Re: Multi-language support for PHP
| From: | Carl W. Brown | Date: | Fri, 09 Jun 2000 03:57:29 +0000 |
| Subject: | Re: Multi-language support for PHP | ||
| References: | 1 2 3 4 5 | Groups: | php.i18n |
| Request: | Send a blank email to php-i18n+get-17@lists.php.net to get a copy of this message | ||
Hiro,
What I am doing with ICU is making it an Apache facility that can be used by
PHP as well as other applications.
Right now I am working on the per-directory problem. Applications like PHP
are not called on a per directory bases so I am having XICU monitor all
applications that are configured with an AddXICUType. When it encounters a
new directory that would not be processed it will build a special <files>
directive dynamically to get Apache to track per-directory configurations so
that we can set different locale defaults on a per directory basis.
Eventually I think that a more universal application approach will be to
check the input headers. If the language is not correct the url could be
redirected to an acceptable url.
The apache idea if adding an extra type to the URL is not a good idea
because mixing text with different code pages in the same directories is an
administrative nightmare. It is also better if all of the text after a
specific branch is in the same codepage. Otherwise links are a mess. If
you see a Japanese page with a link to a Brazilian URL that may be OK
because a lot of people in Sao Paulo speak Japanese. But at least it gets
your attention.
Carl
"Hironori Neal Sato" <satoh@yyplanet.com> wrote in message
news:20000608112242.A17133@satoh.rc.yyplanet.com...
> 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/
>
> --
> PHP Internationalization Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-i18n-unsubscribe@lists.php.net
> For additional commands, e-mail: php-i18n-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>