Unix Programming - FreeBSD locales

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2007 > FreeBSD locales





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author FreeBSD locales
Darko

2007-10-26, 1:29 pm

Hi,

I have problems implementing i18n on my site hosted on a FreeBSD
server, using PHP. While it was hosted on a Linux server, there were
no problems,
but once I transferred it to FreeBSD, gettext() doesn't translate
anything. Here's my directory structure:

public_html
|-- index.php
`-- locale
|-- en_US.ISO8859-1
| `-- LC_MESSAGES
| |-- OOModelProvider.mo
| `-- OOModelProvider.po
`-- sr_YU.ISO8859-2
`-- LC_MESSAGES
|-- OOModelProvider.mo
`-- OOModelProvider.po

And here's the function that calls php locale-related functions:
/* domain is "OOModelProvider", language is "en_US.ISO8859-2"
*/
function setLocale( $language, $domain )
{
@bindtextdomain( $domain, "/home/darko/public_html/
locale/" );
@bind_textdomain_codeset( $domain, "utf-8" );

if ( ! @setlocale( LC_MESSAGES, $language ) )
throw new Exception( "setlocale" );
textdomain( $domain );
}

This worked perfectly on Linux, but it doesn't work with FreeBSD. I
read somewhere that libintl needs to be installed for LC_MESSAGES, but
1. it is installed 2. LC_ALL instead of LC_MESSAGES doesn't work
neither.

Another important note: LC_DATE works, i.e. sprintf and strftime
(which are locale-aware) work as expected, that is, they print the
strings in expected languages.

Also, after I do setlocale(LC_MESSAGES, $language), I call it with "0"
as the second argument and it returns the correct locale set.

Please, if you have any ideas, post them here.

Thanks.

Darko

2007-10-26, 1:29 pm

On Oct 26, 5:44 pm, Darko <darko.maksimo...@gmail.com> wrote:
> Hi,
>
> I have problems implementing i18n on my site hosted on a FreeBSD
> server, using PHP. While it was hosted on a Linux server, there were
> no problems,
> but once I transferred it to FreeBSD, gettext() doesn't translate
> anything. Here's my directory structure:
>
> public_html
> |-- index.php
> `-- locale
> |-- en_US.ISO8859-1
> | `-- LC_MESSAGES
> | |-- OOModelProvider.mo
> | `-- OOModelProvider.po
> `-- sr_YU.ISO8859-2
> `-- LC_MESSAGES
> |-- OOModelProvider.mo
> `-- OOModelProvider.po
>
> And here's the function that calls php locale-related functions:
> /* domain is "OOModelProvider", language is "en_US.ISO8859-2"
> */
> function setLocale( $language, $domain )
> {
> @bindtextdomain( $domain, "/home/darko/public_html/
> locale/" );
> @bind_textdomain_codeset( $domain, "utf-8" );
>
> if ( ! @setlocale( LC_MESSAGES, $language ) )
> throw new Exception( "setlocale" );
> textdomain( $domain );
> }
>
> This worked perfectly on Linux, but it doesn't work with FreeBSD. I
> read somewhere that libintl needs to be installed for LC_MESSAGES, but
> 1. it is installed 2. LC_ALL instead of LC_MESSAGES doesn't work
> neither.
>
> Another important note: LC_DATE works, i.e. sprintf and strftime
> (which are locale-aware) work as expected, that is, they print the
> strings in expected languages.
>
> Also, after I do setlocale(LC_MESSAGES, $language), I call it with "0"
> as the second argument and it returns the correct locale set.
>
> Please, if you have any ideas, post them here.
>
> Thanks.


Also, even when I *which was a mistake) put ISO8859-1 in
bind_textdomain_codeset, it doesn't work neither.

Darko

2007-10-29, 1:23 pm

On Oct 26, 4:44 pm, Darko <darko.maksimo...@gmail.com> wrote:
> Hi,
>
> I have problems implementing i18n on my site hosted on a FreeBSD
> server, using PHP. While it was hosted on a Linux server, there were
> no problems,
> but once I transferred it to FreeBSD, gettext() doesn't translate
> anything. Here's my directory structure:
>
> public_html
> |-- index.php
> `-- locale
> |-- en_US.ISO8859-1
> | `-- LC_MESSAGES
> | |-- OOModelProvider.mo
> | `-- OOModelProvider.po
> `-- sr_YU.ISO8859-2
> `-- LC_MESSAGES
> |-- OOModelProvider.mo
> `-- OOModelProvider.po
>
> And here's the function that calls php locale-related functions:
> /* domain is "OOModelProvider", language is "en_US.ISO8859-2"
> */
> function setLocale( $language, $domain )
> {
> @bindtextdomain( $domain, "/home/darko/public_html/
> locale/" );
> @bind_textdomain_codeset( $domain, "utf-8" );
>
> if ( ! @setlocale( LC_MESSAGES, $language ) )
> throw new Exception( "setlocale" );
> textdomain( $domain );
> }
>
> This worked perfectly on Linux, but it doesn't work with FreeBSD. I
> read somewhere that libintl needs to be installed for LC_MESSAGES, but
> 1. it is installed 2. LC_ALL instead of LC_MESSAGES doesn't work
> neither.
>
> Another important note: LC_DATE works, i.e. sprintf and strftime
> (which are locale-aware) work as expected, that is, they print the
> strings in expected languages.
>
> Also, after I do setlocale(LC_MESSAGES, $language), I call it with "0"
> as the second argument and it returns the correct locale set.
>
> Please, if you have any ideas, post them here.
>
> Thanks.


Nobody answered, but I found the solution on some old forum. I know
how it feels when you find someone had already asked the same question
that troubles you, but no answers are given. For the moment you feel
happy, and then you get dissappointed.

Anyway, it seems that stupid FreeBSD doesn't care about what you say
with setlocale(), but instead you have to use the antique technique of
putenv( "LANG=en_US.ISO1859-1" );

So, I finished using setlocale for Linuces (since FreeBSD doesn't
report an error for it, though it doesn't work anything), and the next
line is putenv( ... ), and it works ok.

Bye,

Darko

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com