Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 18 Sep 2014, 05:48
All times are UTC - 4
 Forum index » Advanced Topics » Puppy Projects » Localization Project
Internationalization
Moderators: Lobster, MU, raffy
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [2 Posts]  
Author Message
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Tue 25 Feb 2014, 10:13    Post subject:  Internationalization
Subject description: gettext in a nut shell (for coders)
 

gettext in a nut shell:
Code:
# 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
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3287
Location: Ontario

PostPosted: Tue 25 Feb 2014, 20:33    Post subject:  

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

http://208.109.22.214/puppy/viewtopic.php?p=758918&sid=8e64b48a0f9a012b4112c0f714757e5a

_____________________________________________________
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Puppy Projects » Localization Project
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0531s ][ Queries: 12 (0.0074s) ][ GZIP on ]