Wikipedia entry for GNU gettext은 로캘이 단지 "lanuage"라는 예제를 보여줍니다. i18n gettext() “hello world” example에는 언어와 국가가 모두 로케일 값이 있지만 "es_MX
"입니다. "es_MX
"예제를 "lanuage"만 사용하도록 수정했지만 예상 스페인어 대신 영어 텍스트를 생성합니다. Controlling your locale with environment variables 따르면로켈 es_MX가 작동하지만 es가 작동하지 않는 이유는 무엇입니까?
cat >hellogt.cxx <<EOF
// hellogt.cxx
#include <libintl.h>
#include <locale.h>
#include <iostream>
int main(){
setlocale(LC_ALL, "");
bindtextdomain("hellogt", ".");
textdomain("hellogt");
std::cout << gettext("hello, world!") << std::endl;
}
EOF
g++ -o hellogt hellogt.cxx
xgettext --package-name hellogt --package-version 1.2 --default-domain hellogt --output hellogt.pot hellogt.cxx
msginit --no-translator --locale es --output-file hellogt_spanish.po --input hellogt.pot
sed --in-place hellogt_spanish.po --expression='/"hello, world!"/,/#:/s/""/"hola mundo"/'
mkdir --parents ./es.utf8/LC_MESSAGES
msgfmt --check --verbose --output-file ./es.utf8/LC_MESSAGES/hellogt.mo hellogt_spanish.po
LANG=es.utf8 ./hellogt
: 정의한 경우
환경 변수 LANGUAGE 만 GNU gettext에 의해 사용되는 는 ... LANGUAGE는 LC_ALL, LC_MESSAGES 및 LANG 우선 걸린다.
LANGUAGE=es.utf8 ./hellogt
영어보다는 예상 스페인어 텍스트를 생산하고 있습니다.
그러나 "LANG = es"가 작동하지 않는 이유에 대해서는 설명하지 않습니다.