Re: How to do i18n better?

From: Date: Mon, 19 Apr 2010 01:51:42 +0000
Subject: Re: How to do i18n better?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-304188@lists.php.net to get a copy of this message
Andre Polykanine wrote:
Hi everyone, I posted this in the PHP-i18n list, however got no answer so trying here). We are making a blog platform (http://oire.org/) which is provided in several languages (currently they are Russian, Ukrainian, and English). 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!"); etc. I know that PHP does support somehow exporting the strings into a .pod file. Maybe it would be better to do that? If so, how can I do it? Could you suggest me maybe a better solution than we currently have? Thanks a lot!
A lot of systems just use conditional includes and a language array. So the following: Some main file: <?php
    $lang = tell_me_what_the_lang_code_is();
    require_once( "lang/messages.$lang.php" );
?> And then in lang/messages.eng.php: <?php
$messages['Welcome!']    = 'Welcome!';
$messages['login-label'] = 'Login:'; $messages['blah-blah'] = 'Blah blah'; ?> And then in lang/messages.fra.php you might have: <?php
$messages['Welcome!']    = 'Bienvenu!';
$messages['login-label'] = 'Accès :'; $messages['blah-blah'] = 'Le blah blah'; ?> There's lots of variations on this also, but the above is a very common method. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP

« previous php.general (#304188) next »