Re: Multi-language support for PHP
| From: | James Byers | Date: | Sun, 04 Jun 2000 19:51:37 +0000 |
| Subject: | Re: Multi-language support for PHP | ||
| References: | 1 | Groups: | php.i18n |
| Request: | Send a blank email to php-i18n+get-9@lists.php.net to get a copy of this message | ||
Carl,
The work you've done sounds very interesting. As Rasmus
mentioned, a few different groups are working on I18N for PHP. I'm
leading a development effort at VA Linux to add Unicode support to PHP4.
We're just about done with our planning process; I hope to have a proposal
to post on the list by tomorrow.
Our plan, in essence, is to modify PHP's string functions to take
UTF-8 inputs, perform an internal conversion to UCS2/4, manipulate the
string, and return the result back in UTF-8.
This leaves a few gaps, notably:
- character set conversion (handled by PHP's recode extension)
- full locale support (extending setlocale's affected functions to handle
all LC_ categories)
- run-time codepage conversion for file i/o, etc. functions
- scripts in any character set that respects ASCII in SBCS and MBCS modes
(requires script pre- and post-processing to convert to and from UTF-8)
It sounds as though you've addressed a lot of these issues
already. Perhaps we can come up with a unified locale-setting system so
setlocale() and friends fit in with your (X)ICU functions. It would also
be a great win to get away from the platform and installed-locale
dependencies of setlocale().
I'm not sure about how the directory mapping you mention would fit
into PHP-space. This seems like an extension of Multiviews / mod_rewrite,
where Apache would parse the URI and present PHP with locale information
by environment variable. In any case, I think PHP developers should be
able to set language/locale/codepage independent of URI.
Between these two efforts (Unicode and ICU functionality), I think
we can provide all the building blocks developers need. I'd be very
interested to see the code you've worked on and list of functions visible
in PHP. I'll post our proposal as soon as I can so you can see where we're
going.
Thanks,
James
On Sun, 4 Jun 2000, Carl W. Brown wrote:
> I am working on a PHP3 module that adds Multi-lingual support to PHP. It al
> lows you to write scripts in different languages and support different local
> es. (More than 80)
>
> You can write scripts using different character sets. It selects the charac
> ter sets automatically based on the file directory and user configurable def
> ault browser codepages.
>
> /en-us/test.php3 will show US settings
> /ko-kr/test.php3 will show Korean settings
> /xxxx/pt-br/zzzzz/test.php3 will show Brazilian settings
>
> It supports date/time, number, currency & percent formats. It supports 4 l
> evels of culturally correct compares. It has upper, lower and title case st
> ring converters.
>
> The date/time routine supports 6 formats: full, long, medium, short, date on
> ly, and numeric date. The order of fields separator characters , the day na
> mes, month names and abbreviations are all locale dependent.
>
> For example the following evaluates to true in en-us:
>
> if (intl_collate("Black-bird","==?","blackbird "):
>
> intl_collate will handle things like French collating sequence, Spanish lett
> ers like ch & ll etc. it will normalize the text and allow you to match on l
> etters only, case insensitive, case sensitive or exact.
>
> The case converter handles converting the German sharp-s to "SS" fixes the G
> reek ending sigma and handles the Turkish dotted and dotless i depending on
> locale.
>
> It will work either in code-page or with UTF-8 scripts.
>
> Currently it is only working with Apache Unix systems.
>
> I have taken the IBM ICU (International Components of Unicode) and converted
> them to an Apache module. I am talking to them about contributing my chang
> es an integrating them into ICU. This makes ICU plus my ICU extensions (XIC
> U) available to Apache applications other than PHP as well.
>
> The international extensions to PHP3 are a different class of application.
> They are linked with the XICU DSO but they are handled by PHP almost as a re
> sident module.
> This application provides services to mod_php.c, main.c and other applicatio
> ns. It sets the locale and default character set in the per directory confi
> guration records. It sets the locale environment for ICU and builds the ICU
> code converter objects (if needed) for each transaction. It also provides f
> ull Unicode and UTF-8 converters for applications.
>
> This could also be made to support CGI because it uses a special linking pro
> cess that should be NT compatible.
>
> The per dir configuration code is not working with PHP3 on Apache now so I h
> ad to implement a work around. Any changed made to global variables after t
> he initial settings are discarded. and the configuration merge code in mod_
> php3.c is never call by Apache.
>
> Who should I contact to coordinate efforts to integrate this into the PHP4 p
> roduct? It does not look like this should be too difficult.
>
> Carl
>