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
