[development] Translating database fields
Michael Prasuhn
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
like:
<?php
$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
translation templates.
-Mike
__________________
Michael Prasuhn
503.512.0822 office
503.539.3864 cell
503.661.7574 home
mike at mikeyp.net
http://mikeyp.net
On Sep 22, 2009, at 6:23 PM, Jeremy Andrews wrote:
> Hello,
>
> I'm looking for advice on the proper way to resolve this issue:
> http://drupal.org/node/571742
>
> Summary:
> The support module [1] defines four default states ("new", "active",
> "pending", "closed") and four default priorities ("low", "normal",
> "high", "critical"). These fields are defined in the database to
> allow
> the easy creation of custom states and priorities. Because of this,
> I'm
> unsure on how to correctly make them translatable.
>
> The t() api documentation page [2] explicitly states, "however
> tempting
> it is, custom data from user input or other non-code sources should
> not
> 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
> translatable?
>
> Yes, they can simply be changed in the database if you'd like to
> change
> 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.
>
> Thanks,
> -Jeremy
>
> [1] http://drupal.org/project/support
> [2] http://api.drupal.org/api/function/t/6
>
>
More information about the development
mailing list