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 Mon 21 Apr 2014, 00:42
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Why use gettext?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 199
Location: Japan

PostPosted: Thu 05 Sep 2013, 23:07    Post subject:  Why use gettext?  

In puppy scripts I often see statements like
Code:
MSG="$(gettext 'Please wait')"

I would be tempted to simply use
Code:
MSG="Please wait"


I'm sure I'm missing something, but what? Gettext seems to be a very powerful tool for multilanguage text processing, but without any further arguments like in most puppy scripts, does it more than a simple string assignment?
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4134

PostPosted: Fri 06 Sep 2013, 03:14    Post subject:  

It is an external program used to get localized translations of a string.
For ex. if LANG=es, it would return "Hola Mundo" (or something like that for "Hello World")

BTW, There is an alternative method for translation in shell scripts:
http://extra-inter.net/puppy/t12s_DOC/t12s.html

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 199
Location: Japan

PostPosted: Mon 09 Sep 2013, 22:53    Post subject:  

Thanks for the feedback and the link. I've now tried a language pack and seen gettext in action. I roughly know what is going on.

Still I'm not sure if I should use it. I try to learn from the hundreds of scripts in Puppy. They all apply a more or less consistent programming style and are a fantastic source to explore the possibilities of bash, so I treat them with respect. But sometimes I dare to make changes, and here comes my concern: When I make changes to an existing script that uses all these gettext functions, what is "best practise"? Should I

a) also use gettext, though I don't provide translations? Would this make life easier for someone to add translations later?

b) use simple string assignments as an honest statement that there are no translations available?

c) search (how?) to see, if my text "Please wait" has been translated? If it has, then use gettext, if it hasn't, use the simple way.

Of course all this is irrelevant if I make changes for my own pleasure, but if I ever publish code in the forum, I want it to conform to whatever standards are established.
Back to top
View user's profile Send private message 
L18L

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

PostPosted: Tue 10 Sep 2013, 07:50    Post subject:  

MochiMoppel wrote:
...When I make changes to an existing script that uses all these gettext functions, what is "best practise"? Should I

a) also use gettext, though I don't provide translations? Would this make life easier for someone to add translations later


Yes of course.
It is the translator who will provide a translation.

Note; a translations is not added to the script but maybe just added to the *-NLS.pet or the language pack..
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
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.0440s ][ Queries: 12 (0.0054s) ][ GZIP on ]