Language names are displayed with the localized full name now

(closes #15)
This commit is contained in:
Simon Rozman 2016-04-13 20:39:14 +02:00
parent 55c76265df
commit 5e4331903b
14 changed files with 343 additions and 17 deletions

View File

@ -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_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_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 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
<<NOKEEP <<NOKEEP
@ -236,6 +239,9 @@ file00_ZRCola_Re.ttf comp00_ZRCola_Re.ttf 00_ZRC~1.TTF|00_ZRCola_Re.ttf 0 0 1
file00_ZRCola_It.ttf comp00_ZRCola_It.ttf 00_ZRC~2.TTF|00_ZRCola_It.ttf 0 0 1 file00_ZRCola_It.ttf comp00_ZRCola_It.ttf 00_ZRC~2.TTF|00_ZRCola_It.ttf 0 0 1
file00_ZRCola_Bd.ttf comp00_ZRCola_Bd.ttf 00_ZRC~3.TTF|00_ZRCola_Bd.ttf 0 0 1 file00_ZRCola_Bd.ttf comp00_ZRCola_Bd.ttf 00_ZRC~3.TTF|00_ZRCola_Bd.ttf 0 0 1
file00_ZRCola_BI.ttf comp00_ZRCola_BI.ttf 00_ZRC~4.TTF|00_ZRCola_BI.ttf 0 0 1 file00_ZRCola_BI.ttf comp00_ZRCola_BI.ttf 00_ZRC~4.TTF|00_ZRCola_BI.ttf 0 0 1
!IF "$(LANG)" == "Sl"
fileZRCola.zrcdb.mo.sl_SI compZRCola.zrcdb.mo.sl_SI ZRCOLA~1.MO|ZRCola-zrcdb.mo 0 1060 0 1
!ENDIF
<<NOKEEP <<NOKEEP

View File

@ -129,6 +129,7 @@ featZRCola compZRCola.zrcdb
featZRCola comp00_ZRCola_Re.ttf featZRCola comp00_ZRCola_Re.ttf
!IF "$(LANG)" == "Sl" !IF "$(LANG)" == "Sl"
featZRCola compZRCola.mo.sl_SI featZRCola compZRCola.mo.sl_SI
featZRCola compZRCola.zrcdb.mo.sl_SI
featZRCola compwxExtend.mo.sl_SI featZRCola compwxExtend.mo.sl_SI
featZRCola compwxstd.mo.sl_SI featZRCola compwxstd.mo.sl_SI
!ENDIF !ENDIF

View File

@ -60,6 +60,7 @@ bool ZRColaApp::OnInit()
wxVERIFY(m_locale.Init(language)); wxVERIFY(m_locale.Init(language));
wxVERIFY(m_locale.AddCatalog(wxT("wxExtend"))); wxVERIFY(m_locale.AddCatalog(wxT("wxExtend")));
wxVERIFY(m_locale.AddCatalog(wxT("ZRCola"))); wxVERIFY(m_locale.AddCatalog(wxT("ZRCola")));
wxVERIFY(m_locale.AddCatalog(wxT("ZRCola-zrcdb")));
} }
std::fstream dat((LPCTSTR)GetDatabasePath(), std::ios_base::in | std::ios_base::binary); std::fstream dat((LPCTSTR)GetDatabasePath(), std::ios_base::in | std::ios_base::binary);

View File

@ -63,10 +63,12 @@ wxZRColaFrame::wxZRColaFrame() :
m_toolDecompLanguage->Clear(); m_toolDecompLanguage->Clear();
for (size_t i = 0, n = app->m_lang_db.idxLng.size(); i < n; i++) { 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]; 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) 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_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, i); m_toolDecompLanguage->Insert(label_tran, i);
if (memcmp(m_lang, lang.id, sizeof(m_lang)) == 0) if (memcmp(m_lang, lang.id, sizeof(m_lang)) == 0)
m_toolDecompLanguage->Select(i); m_toolDecompLanguage->Select(i);
} }
@ -310,12 +312,18 @@ bool wxPersistentZRColaFrame::Restore()
wxZRColaFrame * const wnd = static_cast<wxZRColaFrame*>(GetWindow()); wxZRColaFrame * const wnd = static_cast<wxZRColaFrame*>(GetWindow());
ZRColaApp *app = ((ZRColaApp*)wxTheApp);
wxString lang; wxString lang;
if (RestoreValue(wxT("lang"), &lang) && lang.Length() == 3) { if (RestoreValue(wxT("lang"), &lang) && lang.Length() == 3) {
memcpy(wnd->m_lang, (const char*)lang.c_str(), sizeof(wnd->m_lang)); 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 { } else {
ZRColaApp *app = ((ZRColaApp*)wxTheApp);
if (!app->m_lang_db.idxLng.empty()) { if (!app->m_lang_db.idxLng.empty()) {
const ZRCola::language_db::language &lang = app->m_lang_db.idxLng[0]; const ZRCola::language_db::language &lang = app->m_lang_db.idxLng[0];
memcpy(wnd->m_lang, lang.id, sizeof(wnd->m_lang)); memcpy(wnd->m_lang, lang.id, sizeof(wnd->m_lang));

View File

@ -410,7 +410,7 @@ bool ZRCola::DBSource::SelectLanguages(ATL::CComPtr<ADORecordset> &rs) const
wxCHECK(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs)), false); wxCHECK(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs)), false);
// Open it. // 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()); _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(); LogErrors();
return false; return false;
@ -433,6 +433,12 @@ bool ZRCola::DBSource::GetLanguage(const ATL::CComPtr<ADORecordset>& rs, ZRCola:
wxCHECK(GetLanguage(f, lang.id), false); wxCHECK(GetLanguage(f, lang.id), false);
} }
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"Jezik_En"), &f)));
wxCHECK(GetValue(f, lang.name), false);
}
return true; return true;
} }

