Hi,

the translation of the cart block custom texts stored in variables
'uc_cart_show_help_text'
'uc_cart_block_title'
is missing in function uc_cart_block().

The custom texts delivered via variables_get() need to be passed through t()-function.

file: uc_cart.module
function: uc_cart_block()

Comments

JacobSteelsmith’s picture

I can't find anywhere in the Drupal core, or Ubercart where variable_get is run through t(). Correct me if I'm wrong, but I think the reason is because the default is run through t() For example, variable_get('uc_cart_help_text', t('Click title to display cart contents.')). If the user sets it, it is already in their native language.

JacobSteelsmith’s picture

Priority: Normal » Minor
Status: Needs work » Closed (works as designed)

Please see http://api.drupal.org/api/function/t/6

"However tempting it is, custom data from user input or other non-code sources should not be passed through t(). Doing so leads to the following problems and errors:

The t() system doesn't support updates to existing strings. When user data is updated, the next time it's passed through t() a new record is created instead of an update. The database bloats over time and any existing translations are orphaned with each update.

The t() system assumes any data it receives is in English. User data may be in another language, producing translation errors.

The "Built-in interface" text group in the locale system is used to produce translations for storage in .po files. When non-code strings are passed through t(), they are added to this text group, which is rendered inaccurate since it is a mix of actual interface strings and various user input strings of uncertain origin."

TS79’s picture

I see your point, but without any possibility for translation, Ubercart is useless for multilanguage pages.

So may be the solution can be the possibility to add different custom texts for different languages via admin interface. Perhaps this can be part of a generalized custom-text-translation-concept in drupal, which exists beside the normal t() function.

A kind of storage of all translations inserted via custom interface into one table:

trans_id;lang;translation;is_default
-----------------------------------
"uc_cart_title";"en";"My cart";1
"uc_cart_title";"de";"Mein Warenkorb";0

and a function to get the translation in a specified language (or page language as default) at runtime:

translation_get($trans_id="uc_cart_title", $lang="de");

TS79’s picture

Category: bug » feature
Status: Closed (works as designed) » Needs work

If found a quite smart solution for the problem: internationalization module i18n (http://drupal.org/node/133977) provides the required feature for translation of user defined strings.

A good description is given here: http://drupal.org/node/313293
The Notification module shows an implementation example: http://drupal.org/node/609364

By the way: the two major contributed modules 'views' and 'panels' pass user defined strings (colum-header of tables...) through t(). But there are i18n plugins in place for each module.

tr’s picture

Status: Needs work » Closed (fixed)

I see your point, but without any possibility for translation, Ubercart is useless for multilanguage pages.

Just to be perfectly clear, this has nothing to do with Ubercart - the available mechanisms for internationalization in *Drupal* are what you're complaining about. Ubercart is simply a set of Drupal modules, and has to live with the i18n infrastructure that Drupal provides.

Use of the i18n module to translate variables set by variable_set() is documented on ubercart.org.