Language names are displayed with the localized full name now
(closes #15)
This commit is contained in:
@@ -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);
|
||||
|
||||
// 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<ADORecordset>& rs, ZRCola:
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -71,6 +71,7 @@ namespace ZRCola {
|
||||
class language {
|
||||
public:
|
||||
ZRCola::langid_t id; ///< Language ID
|
||||
std::wstring name; ///< Language name
|
||||
};
|
||||
|
||||
|
||||
|
@@ -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 <simon.rozman@amebis.si>\n"
|
||||
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\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 "<input file>"
|
||||
msgstr "<vhodna datoteka>"
|
||||
|
||||
#: main.cpp:167
|
||||
msgid "output file"
|
||||
msgstr "izhodna datoteka"
|
||||
#: main.cpp:278
|
||||
msgid "<output file>"
|
||||
msgstr "<izhodna datoteka>"
|
||||
|
||||
#: main.cpp:279
|
||||
msgid "<output POT catalog>"
|
||||
msgstr "<izhodni katalog POT>"
|
||||
|
@@ -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 , _("<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 POT catalog>" ), 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<std::wstring> pot;
|
||||
|
||||
// Open file 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();
|
||||
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<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) {
|
||||
dst.close();
|
||||
wxRemoveFile(filenameOut);
|
||||
|
@@ -46,4 +46,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <codecvt>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
|
Reference in New Issue
Block a user