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 Tue 21 Oct 2014, 16:39
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 Posts_count  
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 425
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: 4353

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: 425
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: 2525
Location: Moved from Hosla to www.eussenheim.de

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:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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