Re: How to do i18n better?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19 April 2010 00:55, Andre Polykanine <andre@xxxxxxxx> wrote:

>
> Now the i18n process is made as follows: we set a cookie on the site
> and depending on it we select the language to display the site in. We
> have three (currently) interface files: rus.lng, ukr.lng, and enu.lng
> (for English US). the format is the following:
> define ("MSG379", "Welcome!");
>
>
You might want to consider making the language dependent on the URL, e.g.
http://site.com/ru/pagename for Russian. Doing it this way certainly isn't a
bad solution, but I do strongly recommend against using define() and using
anonymous translation keys. Usually, you have one base language (which is
usually English due to its lack of special characters and ubiquity) from
which you work. You then either simplify your keys, e.g. 'user_welcome' =>
'Welcome, %1$s!', or make the keys the proper base language strings so you
can wrap everything in a language function.

In the latter case, you might have something like <p><?= _('Welcome, %1$s!',
$username); ?></p>, and then if the current language is not English, the _()
function will make the appropriate lookup.

The advantage of this is you won't need to have a tertiary source to tell
you which MSG### corresponds to which piece of text.

Michiel

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux