MoManager: handling multiple langpacks

I committed some work on MoManager yesterday:
http://bkhome.org/blog2/?viewDetailed=00215

While the momentum is there, I have implemented some more improvements...

Firstly, I added a test to check if a .po file is changed after having been edited.

Secondly, I implemented code to rename /usr/local/apps/*/AppInfo.xml files to AppInfo.xml.in, to cater for installation of multiple langpacks, as L18L has posted about here:
http://www.murga-linux.com/puppy/viewtopic.php?t=85648&start=15

L18L has posted changes to 'momanager' and usr/share/doc/langpack-template/pinstall.sh (25 April 2013):
http://www.murga-linux.com/puppy/viewtopic.php?t=85648&start=15

I have implemented these changes. This is good, not just for installing multiple langpacks, but also if the .xml files change in Woof, only the translation lines from the langpack get merged, not the entire .xml file replaced.

Note, I haven't actually tested these changes yet.

Woof commit:
http://bkhome.org/fossil/woof2.cgi/info/22e97ae762


Posted on 3 May 2013, 9:20


Comments:

Posted on 3 May 2013, 21:49 by L 18 L
Re. Langpack-template/pinstall.sh
This is good, not just for installing multiple langpacks, but also if the .xml files change in Woof...

... and if there will ever come a dialect variant
like e.g. fr_CA which must also use fr because not every message is different from fr ....

Checking the code:
LANG1="`cat pet.specs | cut -d'-' -f1 | cut -d'_' -f2`" #130503 L18L: langpack may be different from current LANG setting.

It is bad, really bad. Sorry, my fault.
Correct is:
LANG1="`cat pet.specs | cut -d'-' -f1`" #130503 L18L: langpack may be different from current LANG setting.

- is the separator between language and date
and the language of langpack must stay with what it it is defined by the translator to be.
examples:
de_CH (SwizzerDeutsch) must coexist with de
pt_BR must exist besides pt and pt_PT
and the diverse Chineses (no, they seem to live happily together without momanager and our naming scheme)

PS: more stuff for multiple langpacks in
http://murga-linux.com/puppy/viewtopic.php?t=85888



Posted on 3 May 2013, 23:02 by BarryK
Getting LANG
Neither is correct. I fixed it, see here:

# echo 'langpack_de-20130310' | cut -d'-' -f1 | cut -d'_' -f2-

de
# echo 'langpack_de_DE-20130310' | cut -d'-' -f1 | cut -d'_' -f2-
de_DE




Posted on 4 May 2013, 2:59 by L 18 L
Re: Getting LANG





Posted on 6 May 2013, 3:01 by L 18 L
momanager test
Note, I haven't actually tested these changes yet.

I did.
if ! diff -q /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1 /tmp/momanager/${ATEXTDOMAIN}.po >/dev/null 2>&1; then #130503

should be
if [ ! diff -q /tmp/momanager/${ATEXTDOMAIN}.poBACKUP1 /tmp/momanager/${ATEXTDOMAIN}.po >/dev/null 2>&1 ] ; then #130503

occuring twice


and a lightning fast momanager at 5th post of
http://www.murga-linux.com/puppy/viewtopic.php?p=655552




Posted on 6 May 2013, 12:07 by BarryK
diff test
L18L,
Did you actually get an error with that line?

It should work without the square brackets.



Posted on 6 May 2013, 16:03 by L 18 L
re diff test
No "error" but wrong result.
always ABORTFLAG=8 and break.

I have found this while translating a small test script named foo in /root/my-applications/bin:

export TEXTDOMAIN=foo

echo $(gettext 'foo')


..and it was not possible to create a .mo file for this script.

I had inserted the square brackets and then it was OK.





Posted on 6 May 2013, 18:45 by BarryK
diff test
L18L,
Oh, I see what is wrong. No, the square brackets are not appropriate, you will never get ABORTFLAG=8.

I did a little test:

#!/bin/sh


if diff -q NewFile1 NewFile2 >/dev/null 2>&1; then
echo 'The files are the same'
else
echo 'The files are different'
fi


The problem was the !, I removed that.



Posted on 6 May 2013, 18:52 by BarryK
diff test
Or maybe I am being a bit hasty discounting the square brackets, maybe that will work.

Anyway, normally when you are only testing the return status value of an application, you don't need the square brackets.
A return value of zero means success, which for diff means the files are the same, and for bash, value of zero is "true". Any non-zero value is "false".

Note, in bash you can read the return value with $?
Ex: RETVAL=$?



Posted on 6 May 2013, 19:46 by L 18 L
diff: square brackets
Without square brackets and ! removed
gave expected result:
MoManager: mo create aborted
You did not change foo.po, so operation aborted.

With square brackets and ! removed
gave wrong result:
mo file was created
when no changes in po file were made and editor closed.

#130506 [ ! diff... ] -> diff...
I am going to post this on forum too...