2009-07-05 27 views
6

Complete C++ i18n gettext() “hello world” example kullanımı "es_MX" ifadesinden "" ifadesini ve "merhaba, dünya!" Metnini değiştirdim. "Geçersiz giriş. En az 20 karakter uzunluğunda bir dize girin." Lehçe çeviri msgfmt "łąźó" dan "geçersiz çok bayt sırası" hatalarına neden olan birkaç karakter içeriyor. Çevrilen metin bir web sayfasından kopyalandı.msgfmt Lehçe bir metindeki "geçersiz çok bayt sırası" hatası

Sorun utf8 olduğunu farz ediyorum. Öyleyse, bunun yerine ne kullanılmalı?

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 

cevap

6

Düzenleme plt_polish.po ve Content-Type çizgisini değiştirmek "Content-Type: text/plain; charset = UTF-8 \ n"

+0

Ekle (ASCII UTF-8 charset değiştirme) " msginit'ten hemen önce sed - in-place plt.pot --expression = 's/CHARSET/UTF-8 /' –

+0

Düzenlemeyi, pot dosyası yerine .po dosyasına uygulamanızı öneririm. –

İlgili konular