View File

@ -71,6 +71,7 @@ namespace ZRCola {
class language { class language {
public: public:
ZRCola::langid_t id; ///< Language ID ZRCola::langid_t id; ///< Language ID
std::wstring name; ///< Language name
}; };

View File

@ -1,8 +1,8 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ZRColaCompile\n" "Project-Id-Version: ZRColaCompile\n"
"POT-Creation-Date: 2016-03-14 17:18+0100\n" "POT-Creation-Date: 2016-04-13 18:11+0200\n"
"PO-Revision-Date: 2016-03-14 17:18+0100\n" "PO-Revision-Date: 2016-04-13 18:11+0200\n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n" "Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n" "Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n"
"Language: sl_SI\n" "Language: sl_SI\n"
@ -17,14 +17,18 @@ msgstr ""
"X-Poedit-KeywordsList: _\n" "X-Poedit-KeywordsList: _\n"
"X-Poedit-SearchPath-0: .\n" "X-Poedit-SearchPath-0: .\n"
#: main.cpp:165 #: main.cpp:276
msgid "Show this help message" msgid "Show this help message"
msgstr "Pokaži to sporočilo pomoči" msgstr "Pokaži to sporočilo pomoči"
#: main.cpp:166 #: main.cpp:277
msgid "input file" msgid "<input file>"
msgstr "vhodna datoteka" msgstr "<vhodna datoteka>"
#: main.cpp:167 #: main.cpp:278
msgid "output file" msgid "<output file>"
msgstr "izhodna datoteka" msgstr "<izhodna datoteka>"
#: main.cpp:279
msgid "<output POT catalog>"
msgstr "<izhodni katalog POT>"

View File

@ -274,8 +274,9 @@ int _tmain(int argc, _TCHAR *argv[])
static const wxCmdLineEntryDesc cmdLineDesc[] = static const wxCmdLineEntryDesc cmdLineDesc[] =
{ {
{ wxCMD_LINE_SWITCH, "h" , "help", _("Show this help message"), wxCMD_LINE_VAL_NONE , wxCMD_LINE_OPTION_HELP }, { 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 , _("<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 , _("<output file>" ), wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY },
{ wxCMD_LINE_PARAM , NULL, NULL , _("<output POT catalog>" ), wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION },
{ wxCMD_LINE_NONE } { wxCMD_LINE_NONE }
}; };
@ -317,6 +318,10 @@ int _tmain(int argc, _TCHAR *argv[])
bool has_errors = false; bool has_errors = false;
// Set of strings to translate.
bool build_pot = parser.GetParamCount() > 2;
std::set<std::wstring> pot;
// Open file ID. // Open file ID.
std::streamoff dst_start = stdex::idrec::open<ZRCola::recordid_t, ZRCola::recordsize_t>(dst, ZRCOLA_DB_ID); std::streamoff dst_start = stdex::idrec::open<ZRCola::recordid_t, ZRCola::recordsize_t>(dst, ZRCOLA_DB_ID);
@ -460,7 +465,14 @@ int _tmain(int argc, _TCHAR *argv[])
unsigned __int32 idx = db.data.size(); unsigned __int32 idx = db.data.size();
for (std::wstring::size_type i = 0; i < sizeof(ZRCola::langid_t)/sizeof(unsigned __int16); i++) 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]); 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); db.idxLng.push_back(idx);
if (build_pot)
pot.insert(lang.name);
} else } else
has_errors = true; has_errors = true;
@ -542,6 +554,50 @@ int _tmain(int argc, _TCHAR *argv[])
has_errors = true; 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<std::codecvt_utf8<wchar_t>> conv;
for (std::set<std::wstring>::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) { if (has_errors) {
dst.close(); dst.close();
wxRemoveFile(filenameOut); wxRemoveFile(filenameOut);

View File

@ -46,4 +46,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <codecvt>
#include <fstream> #include <fstream>
#include <set>

View File

@ -202,6 +202,8 @@ namespace ZRCola {
/// ///
struct language { struct language {
langid_t id; ///< Language ID langid_t id; ///< Language ID
unsigned __int16 name_len; ///< \c name length (in characters)
wchar_t name[]; ///< Language name
}; };
#pragma pack(pop) #pragma pack(pop)

Binary file not shown.

View File

@ -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 ""

Binary file not shown.

View File

@ -0,0 +1,123 @@
msgid ""
msgstr ""
"Project-Id-Version: ZRCola.zrcdb\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\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"