RE: software localization with PHP

From: Date: Wed, 14 Mar 2001 19:30:40 +0000
Subject: RE: software localization with PHP
Groups: php.general 
Request: Send a blank email to php-general+get-43902@lists.php.net to get a copy of this message
You can still do: in your language file (presumably called english.php) define("ENGLISH_GREETING", "Hello, \$first_name"); Then in your script you just need to use ENGLISH_GREETING it should work as long as you have defined $first_name prior to using ENGLISH_GREETING you may have to declare $first_name as a global variable but I am not sure. Kevin Leavell kevin@ldigitaldesign.com P 406.829.8989 C 406.240.4595 ---> -----Original Message----- ---> From: Tao [mailto:taoliang@cdr.stanford.edu] ---> Sent: Wednesday, March 14, 2001 12:14 PM ---> To: kevin@ldigitaldesign.com ---> Subject: software localization with PHP ---> ---> ---> Kevin, ---> ---> Thanks for the reply. This will not solve my problem. The ---> problem is, for some ---> languages the sentence structure may be different. For ---> example, the sentence ---> may need to be, ---> $greeting = "$first_name, welcome!" ---> as opposed to, ---> $greeting = "Welcome, $first_name!" ---> ---> Or, it can come in a different form, like, ---> $greeting = "Good morning, $first_name." ---> ---> These specificity need to be in the language file, not the scripts. ---> ---> Tao ---> ---> ---> Leavell Digital Design wrote: ---> ---> > You can use constants: ---> > ---> > in your language file ---> > define("HELLO", OLA); ---> > ---> > in your script which includes the language file you can write ---> > $greeting = HELLO . " $first_name"; ---> > ---> > print $greeting; ---> > ---> > Kevin Leavell ---> > kevin@ldigitaldesign.com ---> > P 406.829.8989 ---> > C 406.240.4595 ---> > ---> > ---> -----Original Message----- ---> > ---> From: Tao [mailto:taoliang@cdr.stanford.edu] ---> > ---> Sent: Tuesday, March 13, 2001 9:50 PM ---> > ---> To: php-general@lists.php.net ---> > ---> Subject: [PHP] software localization with PHP ---> > ---> ---> > ---> ---> > ---> Hi all, ---> > ---> ---> > ---> I have a question about localizing PHP scripts. I understand ---> > ---> that for basic ---> > ---> localization one can have a "strings" file for each language, ---> > ---> which contains ---> > ---> string variables and values such as: ---> > ---> <?php ---> > ---> $title = "Welcome!"; ---> > ---> $error = "An error occurred."; ---> > ---> ?> ---> > ---> ---> > ---> Then, in the scripts just "include" the language file at the ---> > ---> beginning and ---> > ---> simply call the strings by their variable names. The issue I ---> > ---> have is when ---> > ---> embedding variables within these strings. Suppose I need to ---> > ---> call the user ---> > ---> by his/her first name, in the strings file I would have ---> a variable like ---> > ---> this: ---> > ---> $greeting = "Welcome! $first_name"; ---> > ---> ---> > ---> The problem is, the strings file is loaded at the beginning of ---> > ---> the script ---> > ---> before $first_name was set, so the $greeting string ---> will come out as ---> > ---> "Welcome! ", with $first_name being an empty string. Even if ---> > ---> I loaded the ---> > ---> strings file after the $first_name variable is set, the ---> problem still ---> > ---> remains - when $first_name variable is changed, the strings ---> > ---> file has to be ---> > ---> reloaded. ---> > ---> ---> > ---> What is the best way of dealing with this problem? Is there a ---> > ---> place to find ---> > ---> "best practices" on localizing PHP software? ---> > ---> ---> > ---> Tao ---> > ---> ---> > ---> ---> > ---> ---> > ---> -- ---> > ---> PHP General Mailing List (http://www.php.net/) ---> > ---> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net ---> > ---> For additional commands, e-mail: php-general-help@lists.php.net ---> > ---> To contact the list administrators, e-mail: ---> > ---> php-list-admin@lists.php.net ---> > ---> > -- ---> > PHP General Mailing List (http://www.php.net/) ---> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net ---> > For additional commands, e-mail: php-general-help@lists.php.net ---> > To contact the list administrators, e-mail: ---> php-list-admin@lists.php.net

« previous php.general (#43902) next »