It is currently Tue, 30 Nov 2021 17:21:23 GMT



 
Author Message
 How to write a shell script that can be translated to non-English language
Hi all,

Has anyone written shell scripts that can be translated into non-English
languages?  I am only interested in translation for prompts and
messages. Any advice or help would be greatly appreciated.

TIA
Zheng

Sent via Deja.com http://www.**-**.com/
Share what you know. Learn what you don't.



 Sun, 06 Jan 2002 03:00:00 GMT   
 How to write a shell script that can be translated to non-English language
Zheng Huang wrote;
# Hi all,
#
# Has anyone written shell scripts that can be translated into non-English
# languages?  I am only interested in translation for prompts and
# messages. Any advice or help would be greatly appreciated.

Hay Zheng,

Use external files which contains the messages, prompts, etc. I wrote a
small example script for you. It uses a file where the messages are
stored by number. A record look like this :  number=text
At the beginning of the script, all messages are read into a one-
dimentional array and the index-numbers are stored in contants.
Change the line MsgFile="English.dat" when you want to use other files
with messages in other languages.

Below are the two necessary files, 1st the script and the 2nd is the
English.dat file.

Good luck,
Real

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

#
# The script
#

#!/usr/bin/ksh

# Message contants
msg_info="1"
msg_prompt="2"
msg_success="3"
msg_failure="4"
msh_end="5"

# The message file
MsgFile="English.dat"

# Use grep to ignore comment- and empty lines
grep -Ev '^#|^[ ]*$' ${MsgFile} | while read MsgLine
do
   Messages[${MsgLine%%=*}]="${MsgLine##*=}"
done

# The part of the script which actually uses the messages
echo "${Messages[${msg_info}]}"
printf "${Messages[${msg_prompt}]}" ; read Value
case "${Value}" in
   y|Y) echo "${Messages[${msg_success}]}" ;;
     *) echo "${Messages[${msg_failure}]}" ;;
esac

echo "${Messages[${msg_end}]}"

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

#
# English.dat
#

1=This is a script with multi-language support
2=Don't you think it's a nice script (Y/N) ? :
3=I thought so !
4=That's to bad !
5=This is the end of the script - bye.



 Mon, 07 Jan 2002 03:00:00 GMT   
 
   [ 2 post ] 

Similar Threads

1. -- Translating non-English e-mail addresses to English --

2. non-english languages with samba

3. non-English language installation problem

4. 23000 files devoted to non-English languages

5. . "sed script" URLs, language not english

6. can you translate shell script into perl script?

7. lcase - Shell script to translate filenames to lower case

8. Translating Bourne shell scripts to C

9. translating shell scripts

10. term: translate the HOWTO from swahili into english.


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software