Closed (fixed)
Project:
Ubercart
Version:
6.x-2.x-dev
Component:
Code
Priority:
Minor
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
26 Jan 2010 at 22:50 UTC
Updated:
21 Feb 2010 at 23:55 UTC
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
Comment #1
JacobSteelsmith commentedI 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.
Comment #2
JacobSteelsmith commentedPlease 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."
Comment #3
TS79 commentedI 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");
Comment #4
TS79 commentedIf 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.
Comment #5
tr commentedJust 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.