Internationalization

For efforts in internationalising Puppy and solving problems in this area
Post Reply
Message
Author
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Internationalization

#1 Post by L18L »

gettext in a nut shell:

Code: Select all

# LANGUAGE=en sample_i18n_gettext.sh
#!/bin/sh
cat "$0"
echo "
# gettext in a nut shell"
#
export TEXTDOMAIN=sample_i18n_gettext

echo "
1st simple gettext:"
echo $(gettext 'hello world')

echo "
2nd gettext and variables:"
x="$(gettext 'silly')"
eval echo $(gettext 'hello $x world')

echo "
3rd gettext and another catalog (welcome1stboot):"
echo $(gettext welcome1stboot 'Welcome')

echo "
4th gettext and number:"
for n in 1 2 6; do
 eval echo $(ngettext 'There is just one $x method' 'There are $n $x methods' $n)
done

echo "
that's it.
Without eval_gettext and 
without eval_ngettext and without /usr/bin/gettext.sh
"

# gettext in a nut shell

1st simple gettext:
hello world

2nd gettext and variables:
hello silly world

3rd gettext and another catalog (welcome1stboot):
Welcome

4th gettext and number:
There is just one silly method
There are 2 silly methods
There are 6 silly methods

that's it.
Without eval_gettext and 
without eval_ngettext and without /usr/bin/gettext.sh

# 
# 
# LANGUAGE=de sample_i18n_gettext.sh
#!/bin/sh
cat "$0"
echo "
# gettext in a nut shell"
#
export TEXTDOMAIN=sample_i18n_gettext

echo "
1st simple gettext:"
echo $(gettext 'hello world')

echo "
2nd gettext and variables:"
x="$(gettext 'silly')"
eval echo $(gettext 'hello $x world')

echo "
3rd gettext and another catalog (welcome1stboot):"
echo $(gettext welcome1stboot 'Welcome')

echo "
4th gettext and number:"
for n in 1 2 6; do
 eval echo $(ngettext 'There is just one $x method' 'There are $n $x methods' $n)
done

echo "
that's it.
Without eval_gettext and 
without eval_ngettext and without /usr/bin/gettext.sh
"

# gettext in a nut shell

1st simple gettext:
Hallo Welt

2nd gettext and variables:
Hallo du schnöde Welt

3rd gettext and another catalog (welcome1stboot):
Willkommen

4th gettext and number:
Es gibt nur die eine schnöde Methode.
Es gibt doch 2 schnöde Methoden.
Es gibt doch 6 schnöde Methoden.

that's it.
Without eval_gettext and 
without eval_ngettext and without /usr/bin/gettext.sh

#

this sample_i18n_gettext.sh will be in next MoManager

But you can copy and paste from the above into /root/my-applications/sample_i18n_gettext.sh
and play
and have fun
and write better code :wink:

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#2 Post by don570 »

There is another example of how to gettext a simple script at

http://208.109.22.214/puppy/viewtopic.p ... f714757e5a

_____________________________________________________

Post Reply