bash and languages


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash and languages
# 1  
Old 06-02-2008
bash and languages

Hi everyone,
First of all, i dont know what id do without this forum its been such a great helpSmilie 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/ladySmilie
# 2  
Old 06-06-2008
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.
# 3  
Old 06-06-2008
Quote:
Originally Posted by era
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,
# 4  
Old 06-06-2008
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 04:34 AM.. Reason: Maybe don't clobber LC_ALL globally after all
# 5  
Old 06-06-2008
Since we lost the war, most of us speak english anyways SmilieSmilie Smilie
# 6  
Old 06-06-2008
Tala för dig själv bara.
# 7  
Old 06-06-2008
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 Smilie 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 05:43 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Programming

Why is C/C++ considered low-level languages???

Hi friends, I hope everyone is doing well and fine. I have always been hearing that C/C++ are relatively low-level as compared to Java/C# etc. Could you please tell me some low-level qualities of C/C++? And I think disk deframenters are written in C/C++, please correct me if I am wrong. And please... (5 Replies)
Discussion started by: gabam
5 Replies

2. What is on Your Mind?

How can I learn computer programming languages on my own?

I would love the idea to develop games. How can I teach myself computer programming? What programs or software must I use? I have the new iMac? (5 Replies)
Discussion started by: Anna Hussie
5 Replies

3. Web Development

What Web Development languages should i learn?

I am learning Web Development, so far i am learning html,xhtml, css, java script.... What I want to know is what other Web Development languages should i learn? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

4. What is on Your Mind?

Programming languages polyglots: how many languages you know?

Post what languages (including scripting) you know, why and where you think that language is most usable. Also include libraries in which you're really good at (libusb, gtk, qt, etc). assembly? C or C++? perl or python? pascal? bash or csh/tcsh? opengl? gtk or qt? mono? (27 Replies)
Discussion started by: redoubtable
27 Replies

5. Shell Programming and Scripting

output in different languages

hello, i have to change a lot of shell scripts for one reason : the output in a script should be done in different languages. for example: echo "this is a test" and "this is a test" should be printed out in language for an example: german,italian and so. i saw a tool "gettext" ,... (2 Replies)
Discussion started by: bora99
2 Replies

6. UNIX for Dummies Questions & Answers

Programming/Scripting Languages To Learn

Which languages would, in the long run, be best to learn on a UNIX environment for kernel work, every day programs, and overall UNIX programming? I've been learning C for over a year now (which I'm pretty confident with) and decided I want to look into some other languages. I'll mainly be... (1 Reply)
Discussion started by: tjinr
1 Replies

7. UNIX for Dummies Questions & Answers

scripting languages

I am currently working as a configuration manager on a quite a large project. Our development environment is on NT, but from unit testing onwards it will be UNIX. I will need to write scripts to automate the process of migrating code from NT to UNIX, now since I am new to UNIX, I wasn't sure if... (3 Replies)
Discussion started by: headspin
3 Replies
Login or Register to Ask a Question