MSGFMT“무효 다중 반영 시퀀스”오류 폴란드어 텍스트
-
23-08-2019 - |
문제
사용 c ++ i18n getText ()“Hello World”예제 완료 나는 로케일을 "es_MX
" 에게 "pl_PL
"그리고"Hello, World! "에서"Invalid Input. 폴란드어 번역에는 MSGFMT의 "유효하지 않은 멀티 바이트 시퀀스"오류가 "wullick"로 인한 여러 문자가 포함되어 있습니다. 번역 된 텍스트는 웹 페이지에서 복사되었습니다.
UTF8이 문제라고 가정합니다. 그렇다면 대신 무엇을 사용해야합니까?
cat >plt.cxx <<EOF
// plt.cxx
#include <libintl.h>
#include <locale.h>
#include <iostream>
int main (){
setlocale(LC_ALL, "");
bindtextdomain("plt", ".");
textdomain( "plt");
std::cout << gettext("Invalid input. Enter a string at least 20 characters long.") << std::endl;
}
EOF
g++ -o plt plt.cxx
xgettext --package-name plt --package-version 1.2 --default-domain plt --output plt.pot plt.cxx
msginit --no-translator --locale pl_PL --output-file plt_polish.po --input plt.pot
sed --in-place plt_polish.po --expression='/#: /,$ s/""/"Nieprawidłowo wprowadzone dane. Wprowadź ciąg przynajmniej 20 znaków."/'
mkdir --parents ./pl_PL.utf8/LC_MESSAGES
msgfmt --check --verbose --output-file ./pl_PL.utf8/LC_MESSAGES/plt.mo plt_polish.po
LANGUAGE=pl_PL.utf8 ./plt
해결책
편집하다 plt_polish.po
컨텐츠 유형 라인을 "Content-Type : Text/Plain; charset = utf-8 n"으로 변경합니다 (charset을 ASCII에서 UTF-8으로 변경)
제휴하지 않습니다 StackOverflow