[development] Translating database fields
mike at mikeyp.net
Wed Sep 23 01:54:09 UTC 2009
I'm sure others have a better handle on this, than I, and I'm sure
they will chime in here.
My understanding is that you could run the output through t() but you
would have to make sure that the users know and the edit page explains
that the strings must be entered in English, and then in turn
translated for each language by hand, using Locale.
One important point to note though, is that you will want to make sure
that the default strings are run through t() somewhere in your code so
that the extractor picks them up, and they are included in packaged
translations. Do not however use the output of t() to insert as
defaults into the database, as the default strings in the database
must remain in English.
I believe I've read somewhere that some modules accomplish this by
including a module_name.locale.php file or some similar with something
$foo = t('A string my module stores in the database');
$foo = t('Another string my module stores in the database');
So that the extractor will find these strings and include them in
mike at mikeyp.net
On Sep 22, 2009, at 6:23 PM, Jeremy Andrews wrote:
> I'm looking for advice on the proper way to resolve this issue:
> The support module  defines four default states ("new", "active",
> "pending", "closed") and four default priorities ("low", "normal",
> "high", "critical"). These fields are defined in the database to
> the easy creation of custom states and priorities. Because of this,
> unsure on how to correctly make them translatable.
> The t() api documentation page  explicitly states, "however
> it is, custom data from user input or other non-code sources should
> be passed through t()." It goes on to explain that doing so can
> lead to
> orphaned words, mistranslation of non-English words, etc. My question
> then is, what is the correct way to make these states and priorities
> Yes, they can simply be changed in the database if you'd like to
> them to another language, but some websites want the ability to
> translate them into multiple languages.
> If replying, please do so in the issue linked above.
>  http://drupal.org/project/support
>  http://api.drupal.org/api/function/t/6
More information about the development