envsubst, gettext.sh
September 26, 2011 —
BarryK
L18L has very kindly internationalized a script in my shutdownconfig GUI shutdown system, /usr/sbin/shutdownconfig. L18L posted to this Forum thread:
http://murga-linux.com/puppy/viewtopic.php?t=71911
The method that L18L has used requires two other executables from the 'gettext' package, 'envsubst' and 'gettext.sh'. Up until now, Woof-built puppies have those in the 'devx' only.
I have modified the 'gettext' template in Woof so that now those two (as well as the 'gettext' executable) are in the main SFS. This will apply to all puppies built from the next upload of Woof.
Here is a nice tutorial that explains how a Bash/Ash script can be internationalized:
http://www.gnu.org/s/hello/manual/gettext/Preparing-Shell-Scripts.html
Comments
More GUI Frontendspreparing shell scripts
Username: L18L
"I have been using gettext for a while now without knowledge of above link. This is explaining things very well, also the triple backslash sequence. Thanks for the very useful link above.
reinventing the wheel ... again
Username: technosaurus
"I found this method to be much faster [code]{ #localization block [ $myLANG ] || myLANG=${LANGUAGE%% *} [ $myLANG ] || myLANG=${LANG%_*} case $myLANG in de*). /usr/share/locale/de/LC_MESSAGES/jwm;; es*). /usr/share/locale/es/LC_MESSAGES/jwm;; fr*). /usr/share/locale/fr/LC_MESSAGES/jwm;; ru*). /usr/share/locale/ru/LC_MESSAGES/jwm;; esac }[/code] each locale just contains a translated list of variables VAR="translated string" ... we don't need one for english, just this ${VAR:-English translation} it is all plain text and easy for people to contribute translations
Re reinventing wheel
Username: BarryK
"I am going to come back later and take another look at what you suggest. Can't right now, but I like the look of what you have done. I don't like the gettext mechanism, locale handling in general in Linux is very slow. Actually, I probably shouldn't get started on what I think is fundamentally wrong/bad/inefficient with Unix/Linux. The entire file ownership/permissions mechanism for example...
Tags: woof