From 5e4331903b14a88285151ba404975527c23e548a Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 13 Apr 2016 20:39:14 +0200 Subject: [PATCH] Language names are displayed with the localized full name now (closes #15) --- MSI/ZRCola/Main/Makefile | 6 ++ ZRCola/MSIBuild/Makefile | 1 + ZRCola/zrcolaapp.cpp | 1 + ZRCola/zrcolafrm.cpp | 18 +++- ZRColaCompile/dbsource.cpp | 8 +- ZRColaCompile/dbsource.h | 1 + ZRColaCompile/locale/sl_SI.po | 22 +++-- ZRColaCompile/main.cpp | 60 +++++++++++- ZRColaCompile/stdafx.h | 2 + lib/libZRCola/include/zrcola/language.h | 2 + output/data/ZRCola.zrcdb | Bin 112652 -> 113408 bytes output/locale/ZRCola-zrcdb.pot | 116 ++++++++++++++++++++++ output/locale/sl_SI/ZRCola-zrcdb.mo | Bin 0 -> 2207 bytes output/locale/sl_SI/ZRCola-zrcdb.po | 123 ++++++++++++++++++++++++ 14 files changed, 343 insertions(+), 17 deletions(-) create mode 100644 output/locale/ZRCola-zrcdb.pot create mode 100644 output/locale/sl_SI/ZRCola-zrcdb.mo create mode 100644 output/locale/sl_SI/ZRCola-zrcdb.po diff --git a/MSI/ZRCola/Main/Makefile b/MSI/ZRCola/Main/Makefile index 3636d71..27345a9 100644 --- a/MSI/ZRCola/Main/Makefile +++ b/MSI/ZRCola/Main/Makefile @@ -64,6 +64,9 @@ comp00_ZRCola_Re.ttf {B6CE8B39-11DC-4B59-B10C-3F0FFE8F81AF} FontsFolder 0 file0 comp00_ZRCola_It.ttf {10613965-2874-470D-9D5A-B7D535AA3317} FontsFolder 0 file00_ZRCola_It.ttf comp00_ZRCola_Bd.ttf {C036BE8D-6D2F-4DBF-99D6-F53702EAEBB6} FontsFolder 0 file00_ZRCola_Bd.ttf comp00_ZRCola_BI.ttf {883DDA9A-DA85-4FC4-95B7-EF0E08766DEF} FontsFolder 0 file00_ZRCola_BI.ttf +!IF "$(LANG)" == "Sl" +compZRCola.zrcdb.mo.sl_SI {6572EAD1-EE48-46A1-A28E-77985B667F67} ZRCOLALOCSLSIDIR $(MSIBUILD_COMPONENT_ATTRIB_FILE) fileZRCola.zrcdb.mo.sl_SI +!ENDIF <Clear(); for (size_t i = 0, n = app->m_lang_db.idxLng.size(); i < n; i++) { const ZRCola::language_db::language &lang = app->m_lang_db.idxLng[i]; - wxString label(wxString::FromAscii(lang.id, strnlen(lang.id, sizeof(lang.id)))); + wxString + label(lang.name, lang.name_len), + label_tran(wxGetTranslation(label)); if (i < wxID_DECOMP_LANGUAGE_END - wxID_DECOMP_LANGUAGE_START + 1) - m_menuDecompLanguage->Insert(i, wxID_DECOMP_LANGUAGE_START + i, label, wxString::Format(_("Select %s language for decomposition"), (const wxStringCharType*)label), wxITEM_RADIO); - m_toolDecompLanguage->Insert(label, i); + m_menuDecompLanguage->Insert(i, wxID_DECOMP_LANGUAGE_START + i, label_tran, wxString::Format(_("Select %s language for decomposition"), (const wxStringCharType*)label_tran), wxITEM_RADIO); + m_toolDecompLanguage->Insert(label_tran, i); if (memcmp(m_lang, lang.id, sizeof(m_lang)) == 0) m_toolDecompLanguage->Select(i); } @@ -310,12 +312,18 @@ bool wxPersistentZRColaFrame::Restore() wxZRColaFrame * const wnd = static_cast(GetWindow()); + ZRColaApp *app = ((ZRColaApp*)wxTheApp); wxString lang; if (RestoreValue(wxT("lang"), &lang) && lang.Length() == 3) { memcpy(wnd->m_lang, (const char*)lang.c_str(), sizeof(wnd->m_lang)); - wnd->m_toolDecompLanguage->SetStringSelection(wxString::FromAscii(wnd->m_lang, sizeof(wnd->m_lang))); + + ZRCola::language_db::language *lang = new ZRCola::language_db::language; + memcpy(lang->id, wnd->m_lang, sizeof(lang->id)); + lang->name_len = 0; + ZRCola::language_db::indexLang::size_type start, end; + wnd->m_toolDecompLanguage->SetSelection(app->m_lang_db.idxLng.find(*lang, start, end) ? start : -1); + delete lang; } else { - ZRColaApp *app = ((ZRColaApp*)wxTheApp); if (!app->m_lang_db.idxLng.empty()) { const ZRCola::language_db::language &lang = app->m_lang_db.idxLng[0]; memcpy(wnd->m_lang, lang.id, sizeof(wnd->m_lang)); diff --git a/ZRColaCompile/dbsource.cpp b/ZRColaCompile/dbsource.cpp index 44c2551..a3aca02 100644 --- a/ZRColaCompile/dbsource.cpp +++ b/ZRColaCompile/dbsource.cpp @@ -410,7 +410,7 @@ bool ZRCola::DBSource::SelectLanguages(ATL::CComPtr &rs) const wxCHECK(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs)), false); // Open it. - if (FAILED(rs->Open(ATL::CComVariant(L"SELECT DISTINCT [entCode] FROM [VRS_Jezik]"), ATL::CComVariant(m_db), adOpenStatic, adLockReadOnly, adCmdText))) { + if (FAILED(rs->Open(ATL::CComVariant(L"SELECT DISTINCT [entCode], [Jezik_En] FROM [VRS_Jezik]"), ATL::CComVariant(m_db), adOpenStatic, adLockReadOnly, adCmdText))) { _ftprintf(stderr, wxT("%s: error ZCC0060: Error loading languages from database. Please make sure the file is ZRCola.zrc compatible.\n"), m_filename.c_str()); LogErrors(); return false; @@ -433,6 +433,12 @@ bool ZRCola::DBSource::GetLanguage(const ATL::CComPtr& rs, ZRCola: wxCHECK(GetLanguage(f, lang.id), false); } + { + ATL::CComPtr f; + wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"Jezik_En"), &f))); + wxCHECK(GetValue(f, lang.name), false); + } + return true; } diff --git a/ZRColaCompile/dbsource.h b/ZRColaCompile/dbsource.h index c468b4c..53ae54f 100644 --- a/ZRColaCompile/dbsource.h +++ b/ZRColaCompile/dbsource.h @@ -71,6 +71,7 @@ namespace ZRCola { class language { public: ZRCola::langid_t id; ///< Language ID + std::wstring name; ///< Language name }; diff --git a/ZRColaCompile/locale/sl_SI.po b/ZRColaCompile/locale/sl_SI.po index 6785737..8745e42 100644 --- a/ZRColaCompile/locale/sl_SI.po +++ b/ZRColaCompile/locale/sl_SI.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: ZRColaCompile\n" -"POT-Creation-Date: 2016-03-14 17:18+0100\n" -"PO-Revision-Date: 2016-03-14 17:18+0100\n" +"POT-Creation-Date: 2016-04-13 18:11+0200\n" +"PO-Revision-Date: 2016-04-13 18:11+0200\n" "Last-Translator: Simon Rozman \n" "Language-Team: Amebis, d. o. o., Kamnik \n" "Language: sl_SI\n" @@ -17,14 +17,18 @@ msgstr "" "X-Poedit-KeywordsList: _\n" "X-Poedit-SearchPath-0: .\n" -#: main.cpp:165 +#: main.cpp:276 msgid "Show this help message" msgstr "Pokaži to sporočilo pomoči" -#: main.cpp:166 -msgid "input file" -msgstr "vhodna datoteka" +#: main.cpp:277 +msgid "" +msgstr "" -#: main.cpp:167 -msgid "output file" -msgstr "izhodna datoteka" +#: main.cpp:278 +msgid "" +msgstr "" + +#: main.cpp:279 +msgid "" +msgstr "" diff --git a/ZRColaCompile/main.cpp b/ZRColaCompile/main.cpp index 232c8a6..3216a4e 100644 --- a/ZRColaCompile/main.cpp +++ b/ZRColaCompile/main.cpp @@ -274,8 +274,9 @@ int _tmain(int argc, _TCHAR *argv[]) static const wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, "h" , "help", _("Show this help message"), wxCMD_LINE_VAL_NONE , wxCMD_LINE_OPTION_HELP }, - { wxCMD_LINE_PARAM , NULL, NULL , _("input file") , wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY }, - { wxCMD_LINE_PARAM , NULL, NULL , _("output file") , wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY }, + { wxCMD_LINE_PARAM , NULL, NULL , _("" ), wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY }, + { wxCMD_LINE_PARAM , NULL, NULL , _("" ), wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY }, + { wxCMD_LINE_PARAM , NULL, NULL , _("" ), wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION }, { wxCMD_LINE_NONE } }; @@ -317,6 +318,10 @@ int _tmain(int argc, _TCHAR *argv[]) bool has_errors = false; + // Set of strings to translate. + bool build_pot = parser.GetParamCount() > 2; + std::set pot; + // Open file ID. std::streamoff dst_start = stdex::idrec::open(dst, ZRCOLA_DB_ID); @@ -460,7 +465,14 @@ int _tmain(int argc, _TCHAR *argv[]) unsigned __int32 idx = db.data.size(); for (std::wstring::size_type i = 0; i < sizeof(ZRCola::langid_t)/sizeof(unsigned __int16); i++) db.data.push_back(((const unsigned __int16*)lang.id)[i]); + std::wstring::size_type n = lang.name.length(); + wxASSERT_MSG(n <= 0xffff, wxT("language name too long")); + db.data.push_back((unsigned __int16)n); + for (std::wstring::size_type i = 0; i < n; i++) + db.data.push_back(lang.name[i]); db.idxLng.push_back(idx); + if (build_pot) + pot.insert(lang.name); } else has_errors = true; @@ -542,6 +554,50 @@ int _tmain(int argc, _TCHAR *argv[]) has_errors = true; } + if (!has_errors && build_pot) { + const wxString& filenamePot = parser.GetParam(2); + std::fstream dst((LPCTSTR)filenamePot, std::ios_base::out | std::ios_base::trunc); + if (dst.good()) { + dst << "msgid \"\"" << std::endl + << "msgstr \"\"" << std::endl + << "\"Project-Id-Version: ZRCola.zrcdb\\n\"" << std::endl + << "\"Language: en\\n\"" << std::endl + << "\"MIME-Version: 1.0\\n\"" << std::endl + << "\"Content-Type: text/plain; charset=UTF-8\\n\"" << std::endl + << "\"Content-Transfer-Encoding: 8bit\\n\"" << std::endl + << "\"X-Generator: ZRColaCompile " << ZRCOLA_VERSION_STR << "\\n\"" << std::endl; + + std::wstring_convert> conv; + for (std::set::const_iterator i = pot.cbegin(); i != pot.cend(); ++i) { + // Convert UTF-16 to UTF-8 and escape. + std::string t(conv.to_bytes(*i)), u; + for (size_t i = 0, n = t.size(); i < n; i++) { + char c = t[i]; + switch (c) { + case '\'': u += "\\\'"; break; + case '\"': u += "\\\""; break; + case '\n': u += "\\\n"; break; + case '\t': u += "\\\t"; break; + default : u += c; + } + } + dst << std::endl + << "msgid \"" << u << "\"" << std::endl + << "msgstr \"\"" << std::endl; + } + + if (dst.fail()) { + _ftprintf(stderr, wxT("%s: error ZCC0013: Writing to POT catalog failed.\n"), (LPCTSTR)filenameOut.c_str()); + has_errors = true; + } + + dst.close(); + } else { + _ftprintf(stderr, wxT("%s: error ZCC0012: Error opening POT catalog.\n"), filenameOut.fn_str()); + has_errors = true; + } + } + if (has_errors) { dst.close(); wxRemoveFile(filenameOut); diff --git a/ZRColaCompile/stdafx.h b/ZRColaCompile/stdafx.h index 42747bc..145b02e 100644 --- a/ZRColaCompile/stdafx.h +++ b/ZRColaCompile/stdafx.h @@ -46,4 +46,6 @@ #include +#include #include +#include diff --git a/lib/libZRCola/include/zrcola/language.h b/lib/libZRCola/include/zrcola/language.h index c0ad9fa..35d6ff2 100644 --- a/lib/libZRCola/include/zrcola/language.h +++ b/lib/libZRCola/include/zrcola/language.h @@ -202,6 +202,8 @@ namespace ZRCola { /// struct language { langid_t id; ///< Language ID + unsigned __int16 name_len; ///< \c name length (in characters) + wchar_t name[]; ///< Language name }; #pragma pack(pop) diff --git a/output/data/ZRCola.zrcdb b/output/data/ZRCola.zrcdb index 473e5ec66f9d2d1e25bf6e74f0224fa1d4f608a9..535c732139e116e9d7c8664ca2365eef4b2e1f63 100644 GIT binary patch delta 1089 zcmZ{jy>Ami6vW38Tu1~62o<6*BBG|Ep#qce6(STv6VaS~8{6{v&e^?lM4AI3I!X#U zBqT%u9YP=^8cO~FYC1{^1eE-C&n8k7Y>j-LeIGOL?LGMsJ@^$x8|y9o`S>t;7d3vq ztWF=0mQ;U^@N))S0GGiH&<6LwCfEWy;4yd#o`cumE%*e!fUn>i_zjLWq*LH5I1es@ zWv~V|K+;g9oQFr?8F&HSfDhm^=$KRsNHIzk%c_*qfTv8I-03(cIZQU?np$i&waR$` zLg&J6|oO5#kBt^^r_5Sy41 z<|^k_qrjW2r#USnq8F1m}>K&qP<+v@yvmq#8)yV6(IYdS-wOFU~verACK! zJ+Qu9lZJ7ajQ82M6LMOd=CIzs&*_&Lmab973-J@I`7|!D0;iGVnC!O3M0w6H%xw+mbBXNEl;y0Fvtw>@ z8#VUdmD}$oJL_-qesO!J;w-{sOzP(`Ntx delta 327 zcmXBMJxjw-7{&1uDM3V}h)59;5s@NAL_|c2h>AEnx+Tr+3%z;q-Xw)A)!nb*;x77; z938~jzxcrKIcGYLKjHIN7~bDqsrB&`zJxg_PH`s9)u)`}0++bP4Q>$|t2p;)H1M$ojZqS1N=zk_ zjbwbOp^G%EoJQ7Y>}rjxOg1V}%T7wA(?qEybBjh7%Q6vwwvK4J=mme2Avd{io;YvQIrjYzhu+{=1XAg#fh$t4fDjxwz=;DVB>2De>^d%tJpRr5nD^ei+4r z9|12qehJ(C`CZ43;|54|e+W_? z=Rve7y@Q8A8WcYpPh!C^pLPnW^;x$jP%r6z>CR|SZW``0P1lrVME}xM7Ovl#iE5jTi}8co#atFX^=WiL;t;0l5sof*SgFD(d@@w<|-DE@Rp5g za`GFldRU#+{f4opMT>$~OD9aa#?()XCN*Xyu^r-S$8z+M%CKf#1hK!^^xqOTl17)=sanM-Ufi@nvr(wN zx#Cx>K(~$dXL&5j3_8CidXl^|)e?_lf5mbgDIObJW_1}F&1z;7hhirpl8QE!rg$hC zGAc&$mBJF&t%SFPzan^8X49$VC~Fp(q2EzQjHvq-&HUo0#yF3$~4 zP%4fVDn`dbqo^}o)EtYA_=T>*sV7*_<~9=X5Io8mImS&J9{=W9f#={Ok>YYAaOsNUpI*jM5SMKnf1%|IK7{p?dw}obFU$ku}LnO zC^w~FPayG@WB|XLEx0XuP~2nYr-T?JZO7lvoj2*yh)$ui|E;AF-Z`4P?hXllYNu)cDC`1Gryhf So@i!5oa8-B@TAve?)EPp%}NFU literal 0 HcmV?d00001 diff --git a/output/locale/sl_SI/ZRCola-zrcdb.po b/output/locale/sl_SI/ZRCola-zrcdb.po new file mode 100644 index 0000000..c47c267 --- /dev/null +++ b/output/locale/sl_SI/ZRCola-zrcdb.po @@ -0,0 +1,123 @@ +msgid "" +msgstr "" +"Project-Id-Version: ZRCola.zrcdb\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: Simon Rozman \n" +"Language-Team: Amebis, d. o. o., Kamnik \n" +"Language: sl_SI\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.7\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" +"X-Poedit-SourceCharset: UTF-8\n" + +msgid "Albanian" +msgstr "albanščina" + +msgid "Belarusian" +msgstr "beloruščina" + +msgid "Bosnian – Cyrillic" +msgstr "bosanščina – cirilica" + +msgid "Bosnian – Latinic" +msgstr "bosanščina – latinica" + +msgid "Croatian" +msgstr "hrvaščina" + +msgid "Czech" +msgstr "češčina" + +msgid "Danish" +msgstr "danščina" + +msgid "English" +msgstr "angleščina" + +msgid "Estonian" +msgstr "estonščina" + +msgid "French" +msgstr "francoščina" + +msgid "Friulian" +msgstr "furlanščina" + +msgid "German" +msgstr "nemščina" + +msgid "Hungarian" +msgstr "madžarščina" + +msgid "Irish Gaelic" +msgstr "irščina" + +msgid "Kashubian" +msgstr "kašubščina" + +msgid "Latin" +msgstr "latinščina" + +msgid "Latvian" +msgstr "letonščina" + +msgid "Lithuanian" +msgstr "litovščina" + +msgid "Macedonian" +msgstr "makedonščina" + +msgid "Maltese" +msgstr "malteščina" + +msgid "Moldavian – Cyrillic" +msgstr "moldavščina – cirilica" + +msgid "Moldavian – Latinic" +msgstr "moldavščina – latinica" + +msgid "Norwegian" +msgstr "norveščina" + +msgid "Polish" +msgstr "poljščina" + +msgid "Portuguese" +msgstr "portugalščina" + +msgid "Romanian" +msgstr "romunščina" + +msgid "Russian" +msgstr "ruščina" + +msgid "Serbian – Cyrillic" +msgstr "srbščina – cirilica" + +msgid "Serbian – Latinic" +msgstr "srbščina – latinica" + +msgid "Slovak" +msgstr "slovaščina" + +msgid "Slovenian" +msgstr "slovenščina" + +msgid "Sorbian" +msgstr "lužiščini" + +msgid "Spanish" +msgstr "španščina" + +msgid "Swedish" +msgstr "švedščina" + +msgid "Turkish" +msgstr "turščina" + +msgid "Ukrainian" +msgstr "ukrajinščina"