Re: Multi-language support for PHP

From: Date: Thu, 08 Jun 2000 18:22:42 +0000
Subject: Re: Multi-language support for PHP
References: 1 2 3 4  Groups: php.i18n 
Request: Send a blank email to php-i18n+get-16@lists.php.net to get a copy of this message
Let me take a shot at this one. On Mon, Jun 05, 2000 at 09:44:11PM -0700, Carl W. Brown wrote: >We thought of using your package since our first implementation is Korean. > >However when you get more than a few character sets it becomes difficult to >autodetect and some character sets are very close. I have attempted to expand encoding convertor (or we call it mbfl - multi- byte filter library) to work with other language including Korean. As you mentioned, it's near impossible to detect from one encoding from others such as EUC-JP vs EUC-KR. But, if you know the language of text (or script, post data, etc), you should be able to detect encoding for that particular language. Here is what I did to test Korean encoding filter. Although I didn't implemented auto detection routine with Korean, I had a simple wrapper written for mbfl that works with iconv to convert between UTF-8 and EUC-KR. This was the easy part, and it allowed me to whip out encoding convertor quickly. Tricky part was to have knowledge of the language in advance before initialization of mbfl. My implementation would work like this: In apache conf, <VirtualHost xx.xx.xx.xx> ServerName www.kr.somedomain.com php_value i18n_language ko php_value i18n_internal_encoding UTF-8 php_value i18n_output_encoding EUC-KR php_value i18n_script_encoding EUC-KR </VirtualHost> <VirtualHost xx.xx.xx.xx> ServerName www.jp.somedomain.com php_value i18n_language ja php_value i18n_internal_encoding EUC-JP php_value i18n_output_encoding SJIS php_value i18n_script_encoding auto </VirtualHost> I guess you can setup Directory directive same way. Or, we could even go further by using content negotiation, such that filename.ja.php would set i18n_language to ja. Hmmmmm, that would be interesting. Above setup worked for me. I had php script written in EUC-KR which was converted to UTF-8 internally, then output was converted into EUC-KR. At the sametime, Japanese scripts worked as I expected: SJIS script's encoding was autodetected and converted into EUC-JP for internal processing, while output was in SJIS. One major problem that I came upon was how post data was handled. Since, I implemented mbfl as a module, it was never initialized until post data was processed. Thus, I had no way to initialize encoding convertor to process post data. To get around with this problem, I had to move mbfl out of module directory to the root directory, then initialize it before post data processing. I'm kinda stuck at that point right now. (too damn busy with work) As Carl mentioned in previous mail, going with 'everything UTF-8' is an ideal case, but we need someway to take in account for other encodings. I don't exactly know how all these encoding convertor should fit in PHP, but it has to be in there somehow, somewhere... Hiro -- Hironori Neal Sato <satoh@yyplanet.com> Japanese Network - http://www.jpnnet.com/

« previous php.i18n (#16) next »