MoManager: handling multiple langpacks
May 03, 2013 —
BarryK
I committed some work on MoManager yesterday:
http://bkhome.org/archive/blog2/201305/momanager-loop-if-po-to-mo-fail.html
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
Comments
Re. Langpack-template/pinstall.shUsername: L 18 L
[i]This is good, not just for installing multiple langpacks, but also if the .xml files change in Woof[/i]... ... and if there will ever come a [b]dialect variant[/b] like e.g. [b]fr_CA[/b] which must also use [b]fr[/b] because not every message is different from fr .... Checking the code: [code]LANG1="`cat pet.specs | cut -d'-' -f1 | cut -d'_' -f2`" #130503 L18L: langpack may be different from current LANG setting.[/code] It is bad, really bad. Sorry, my fault. Correct is: [code]LANG1="`cat pet.specs | cut -d'-' -f1`" #130503 L18L: langpack may be different from current LANG setting.[/code] - 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
Getting LANG
Username: BarryK
"Neither is correct. I fixed it, see here: [code]# echo 'langpack_de-20130310' | cut -d'-' -f1 | cut -d'_' -f2- de # echo 'langpack_de_DE-20130310' | cut -d'-' -f1 | cut -d'_' -f2- de_DE [/code]
Re: Getting LANG
Username: L 18 L
":happy: :happy: :happy:
momanager test
Username: L 18 L
"[i]Note, I haven't actually tested these changes yet.[/i] 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
diff test
Username: BarryK
"L18L, Did you actually get an error with that line? It should work without the square brackets.
re diff test
Username: L 18 L
"No "[i]error[/i]" 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: [code]export TEXTDOMAIN=foo echo $(gettext 'foo')[/code] ..and it was not possible to create a .mo file for this script. I had inserted the square brackets and then it was OK.
diff test
Username: BarryK
"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: [code]#!/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 [/code] The problem was the !, I removed that.
diff test
Username: BarryK
"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=$?
diff: square brackets
Username: L 18 L
"[b]Without square brackets and ! removed[/b] gave expected result: MoManager: mo create aborted You did not change foo.po, so operation aborted. [b]With square brackets and ! removed[/b] 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...
Tags: woof