#37 Locale setting in i18n.php


Using squirrelmail-1.4.8 with php-4.4.4 in Solaris 9
(php compiled as CGI-program [not Apache module] with
Solaris 9 [GNU-compatible] gettext), I found that
language de_DE worked only if I created a symlink
locale/de_DE.ISO8859-1 to directory locale/de_DE. I
think the lines from 304 in i18n.php are not optimal:
if ( !((bool)ini_get('safe_mode')) &&
getenv( 'LC_ALL' ) != $longlocale ) {
putenv( "LC_ALL=$longlocale" );
putenv( "LANG=$longlocale" );
putenv( "LANGUAGE=$longlocale" );
putenv( "LC_NUMERIC=C" );
if ($sm_notAlias=='tr_TR') putenv( "LC_CTYPE=C" );
Why set all these variables? (Btw, all LC_... and LANG
besides LC_ALL are normally overridden by the latter!)
After all, setlocale() has already set LC_ALL for the
php binary (this cannot be tested using getenv because
LC_ALL may not exist outside php!). For finding the
translation files, it is now sufficient to set
putenv( "LANGUAGE=$sm_notAlias" );
This finds the files in locale/de_DE rather than in
locale/de_DE.ISO8859-1 (tested!). Btw, putenv cannot
be replaced by setlocale(LANGUAGE, $sm_notAlias), since
php does not recognize LANGUAGE as valid locale category.
What do you think?

<strube (at) physik3 (dot) gwdg (dot) de>


  • Nobody/Anonymous

    Logged In: NO

    I experimented with gettext.php (replacing ru_RU.UTF-8 with
    de_DE.ISO8859-1) and also with system program gettext, the
    latter both in Solaris 9 (with truss) and Linux (with
    strace; here, de_DE.utf8). The problem is simply that
    Solaris 9 gettext does not try recursively stripping (e.g.,
    xx_YY.codeset -> xx_YY -> xx) if the textdomain ".mo" file
    is not found, whereas GNU gettext does try this.
    (I already suspected this earlier after running "make test"
    in building PHP, where the gettext test failed because it
    contained setlocale(LC_ALL, 'fi_FI'); but a directory "fi";
    after renaming this to "fi_FI" the test succeeded.)
    This could be circumvented by using
    putenv( "LANGUAGE=$sm_notAlias" ); instead of
    putenv( "LANGUAGE=$longlocale" );
    and independently of the getenv('LC_ALL') test at that.

  • Tomas Kuliavas

    Tomas Kuliavas - 2006-09-03
    • milestone: 102172 -->

Log in to post a comment.