Hi, On Dec/16/2009, BVK Chaitanya wrote: > On Tue, Dec 15, 2009 at 5:18 AM, Carles Pina i Estany <car...@pina.cat> wrote: > > > > Writing a unittest for gettext it's very easy: it just needs a couple of > > .mo and a script executing gettext "string" and checking that the result > > is "string translated". Will get more interesting when ngettext will > > come too :-)
when I said "it's very easy" I was thinking more like "you explain to me how the unittest infrastructure works and I write the test" more than the other way. But no problem at all if you want to write it! > I don't have much knowledge about how gettext works, but I tried to > add unit test today (in my local branch) and I couldn't get it working > :-( Below is what I did, with some questions: > 1. I downloaded zh_CN.po from translationproject.org and placed it in > $(srcdir)/po/ directory. ok! > 2. I tried to build grub.pot, but build failed. ops... > Build rule for grub.pot assumes builddir == srcdir, which is not > true in my case. Also, it looks like that command is trying to > create grub.po in srcdir instead of builddir; is it normal? if we > need grub.pot in srcdir, can we move this step into autogen.sh? I'm not familiar with this part, Robert prepared the building system. Of course I can take a look next days or you can propose a patch. > 3. After fixing the grub.pot rule, I was able to get .mo files in > $(builddir)/po/ > 4. Now I wanted to see if gettext could find the translations without > doing a make install, as below in $(builddir) > > $ LANG="zh_CN" TEXTDOMAINDIR=$(pwd) gettext grub "the core image > is too small" > > It displayed only english version, even though zh_CN translation is > available :-( Since the directory structure in /usr/share/locale is > different from $(builddir), I did "make install" and tried the gettext > command without setting TEXTDOMAINDIR, but still no success :-( > > What is wrong? Can you provide any pointers? This is not what I wanted to test using the unittest, but I can show a shell script that I did last june testing for these things. car...@pinux:~/grub2/oldgrub/grubprova$ cat test.sh #!/bin/bash export TEXTDOMAIN="testscript" export TEXTDOMAINDIR="./locale" echo $(gettext "hello world") And then: car...@pinux:~/grub2/oldgrub/grubprova$ find . ./locale ./locale/ca ./locale/ca/LC_MESSAGES ./locale/ca/LC_MESSAGES/testscript.mo ./locale/ca...@euro.po ./locale/test.pot ./test.sh car...@pinux:~/grub2/oldgrub/grubprova$ and it works: car...@pinux:~/grub2/oldgrub/grubprova$ ./test.sh hola món car...@pinux:~/grub2/oldgrub/grubprova$ I'm not expert in this area, but $TEXTDOMAINDIR in my case is pointing to locale directory that needs to have the above hierarchy. Plus I think that you need to setup TEXTDOMAINDIR even if the files are correctly places in /usr/share/locale. But what I was thinking to test with the unittest is the gettext.mod, not outside. I could do semi-manually doing: a) Different .mo files with some strings (inside /boot/grub/locale/[.mo files]) b) A Grub2 disk image with the script to check the gettext module. Mainly would do (I'll write in pseudo-Bash, would be in Grub script): ------- set lang=ca TESTFAILED=false if [ $(gettext "hello world") -ne "hola món" ] then echo "Test failed 01!" TESTFAILED=true fi if [ ... ] then echo "Test failed 02!" TESTFAILED=true fi set lang=es if [ ... ] then fi if [ $TESTFAILED -eq "true" ] then echo "TESTS FAILEDS" fi ------- So when I do changes in gettext module (like optimizse something, add support for plurals, etc. etc.) I would be sure that everything is all right. Was you thinking something like this? Thanks, -- Carles Pina i Estany http://pinux.info _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel