Localizing scripts

For efforts in internationalising Puppy and solving problems in this area
Message
Author
User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

localization of xorgwizard

#121 Post by shinobar »

tnx for testing smourguit.

your xorgwizard417-loc.pet works with np as for 2-letter langage codes.
i think the code from MU can be expanded for more precise language selection.

line 38-45 (code from MU)

Code: Select all

#-- simple localization for scripts by MU. Localized JJ Moulinier July 2009
mo=xorgwizard.mo
lng=`echo $LANG | sed "s/\(..\).*/\1/"`
#echo $lng
. "/usr/share/locale/en/LC_MESSAGES/$mo"
if [ -f "/usr/share/locale/$lng/LC_MESSAGES/$mo" ];then
  . "/usr/share/locale/$lng/LC_MESSAGES/$mo"
fi
my code as described before: (the priority between 'en' and 'C' changed on 25 aug)

Code: Select all

#-- simple localization for scripts by Shinobar based on MU.
mo=xorgwizard.mo
# set locale
for lng in C $(echo $LANGUAGE|cut -d':' -f1) $LC_ALL $LANG;do :;done   # ex.    ja_JP.UTF-8
# search locale file
lng1=$(echo $lng|cut -d'.' -f1)      # ex.   ja_JP
lng2=$(echo $lng|cut -d'_' -f1)   # ex.   ja
LOCALEDIR=/usr/share/locale
[ "$mo" ] || mo=$(basename $0).mo
for D in en C $lng2 $lng1 $lng
do
   F="$LOCALEDIR/$D/LC_MESSAGES/$mo"
   [ -f "$F" ] && . "$F"
done
Last edited by shinobar on Tue 25 Aug 2009, 02:01, edited 1 time in total.

User avatar
esmourguit
Posts: 1410
Joined: Fri 17 Nov 2006, 14:45
Location: Entre l'ile aux oiseaux.et l'ile de sainte Lucie

#122 Post by esmourguit »

Bonjour à tous,
Here are xorgwizard_417 and chooselocale scripts localized (french and english .po files) with shinobar improvements.
Hope B. Kauler will place them in future releases.
Cordialement ;)
Attachments
chooselocale_Loc.pet
(4.79 KiB) Downloaded 1374 times
xorgwizard417-loc.pet
(23.48 KiB) Downloaded 1319 times
[url=http://moulinier.net/][color=blue][b]Toutou Linux[/b][/color][/url] - [url=http://toutoulinux.free.fr/pet.php][color=blue][b]Paquets français[/b][/color][/url]

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

xorgwizard revised

#123 Post by shinobar »

found bug around xvidtune ....fixed.
fix keyboard model for jp106.
with japanese translation.
Attachments
xorgwizard423-loc.pet
xorgwizard I18N
(26.24 KiB) Downloaded 937 times

ljfr
Posts: 176
Joined: Thu 23 Apr 2009, 08:35

Script localization

#124 Post by ljfr »

Hi,

Do you know gettext could be used inside bash script:
http://tldp.org/LDP/abs/html/localization.html
Could this be usefull?

I just tried on simple examples (pure output text and gtkdialog box), and it worked fine.

regards,

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

Re: Script localization

#125 Post by shinobar »

ljfr wrote: Do you know gettext could be used inside bash script:
Maybe Puppy Linux Chinese version does.
http://puppy.cnbits.com/

ljfr
Posts: 176
Joined: Thu 23 Apr 2009, 08:35

localization with gettext

#126 Post by ljfr »

Hi,

Regarding the use of gettext, here is a example on Xorgwizard
-localized in french, if you update your "dialog" utility, everything could work fine, otherwise you may have some issue with UTF-8 french characters.

Process applied to build the localized xorgwizard:
1-Modification of /usr/sbin/xorgwizard:
-at the begining of the script insertion of:

Code: Select all

TEXTDOMAINDIR=/usr/share/locale
TEXTDOMAIN=xorgwizard
export TEXTDOMAINDIR
export TEXTDOMAIN
-then every text to be translated is called with gettext,
as in the example:

Code: Select all

echo "Hello world"
becomes:

Code: Select all

echo "`gettext \"Hello world\"`"
2-extract text abstract to be translated:

Code: Select all

xgettext --language=shell -o - /usr/sbin/xorgwizard > ~/xorgwizard.po
3-translate , for that you can edit the po file with your prefered editor.
But you could use any tool specialized for po catalogs such as poedit which can be compiled with gtkspell -with wxwidgets as dependency. poedit also builds the mo file everytime the po file is saved. ... You get a nice GUI, and translation tools.

4-build the mo file from the po file and put it in your language folder:

Code: Select all

msgfmt -o /usr/share/locale/fr/LC_MESSAGES/xorgwizard.mo ~/xorgwizard.po
You will find the resulting pet package in attachment. the po file in the root folder is useless, it's just here for the example.

Note that french special characters are displayed ok,
some were not (uppercase ones),
and the right edge of the "dialog" frame was distorted as reported by maddox,
but updating dialog solved almost all these problem (thanks MU)
- I took the version inside the slackware 12.2 repository, just a
remaining issue with this one

Code: Select all

È   	È  	È  	È  	Capital E-grave

Afterward, if some modifications are made to the script,
you have to extract the new text field in a new file:
xgettext --language=shell -o - /usr/sbin/xorgwizard > ~/xorgwizard.pot
and merge it with your previous translation:
msgmerge --update ~/xorgwizard.po ~/xorgwizard.pot
and you will keep your previous translation inside the po file, plus the
extra fields and notification on modified ones, then you can start again from translation step 3, above.

This is just an example, they are surely few mistakes in it, and I just tried in french, so probably still few issues unmet and then unsolved.


infomation mostly extracted from:
http://bash-hackers.org/wiki/doku.php/m ... ashfaq/098
http://tldp.org/LDP/abs/html/localization.html
http://www.poedit.net
Attachments
xorgwizard431-loc.pet
(31.12 KiB) Downloaded 898 times

User avatar
esmourguit
Posts: 1410
Joined: Fri 17 Nov 2006, 14:45
Location: Entre l'ile aux oiseaux.et l'ile de sainte Lucie

#127 Post by esmourguit »

Bonjour à tous,
Merci ljfr pour cette bonne nouvelle.
Here is the xorgwizard-loc you've modified with gettext in which i added the pizzasgood's fix.
Cordialement ;)
Attachments
xorgwizard431-loc-bugfixed.pet
(33.39 KiB) Downloaded 910 times
[url=http://moulinier.net/][color=blue][b]Toutou Linux[/b][/color][/url] - [url=http://toutoulinux.free.fr/pet.php][color=blue][b]Paquets français[/b][/color][/url]

ljfr
Posts: 176
Joined: Thu 23 Apr 2009, 08:35

pootle

#128 Post by ljfr »

Hi,

Since puppy scripts could be localized with usual po files (see previous post),
regarding standardized translation tools, Pootle could also be usefull: "Pootle is an online translation management tool with translation interface" quoted from http://en.wikipedia.org/wiki/Pootle
on example of pootle server (wordpress):
http://pootle.locamotion.org/projects/wordpress/

regards,

User avatar
Aitch
Posts: 6518
Joined: Wed 04 Apr 2007, 15:57
Location: Chatham, Kent, UK

#129 Post by Aitch »

ljfr

Pootle looks very useful, thanks

Aitch :)

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

xorgwizard update

#130 Post by shinobar »

DOES NOT WORK! The attachment removed.
attached xorgwizard using gettext updated, merged with 431JP and quirky-002.

#091119 pizzasgood: patch for multiple monitors.
# 28Oct09 - 17nov09 I18N using gettext by ljfr and esmourguit
#091125 if no Xvesa, do not display dlg that offers to choose it.
# 25dec09 use KBDMODEL, xvidtune, tapping enabled for Synaptics Mouse, from v420JP,v431JP
Last edited by shinobar on Sat 26 Dec 2009, 05:07, edited 2 times in total.

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

bug in localized xorgwizard

#131 Post by shinobar »

think all xorgwizard by ljfr, esmourguit and mine do not work.
checking them up.

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

bugfixed localized xorgwizard

#132 Post by shinobar »

shinobar wrote:think all xorgwizard by ljfr, esmourguit and mine do not work.
checking them up.
sorry xorgwizard-091226-1 was missing 'XkbdModel'.
new attached xorgwizard-091226-2 may work.


#091119 pizzasgood: patch for multiple monitors.
# 28Oct09 - 17nov09 I18N using gettext by ljfr and esmourguit
#091125 if no Xvesa, do not display dlg that offers to choose it.
# 25dec09 merge with v420JP,v431JP
# use KBDMODEL, tapping enabled for Synaptics Mouse
# xvidtune message ,Generic_driver dialog label
# 26dec09 bugfix choosexmodedlg using gettext
Attachments
xorgwizard-091226-2.tar.gz
(20.91 KiB) Downloaded 1249 times

Post Reply