zigbert and gettext
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
pfind
Please test version 5.02
NLS has German (of course) and Russian (converted from old system)
So you can change between de, ru and English
Next I will try to convert the other languages.......
NLS has German (of course) and Russian (converted from old system)
So you can change between de, ru and English
Next I will try to convert the other languages.......
- Attachments
-
- pfind_changeLANGUAGE.png
- (7.97 KiB) Downloaded 814 times
-
- pfind-NLS.pet
- Russian (to be completed) and German
- (8.45 KiB) Downloaded 658 times
-
- pfind-5.02.pet
- (18.72 KiB) Downloaded 697 times
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
Re: Gettext in pBurn.
Hope you understand my solution in pfind ( used it in ymount some time ago ) Search for LANGUAGE NEW_LANGUAGE and LANGUAGESrodin.s wrote:...I haven't change set-language section of pburn script so translation only works if I choose or type in 'ru' language in Preferences....
Sorry I cannot help very much with testing because I do NOT have CD burner
zigbert2gettext-0.1
OK, the first trial to place gettext inline the code.zigbert wrote:Gettext has the advantage of making the code more readable (also for me ). That is a good thing for the community. Converting the locales-file would sure be good for backward compatibility, but for moving the project further, I think updating the code itself is the way to go.
But for multiple lines, i think we are better to stay the substitution method, that is:
Code: Select all
export LOCXXX=$(gettext "First line
Second lne")
export DIALOG="<text><input>echo -n "\$LOCXXX"</inout></text>"
# zigbert2gettext --help
zigbert2gettext 0.1
Convert zigbert apps into gettext version.
usage: zigbert2gettext [PATH_TO_MAIN_SCRIPT] [TEXT_DOMAIN]
PATH_TO_MAIN_SCRIPT - example: /usr/local/pburn/pburn
But still you need to remove manually some code, loading the locales file, from the converted main script.
- Attachments
-
- zigbert2gettext.gz
- Unzip, add executable, place at /root/my-applications/bin.
- (2.3 KiB) Downloaded 693 times
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]
pBurn updated
I did some tests on pBurn. Tried to burn CD-R. Seems OK. I have also completed translation of mo-file: just have copied lines from old locale file in Poedit with some modifications.
I have also made some changes to previous pet: commented out set-locale this time.
I changed some translation lines for example:
Blank Disc - To blank the disc
and
Blank Disc - The disc is blank
have different translation so I have added whitespace to 'Blank Disc ' in func.
Same with 'Burn ISO-image' button in GUI: to burn and the burn have different translations.
I have also made some changes to previous pet: commented out set-locale this time.
I changed some translation lines for example:
Blank Disc - To blank the disc
and
Blank Disc - The disc is blank
have different translation so I have added whitespace to 'Blank Disc ' in func.
Same with 'Burn ISO-image' button in GUI: to burn and the burn have different translations.
- Attachments
-
- pburn_gtxt2-3.7.3.pet
- Updated pBurn
- (71.7 KiB) Downloaded 612 times
-
- MoManager-ru_UA-pburn-3.7.3.tar.gz
- Full Russian translation this time.
- (14.14 KiB) Downloaded 600 times
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
ptiming
doneL18L wrote:...Next I will try to convert the other languages.......
using shinobar's locale2gettext in
Code: Select all
#!/bin/sh
#
# convert translation file "Zigbert" to "Gettext"
# convert /usr/local/app/locals/LANG to /usr/share/locale/language/app.mo
# which then can be checked/modified using momanager
# 20120805 by L18L
apps="`find /usr/local -name locals | cut -d'/' -f4`" # pburn pfind pfilesearch ...
apps="ptiming" # no, just pvd for now
for app in $apps; do
[ "$app" = "pfind" ] && continue
[ "$app" = "pfilesearch" ] && continue
SOURCE=/usr/local/$app/locales
[ -f "$SOURCE" ] || SOURCE=/usr/local/$app/locals/en_US:english
[ -f "$SOURCE" ] || continue # nothing to translate here
echo " converting /usr/local/$app ..."
# locale2gettext usage: $APPNAME [PATH_TO_LOCALE_FILE] [TEXT_DOMAIN]"
[ -f "$SOURCE.converted" ] || locale2gettext $SOURCE
# $SOURCE.converted has LOCxxx=$(gettext "bla bla")
langs=`ls /usr/local/$app/locals | cut -d'_' -f1 | sort -u`
for lang in $langs; do # for each language
[ "$lang" = "en" ] && continue
echo " from /usr/local/$app/locals/$lang ..."
# input
TEMPLfile=$SOURCE.converted
# we know just ru and must say ru_RU
LOCfile=`ls /usr/local/$app/locals/$lang* | head -n1`
# output
LOCfilePO=$LOCfile.po
echo '#, fuzzy
msgid ""
msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
' > $LOCfilePO
while read LINE ; do
case $LINE in
\#*) continue # skip comments
;;
*) [ -z "$LINE" ] && continue # skip blank lines
[ "`echo $LINE | grep '^export TEXTDOMAIN='`" ] && continue # skip
[ "`echo $LINE | grep '^export OUTPUT_CHARSET='`" ] && continue # skip
[ "`echo $LINE | grep '^set'`" ] && continue # skip
[ "${LINE:0:7}" = "export " ] && LINE="${LINE//export }" # delete 'export '
LINEid=`echo $LINE | cut -d '=' -f1`
msgid=`echo $LINE | cut -d '"' -f2`
msgstr=`grep $LINEid $LOCfile | cut -d '"' -f2 | head -n1`
[ "`grep $LINEid $LOCfilePO`" ] && continue # avoid douplicates
#echo "# $LINEid"
#echo "msgid "$msgid""
echo "msgstr "$msgstr""
#echo ""
echo "# $LINEid" >> $LOCfilePO
echo "msgid "$msgid"" >> $LOCfilePO
echo "msgstr "$msgstr"" >> $LOCfilePO
echo "" >> $LOCfilePO
;;
esac
done < $TEMPLfile
# create mo file and delete po file
if [ "`msgfmt -o /usr/share/locale/$lang/LC_MESSAGES/$app.mo $LOCfilePO`" ]; then
echo could not create /usr/share/locale/$lang/LC_MESSAGES/$app.mo
else
rm $LOCfilePO
echo /usr/share/locale/$lang/LC_MESSAGES/$app.mo created
fi
echo ''
done # lang
echo " ... $app converted"
rm $SOURCE.converted
done # app
echo "finished
You can edit the translations using momanager
"
exit 0
Code: Select all
##set language
#. $APPDIR/locals/en_US:english #always run to fill gaps in translation
#LANGUAGE="`ls -1 $APPDIR/locals/ | grep ${LANG%.*}`"
##fallback to macrolanguage if available (ISO 639-1 two letter code: en, es, fr, etc.)
#if [ -z $LANGUAGE ]; then LANGUAGE="`ls -1 $APPDIR/locals/ | grep ${LANG%_*}:`"; fi
#[ "$LANGUAGE" != "en_US:english" ] && . $APPDIR/locals/$LANGUAGE 2> /dev/null
#
- Attachments
-
- ptiming_converted.png
- (30.03 KiB) Downloaded 729 times
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
pburn
downloaded version 3.7.4 shows as 3.7.3zigbert wrote:Pburn is updated with gettext
Anyhow, I have converted all languages to pburn.mo using rodin.s `s version above.
So everyone will have to start not from zero
---
edit
going to test version now
- Attachments
-
- pburn_NLS.pet
- some locals converted to pburn.mo
- (48.96 KiB) Downloaded 632 times
Re: pfind
$TEXTDOMAIN=pfilesearch in your pFind. I guess it's because there only can be one text domain, and code from pFilesearch is embedded into pFind.L18L wrote:Please test version 5.02
That means NLS files for pFilesearch will contain gettext-strings for both pFind and pFilesearch? Not the best solution for those who uses only pFilesearch as a backend for pBurn/pMusic.... My intention is to separate the backend and frontend.
What is the downside of having an unique $TEXTDOMAIN=pfind?
Sigmund
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
Re: pfind
Good guess!zigbert wrote:$TEXTDOMAIN=pfilesearch in your pFind. I guess it's because there only can be one text domain, and code from pFilesearch is embedded into pFind.
That was before Barry changed momanager.
Now everything is possible:
I will separate them and make a version 5.03
TEXTDOMAIN=pfind
and pfilesearch using TEXTDOMAIN=pfilesearch containing the messages from pfilesearch only.
Re: pfind
Thank you.L18L wrote:Good guess!zigbert wrote:$TEXTDOMAIN=pfilesearch in your pFind. I guess it's because there only can be one text domain, and code from pFilesearch is embedded into pFind.
That was before Barry changed momanager.
Now everything is possible:
I will separate them and make a version 5.03
TEXTDOMAIN=pfind
and pfilesearch using TEXTDOMAIN=pfilesearch containing the messages from pfilesearch only.
I will be back Tuesday (probably).
Sigmund
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
Re: pfind
doneL18L wrote:I will separate them and make a version 5.03
TEXTDOMAIN=pfind
included is german pfind.mo so you can test changinging of GUI language
for testers only, delete /root/.pfind/pfindrc
a lot of warnings like:
/usr/local/pfind/func: line 4: /tmp/pfind-TREE6413: Datei oder Verzeichnis nicht gefunden <-- not found
cat: /tmp/pfind-treeitems6413: Datei oder Verzeichnis nicht gefunden <-- not found
- Attachments
-
- pfind-5.03.pet
- TEXTDOMAIN=pfind
was pfilesearch before - (23.33 KiB) Downloaded 559 times
pburn
Pburn doesn't switch to Russian automatically. But it does when 'ru' is selected in Preferences. Usually gettext doesn't need this manual language switching. The language of an application is defined by global locale settings of the system.
Re: pburn
Does this occur only for pBurn or is it so for all the zigbert gettext apps?rodin.s wrote:Pburn doesn't switch to Russian automatically. But it does when 'ru' is selected in Preferences. Usually gettext doesn't need this manual language switching. The language of an application is defined by global locale settings of the system.
Sigmund
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
Re: pburn
Running pburn from latest precise 5.2.69zigbert wrote:Does this occur only for pBurn or is it so for all the zigbert gettext apps?rodin.s wrote:Pburn doesn't switch to Russian automatically. But it does when 'ru' is selected in Preferences. Usually gettext doesn't need this manual language switching. The language of an application is defined by global locale settings of the system.
Sigmund
added
echo LANGUAGE=$LANGUAGE
to line 271 of /usr/local/pburn/pburn
gettext is using a LANGUAGE named auto here but for auto there is no pburn.momy console wrote:# pburn
LANGUAGE=auto
EXIT="Ready"
gettext uses automagically user´s language from LANG
-> the option auto has to be removed from the list of available languages
LANGUAGE is a system variable, do use it in its intended purpose only: http://www.gnu.org/software/gettext/man ... E-variable
Hope that helps
Ok, I have changed $LANGUAGE to $MY_LANGUAGE, and added 2 lines after reading rc file. I had no idea gettext relies on $LANGUAGE.
Code: Select all
#set variables
. $CONFIG 2> /dev/null
export LANGUAGE="$MY_LANGUAGE"
[ "$MY_LANGUAGE" = "auto" ] && export LANGUAGE="${LANG%%_*}"
- Attachments
-
- pburn-3.7.5.pet
- (67.08 KiB) Downloaded 471 times