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 473e5ec..535c732 100644 Binary files a/output/data/ZRCola.zrcdb and b/output/data/ZRCola.zrcdb differ diff --git a/output/locale/ZRCola-zrcdb.pot b/output/locale/ZRCola-zrcdb.pot new file mode 100644 index 0000000..09d19b9 --- /dev/null +++ b/output/locale/ZRCola-zrcdb.pot @@ -0,0 +1,116 @@ +msgid "" +msgstr "" +"Project-Id-Version: ZRCola.zrcdb\n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: ZRColaCompile 2.0-alpha5\n" + +msgid "Albanian" +msgstr "" + +msgid "Belarusian" +msgstr "" + +msgid "Bosnian – Cyrillic" +msgstr "" + +msgid "Bosnian – Latinic" +msgstr "" + +msgid "Croatian" +msgstr "" + +msgid "Czech" +msgstr "" + +msgid "Danish" +msgstr "" + +msgid "English" +msgstr "" + +msgid "Estonian" +msgstr "" + +msgid "French" +msgstr "" + +msgid "Friulian" +msgstr "" + +msgid "German" +msgstr "" + +msgid "Hungarian" +msgstr "" + +msgid "Irish Gaelic" +msgstr "" + +msgid "Kashubian" +msgstr "" + +msgid "Latin" +msgstr "" + +msgid "Latvian" +msgstr "" + +msgid "Lithuanian" +msgstr "" + +msgid "Macedonian" +msgstr "" + +msgid "Maltese" +msgstr "" + +msgid "Moldavian – Cyrillic" +msgstr "" + +msgid "Moldavian – Latinic" +msgstr "" + +msgid "Norwegian" +msgstr "" + +msgid "Polish" +msgstr "" + +msgid "Portuguese" +msgstr "" + +msgid "Romanian" +msgstr "" + +msgid "Russian" +msgstr "" + +msgid "Serbian – Cyrillic" +msgstr "" + +msgid "Serbian – Latinic" +msgstr "" + +msgid "Slovak" +msgstr "" + +msgid "Slovenian" +msgstr "" + +msgid "Sorbian" +msgstr "" + +msgid "Spanish" +msgstr "" + +msgid "Swedish" +msgstr "" + +msgid "Turkish" +msgstr "" + +msgid "Ukrainian" +msgstr "" diff --git a/output/locale/sl_SI/ZRCola-zrcdb.mo b/output/locale/sl_SI/ZRCola-zrcdb.mo new file mode 100644 index 0000000..d7392cf Binary files /dev/null and b/output/locale/sl_SI/ZRCola-zrcdb.mo differ 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"