The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
output in different languages bora99 Shell Programming and Scripting 2 01-31-2008 02:47 AM
Operating System and Programming languages jacx2 UNIX for Advanced & Expert Users 2 04-15-2002 08:59 AM
Shell scripting & programming languages aloysius1001 UNIX Desktop for Dummies Questions & Answers 1 02-18-2002 08:04 PM
scripting languages headspin UNIX for Dummies Questions & Answers 3 01-31-2002 01:59 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-02-2008
Registered User
 

Join Date: Dec 2007
Posts: 42
bash and languages

Hi everyone,
First of all, i dont know what id do without this forum its been such a great help so a big thankyou to all,
anyway i have a simple question, if i wrote a scrpt in english would it work on another machine with a different language, or do i have to put something in the script to say its english etc, you get my drift,
I big thankyou in advance for any help, and a big kiss if your a woman/lady
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-05-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,084
What do you mean by "write a script in English"?

The command names like cat df awk etc are never localized, even though some of them coincide with English words (date, join, sort ...)

Output from some commands will be localized, so if you are e.g. parsing the output from ls it might be different from what you expect if the user is in another locale. See man locale for an overview. If this is an issue for your script, export LC_ALL=C should force all commands to use a "traditional" C locale (meaning in practice English minus minus).

If your script prints some messages in English, then of course, unless you take special precautions, your strings will be simply strings and won't change even if you would like them to. If you want to make your script localizable, look at gettext and other internationalization frameworks.
Reply With Quote
  #3 (permalink)  
Old 06-06-2008
Registered User
 

Join Date: Dec 2007
Posts: 42
Quote:
Originally Posted by era View Post
What do you mean by "write a script in English"?

The command names like cat df awk etc are never localized, even though some of them coincide with English words (date, join, sort ...)

Output from some commands will be localized, so if you are e.g. parsing the output from ls it might be different from what you expect if the user is in another locale. See man locale for an overview. If this is an issue for your script, export LC_ALL=C should force all commands to use a "traditional" C locale (meaning in practice English minus minus).

If your script prints some messages in English, then of course, unless you take special precautions, your strings will be simply strings and won't change even if you would like them to. If you want to make your script localizable, look at gettext and other internationalization frameworks.
Hi Era
thankyou for repying, yes what i meant was, i have a bash script written in english
and if someone, eg german etc, wanted to use the script, would it it still work on their machine, ignoring the fact that they couldnt read it.
So if i understand you right adding export LC_ALL=C to a script will allow it to work regardless of locale/language set on the users machine,
Reply With Quote
  #4 (permalink)  
Old 06-06-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,084
That's the idea, yes. Many of the standard Unix tools only have machine-readable output in the first place, so the effects should be minor. Mainly, anything to do with sort order, currency formatting, human-readable number formatting, date and time formats, measurements etc. is sensitive to locale settings, but many scripts don't touch these things much.

Globally clobbering the user's locale is not such a great idea, actually, so it might be better if you use LC_ALL=C only for those commands which actually require it (so grep "$regex" "$file" | LC_ALL=C sort | uniq >file for example). That way, they still see output in their own language if there is an error message from grep, for instance (provided of course that their copy of grep actually has a localized message catalog).

Google a bit for i18n if you need more information about internationalization and localization.

Last edited by era; 06-06-2008 at 12:34 AM. Reason: Maybe don't clobber LC_ALL globally after all
Reply With Quote
  #5 (permalink)  
Old 06-06-2008
Registered User
 

Join Date: Sep 2007
Location: Koblenz, Germany
Posts: 579
Since we lost the war, most of us speak english anyways
Reply With Quote
  #6 (permalink)  
Old 06-06-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,084
Tala för dig själv bara.
Reply With Quote
  #7 (permalink)  
Old 06-06-2008
Registered User
 

Join Date: Sep 2007
Location: Koblenz, Germany
Posts: 579
Hej,
I tried to translate it, but so far I got, it sound not very polite "cause of that, you talk with yourself" or in terms of "you would talk only with yourselves else" ? Help me, my swedish is as good as the translator can help me Was just going to do a little joke/fun; sorry for the hijacking of this thread if you feel disturbed.

EDIT: You can send me a PM if you like to - saw you don't accept any.

Last edited by zaxxon; 06-06-2008 at 01:43 AM.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:07 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0