LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-01-2014, 11:07 AM   #1
dcparris
LQ Newbie
 
Registered: Dec 2011
Location: Charlotte, NC
Distribution: Debian, Kbuntu, CentOS
Posts: 13
Blog Entries: 1

Rep: Reputation: 0
Question How to Internationalize a Bash Script


Hi all,

I created a Bash script some time ago, and thought users might find it helpful (or maybe just cool/neat) to be able to run the script in their own language. I created a copy of it using Spanish prompts, and that works well. However, wouldn't it make more sense to create a file (or maybe a set of files) with the respective translations of the commands, options and messages, and let a user choose what language to use at run-time?

Instead of maintaining a script in 10, or even 30 languages, I could maintain it in one, set a default, and let users choose from whatever languages are available (independent of the language environment variables). The various languages could be maintained independently as well. Does anyone have experience with this?
 
Old 12-01-2014, 11:22 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
yes, that is the usual way. You need a table to index all the available messages and open a language-dependent text collection. In your script you only need to print messages by index....
 
Old 12-01-2014, 04:16 PM   #3
dcparris
LQ Newbie
 
Registered: Dec 2011
Location: Charlotte, NC
Distribution: Debian, Kbuntu, CentOS
Posts: 13

Original Poster
Blog Entries: 1

Rep: Reputation: 0
Many thanks. I kept looking, and think I may have found a good tutorial describing the process in some depth:

http://www.linuxjournal.com/content/...e-bash-scripts

This appears to set the language based on the user's locale settings, but I suppose I could offer the user a prompt to change that, if they so desired.
 
  


Reply

Tags
bash, international, languages



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash Script - Reading User Input while Processing output from Command within Bash cleeky Linux - General 5 05-27-2014 02:57 PM
[SOLVED] Converting Script from Linux (GNU) Bash 4 to Solaris Bash 2.05 - Any cheat sheet? oly_r Solaris / OpenSolaris 6 05-03-2013 08:25 AM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 08:56 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM
LXer: How to internationalize your PHP apps LXer Syndicated Linux News 0 01-18-2007 10:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration