Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NL3Z2-0000Cf-Tq for mharc-grub-devel@gnu.org; Wed, 16 Dec 2009 18:45:52 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NL3Z1-0000CS-Jl for grub-devel@gnu.org; Wed, 16 Dec 2009 18:45:51 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NL3Yw-0000BM-CH for grub-devel@gnu.org; Wed, 16 Dec 2009 18:45:50 -0500 Received: from [199.232.76.173] (port=32790 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NL3Yw-0000BJ-6p for grub-devel@gnu.org; Wed, 16 Dec 2009 18:45:46 -0500 Received: from 197.red-80-32-81.staticip.rima-tde.net ([80.32.81.197]:58396 helo=mail.pina.cat) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NL3Ys-00073m-Ke for grub-devel@gnu.org; Wed, 16 Dec 2009 18:45:43 -0500 Received: from pinux (82-45-164-87.cable.ubr06.hari.blueyonder.co.uk [82.45.164.87]) by mail.pina.cat (Postfix) with ESMTP id C986E288F3009 for ; Thu, 17 Dec 2009 00:45:36 +0100 (CET) Received: by pinux (Postfix, from userid 1000) id B5EBB9680; Wed, 16 Dec 2009 23:45:50 +0000 (GMT) Date: Wed, 16 Dec 2009 23:45:50 +0000 From: Carles Pina i Estany To: The development of GNU GRUB Message-ID: <20091216234550.GE6192@pina.cat> References: <20091214234808.GC29506@pina.cat> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: Unittests X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Dec 2009 23:45:51 -0000 Hi, On Dec/16/2009, BVK Chaitanya wrote: > On Tue, Dec 15, 2009 at 5:18 AM, Carles Pina i Estany = 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 res= ult > > 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 =3D=3D srcdir, which is no= t > 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) >=20 > $ LANG=3D"zh_CN" TEXTDOMAINDIR=3D$(pwd) gettext grub "the core imag= e > is too small" >=20 > 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 :-( >=20 > 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. carles@pinux:~/grub2/oldgrub/grubprova$ cat test.sh=20 #!/bin/bash export TEXTDOMAIN=3D"testscript" export TEXTDOMAINDIR=3D"./locale" echo $(gettext "hello world") And then: carles@pinux:~/grub2/oldgrub/grubprova$ find . ./locale ./locale/ca ./locale/ca/LC_MESSAGES ./locale/ca/LC_MESSAGES/testscript.mo ./locale/ca_ES@euro.po ./locale/test.pot ./test.sh carles@pinux:~/grub2/oldgrub/grubprova$=20 and it works: carles@pinux:~/grub2/oldgrub/grubprova$ ./test.sh=20 hola m=F3n carles@pinux:~/grub2/oldgrub/grubprova$=20 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=3Dca TESTFAILED=3Dfalse if [ $(gettext "hello world") -ne "hola m=F3n" ] then echo "Test failed 01!" TESTFAILED=3Dtrue fi if [ ... ] then echo "Test failed 02!" TESTFAILED=3Dtrue fi set lang=3Des 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, --=20 Carles Pina i Estany http://pinux.info