검색을 통해 이슈를 손쉽게 찾아보세요: #<이슈 ID>
예시: #1832
다음의 검색으로 회원을 쉽게 찾으세요: <사용자 이름>, <명> 와 <성>.
예시: smith를 검색하면, smith 와 adamsmith의 검색결과를 가져옵니다.
Localization is an undocumented Bash feature.
A localized shell script echoes its text output in the language defined as the system's locale. A Linux user in Berlin, Germany, would get script output in German, whereas his cousin in Berlin, Maryland, would get output from the same script in English.
To create a localized script, use the following template to write all messages to the user (error messages, prompts, etc.). #!/bin/bash # localized.sh # Script by Stéphane Chazelas, #+ modified by Bruno Haible, bugfixed by Alfredo Pironti. . gettext.sh E_CDERROR=65 error() { printf "$@" >&2 exit $E_CDERROR } cd $var || error "`eval_gettext \"Can\'t cd to "`" # The triple backslashes (escapes) in front of $var needed #+ "because eval_gettext expects a string #+ where the variable values have not yet been substituted." # -- per Bruno Haible read -p "`gettext \"Enter the value: \"`" var # ... # ------------------------------------------------------------------ # Alfredo Pironti comments: # This script has been modified to not use the $"..." syntax in #+ favor of the "`gettext \"...\"`" syntax. # This is ok, but with the new localized.sh program, the commands #+ "bash -D filename" and "bash --dump-po-string filename" #+ will produce no output #+ (because those command are only searching for the $"..." strings)! # The ONLY way to extract strings from the new file is to use the # 'xgettext' program. However, the xgettext program is buggy. # Note that 'xgettext' has another bug. # # The shell fragment: # gettext -s "I like Bash" # will be correctly extracted, but . . . # xgettext -s "I like Bash" # . . . fails! # 'xgettext' will extract "-s" because #+ the command only extracts the #+ very first argument after the 'gettext' word. # Escape characters: # # To localize a sentence like # echo -e "Hello\tworld!" #+ you must use # echo -e "`gettext \"Hello\\tworld\"`" # The "double escape character" before the `t' is needed because #+ 'gettext' will search for a string like: 'Hello\tworld' # This is because gettext will read one literal `\') #+ and will output a string like "Bonjour\tmonde", #+ so the 'echo' command will display the message correctly. # # You may not use # echo "`gettext -e \"Hello\tworld\"`" #+ due to the xgettext bug explained above. # Let's localize the following shell fragment: # echo "-h display help and exit" # # First, one could do this: # echo "`gettext \"-h display help and exit\"`" # This way 'xgettext' will work ok, #+ but the 'gettext' program will read "-h" as an option! # # One solution could be # echo "`gettext -- \"-h display help and exit\"`" # This way 'gettext' will work, #+ but 'xgettext' will extract "--", as referred to above. # # The workaround you may use to get this string localized is # echo -e "`gettext \" display help and exit\"`" # We have added a \0 (NULL) at the beginning of the sentence. # This way 'gettext' works correctly, as does 'xgettext.' # Moreover, the NULL character won't change the behavior #+ of the 'echo' command. # ------------------------------------------------------------------
bash$ bash -D localized.sh "Can't cd to %s." "Enter the value: "
This lists all the localized text. (The -D option lists double-quoted strings prefixed by a $, without executing the script.)
bash$ bash --dump-po-strings localized.sh #: a:6 msgid "Can't cd to %s." msgstr "" #: a:7 msgid "Enter the value: " msgstr ""
The --dump-po-strings option to Bash resembles the -D option, but uses gettext "po" format.
AquaClusters 안내 프라이버시보호 정책 지원 Version - 19.0.2-4 AquaFold, Inc Copyright © 2007-2017