[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gettext
From: |
Vlada von Strasnic |
Subject: |
Re: gettext |
Date: |
Tue, 23 Apr 2002 02:57:40 +0200 |
User-agent: |
Mutt/1.3.21i |
On Mon, Apr 15, 2002 at 02:20:57PM +0200, Bruno Haible wrote:
> Vlada von Strasnic writes:
> > even if i compile the program from sources and ./configure
> > detects NLS , it compiles , i do "make install" and it doesn't work !!!
>
> Here are a few things that you can check, in order to determine the
> cause of the problem:
>
> - Try the command "locale", to see which is the locale that the system uses.
> - Check your environment variables LC_ALL, LC_CTYPE, LC_MESSAGES,
> LANG, LANGUAGE against the description in the ABOUT-NLS file.
> - Use the 'strace' utility to see which files are accessed by your
> program.
> - Does your program's main() function start out with
> setlocale(LC_ALL,"") ?
> - The gettext package's testsuite verifies that translations work.
> Does "make check" of gettext pass on your system?
yes of course
>
ok, i said previously that my programs are working. With little bit more
examination i realised , that they are working only occasionaly .
Because i feel the problem is on the gettext side i'm giving description
of all that.
#include <stdio.h>
#include <locale.h>
#include <libintl.h>
#define _(String) gettext (String)
#define gettext_noop(String) (String)
#define N_(String) gettext_noop (String)
#define PKG "gettext_ak"
#define LOCDIR "/zz/mysrc/tests/intl001/locale"
// cesta ke katalogu je :
// /dir/locale/language/category/domainname.mo
// ......... .......... //toto lze zadat gettextu
primo
// ....... ......... //toto lze zadat pro kazdy _()
// ...... //pouze velmi neprimo
extern int _nl_msg_cat_cntr;
void gettext_do_update() { _nl_msg_cat_cntr ++ ; }
int main () {
char o[400] ;
printf ( "* * setlocale: %s\n" , setlocale ( LC_ALL, "") ) ;
printf ( "* * textdomain: %s\n" , textdomain (PKG) ) ;
printf ( "* * bindtextdomain: %s\n" , bindtextdomain (PKG, LOCDIR) );
printf ( "* * textdomain: %s\n" , textdomain (PKG) ) ;
printf ("\n" ) ;
printf ( _("%s goes from hollywood\n") , _("frankie") ) ;
++_nl_msg_cat_cntr;
printf ( _("%s goes from hollywood\n") , _("frankie") ) ;
printf ("\n" ) ;
// printf ( "* * setlocale: %s\n", setlocale(LC_MESSAGES,"de_DE") );
// setenv ("LC_MESSAGES", "de_DE", 1); //this doesn't work
// setenv ("LC_ALL", "pl", 1); // this doesn't work
// printf ( "* * setlocale: %s\n" , setlocale ( LC_ALL, "") ) ;
setenv ("LANGUAGE", "cs_CZ", 1); // this works
++_nl_msg_cat_cntr;
printf ( _("%s goes from hollywood\n") , _("frankie") ) ;
printf ("\n" ) ;
// setenv ("LC_ALL", "no", 1); // this doesn't work
// printf ( "* * setlocale: %s\n" , setlocale ( LC_ALL, "") ) ;
setenv ("LANGUAGE", "de", 1);
++_nl_msg_cat_cntr;
printf ( _("%s goes from hollywood\n") , _("frankie") ) ;
return 0;
}
-----------------------------------------
I'm not supllying message catalogs, because they contain just random strings,
to show that it works. ( just say if you want them and i will send *.tgz)
gcc gettext_ak.c
starting position is "C" .... this means: unset LC_* , LANGUAGE , LANG;
So we have clean environment and can start right on. Now comes listing of
commands and ... Please read first comments under the dash-line and return
here ( if you will have enough courage )
03:17/mnt/za/my/te/intl001 0> ./a.out // simplest run
* * setlocale: C
* * textdomain: gettext_ak
* * bindtextdomain: /zz/mysrc/tests/intl001/locale
* * textdomain: gettext_ak
frankie goes from hollywood
frankie goes from hollywood
frankie goes from hollywood
frankie goes from hollywood
03:19/mnt/za/my/te/intl001 0> export LC_ALL=en_US // this works
03:41/mnt/za/my/te/intl001 0> ./a.out
* * setlocale: en_US
* * textdomain: gettext_ak
* * bindtextdomain: /zz/mysrc/tests/intl001/locale
* * textdomain: gettext_ak
frankie goes from hollywood
frankie goes from hollywood
jo nas frantisek goes from hollywood
unser franz goes from hollywood
03:46/mnt/za/my/te/intl001 0> export LC_ALL=cs_CZ // this works
03:53/mnt/za/my/te/intl001 0> ./a.out
* * setlocale: cs_CZ
* * textdomain: gettext_ak
* * bindtextdomain: /zz/mysrc/tests/intl001/locale
* * textdomain: gettext_ak
jo nas frantisek goes from hollywood
jo nas frantisek goes from hollywood
jo nas frantisek goes from hollywood
unser franz goes from hollywood
03:54/mnt/za/my/te/intl001 0>
05:50/mnt/za/my/te/intl001 0> export LC_ALL=de_DE // this doesn't
05:59/mnt/za/my/te/intl001 0> ./a.out
* * setlocale: (null)
* * textdomain: gettext_ak
* * bindtextdomain: /zz/mysrc/tests/intl001/locale
* * textdomain: gettext_ak
frankie goes from hollywood
frankie goes from hollywood
frankie goes from hollywood
frankie goes from hollywood
07:33/mnt/za/my/te/intl001 0> export LANGUAGE=de // hard to tell if
07:47/mnt/za/my/te/intl001 0> ./a.out // this result should
* * setlocale: (null) // be considered as
* * textdomain: gettext_ak // passed or failed
* * bindtextdomain: /zz/mysrc/tests/intl001/locale
* * textdomain: gettext_ak
frankie goes from hollywood
frankie goes from hollywood
frankie goes from hollywood
frankie goes from hollywood
08:12/mnt/za/my/te/intl001 0> export LC_ALL=sk // this works
08:18/mnt/za/my/te/intl001 0> ./a.out
* * setlocale: sk
* * textdomain: gettext_ak
* * bindtextdomain: /zz/mysrc/tests/intl001/locale
* * textdomain: gettext_ak
unser franz goes from hollywood
unser franz goes from hollywood
jo nas frantisek goes from hollywood
unser franz goes from hollywood
08:20/mnt/za/my/te/intl001 0>
---------------
Comments : Previous code is not very readable ( it lacks my PS1 highlighting ),
so summary of all that is ( i added one more line to this table ) :
LANG | LC_ALL | LANGUAGE | setlocale | translated | force cs_CZ | force de
-- -- -- C no no no
-- cs_CZ -- cs_CZ into cs yes yes
-- en_US -- en_US no yes yes
-- de_DE -- (null) no no no
-- de_DE de (null) no no no
-- sk de sk into de yes yes
-- -- cs C no no no
What this means ??
1) i hoped LANGUAGE has higher priority then anything , but this shows it's
not true. It's enough to set some lower priority LC_anything to illegal
string
and LANGUAGE loses
2) gettext doesn't work even when LC_* are unset . Because it cannot be forced
to other language - line 1 and the last one !! Isn't that bug ?
3) my system doesn't seem to understand de_DE . During mandrake instalation
i choosed just en,cz,sk . It means that locale/de/* doesn't contain all that
monetary,ctime,numbers stuff. But locale/de/LC_MESSAGES/* exist !!!!
But gettext is refusing to work . Why ?? I think that catalogs should be
enough to work .
Let me know if you feel this is/is not a bug.
--------------
Other programs works exactly the same way. I previously said they don't work
at all. That was probably by several accidents that probably joined together
1) it's not obvious for beginner that state of $LANGUAGE is not
reflected in output of locale(3) .. So month ago, when i
verified my tests with locale, i had no chance to recognize
the reason. ( i had LANGUAGE=en_US , but diagnostic program
didn't tell - maybe it should be considered a bug )
2) my test were usually executed in new shell, so everytime i spawned
new xterm , it had executed my .bashrc and ...
3) as a bad luck i probably didn't tried ls --help in the same shell
as my programs, but in different ones .
4) i was very often experimenting with hu_HU as this is favourite
language of my friend ( he understand just same 20 words , but
he like to see it on the screen )
So i do apologize about that , but the fault is not completely on my side.
Anyway i'm happy that i can finaly run gimp in czech !
Good night , i'm completely tired
HiS.
--
signed short (mail)