RE: [PHP] Internationalizing Content

From: Date: Tue, 26 Sep 2000 03:54:28 +0000
Subject: RE: [PHP] Internationalizing Content
Groups: php.general 
Request: Send a blank email to php-general+get-17507@lists.php.net to get a copy of this message
just an addition: why not to use something like this instead of cookies: (if your website is not too "?qq=aa" I mean if you have more .html parseable files and less GET methods..) <? // Set language: if (substr ($SCRIPT_NAME, 0, 10) == "/japanese/") { $myCharSet ="Shift_JIS"; $myDCLang ='JA'; } else { $myCharSet ="iso-8859-1"; $myDCLang ='EN'; } ?> <meta http-equiv="Content-Type" content="text/html; charset=<? echo $myCharSet; ?>"> <meta name="DC.Language" content="<?=$myDCLang?>"> That what I use. of course you then will need to have different languages in different folders/subdomains/filenames . but isn't it what is usually done while internationaling a web content? Cheers! -----Original Message----- From: Lawrence.Sheed@dfait-maeci.gc.ca [mailto:Lawrence.Sheed@dfait-maeci.gc.ca] Sent: Tuesday, September 26, 2000 12:45 PM To: augustz@bigfoot.com; php-general@lists.php.net Subject: RE: [PHP] Internationalizing Content I wouldn't bother with trying to force the character set into any given type, or depending on receiving the correct locale from the browser. A lot of browsers are broken in this respect and give wrong or incorrect information - the different flavors of IE are good at this. The best solution I've found is to let the user choose what they want from a list or menu, and then force the language type in the HTML header based on a cookie set from the language type selected. Eg: if (isset($LangCookie)) { $PrefLang == $LangCookie; } switch ($PrefLang) { case 1: $header ="<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"; case 3: $header = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">"; } print "<HTML><HEADER>$header</HEADER>"; Obviously you'll be using either flat file or a database for the real html file headers - I use a ereg replace function on the html I output from a file, replacing a placemarker with the correct header. Eg x.html <HTML> <HEAD> {HEADER} </HEAD> ... $content = ParseFile ("x.html","{HEADER}", $header); print $content; (where parsefile does what I've described above). As for MySql - Store the text in a MEDIUMTEXT BINARY field type, and its ok. I have simplified chinese, traditional chinese, english, and french on one of the sites I do, and that serves it well. For multiple languages, its good to use another table with language type in - eg I have a language table with 2 fields ID Language which contains 1, English 2, French 3, Chinese ... SampleTable with text in ID LangID Other Data I can then select from SampleTable by LangID = whatever in addition to my usual select query. I know this is rather basic, but it works ;) I've found internationalization is easy if you plan it from the very beginning, if you add internationalization afterwards, its a complete pain. Also remember not all languages are left to right - Hebrew and the Aramaic Languages are right to left. Good luck. -----Original Message----- From: August Zajonc [mailto:augustz@bigfoot.com] Sent: September 24, 2000 05:16 AM To: Php-General Subject: [PHP] Internationalizing Content Interested in internationalizing the content of our site into 10 or so languages. Would love pointers to clear descriptions of how to generate web pages in multiple languages, from detecting locals to serving the proper file based on the locale of the end user to how one should store the internationalized versions of the strings in a database such as MySQL. A quick and simple approach is to store string equivalents in a database such as MySQL and then substitute based on users locale. MySQL lists the following character sets: latin1 big5 czech euc_kr gb2312 gbk sjis tis620 ujis dec8 dos german1 hp8 koi8_ru latin2 swe7 usa7 cp1251 danish hebrew win1251. but there has to be a simpler way to have all languages represented in a single charachter set. Can I fit most of them in latin1 (german, french, italian etc)? What are good tools for users to submit their translations of the strings? Any other pointers on this topic? August -- 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 (#17507) next »