From e4feff51cdfcb0489d24fdd84564c0aaa26f84d9 Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 7 Nov 2011 08:27:34 +0000 Subject: [PATCH] Core: Support for secondary .tr language git-svn-id: svn://ultimatepp.org/upp/trunk@4141 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/App.cpp | 15 ++++++++++----- uppsrc/Core/i18n.h | 2 +- uppsrc/Core/srcdoc.tpp/i18n$en-us.tpp | 9 ++++++++- uppsrc/Core/t.cpp | 4 +++- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/uppsrc/Core/App.cpp b/uppsrc/Core/App.cpp index 74bb697a3..f7c082ef1 100644 --- a/uppsrc/Core/App.cpp +++ b/uppsrc/Core/App.cpp @@ -256,12 +256,11 @@ void CommonInit() { i++; int lang = 0; + int lang2 = 0; byte charset = CHARSET_UTF8; String fn = "all"; if(i < cmd.GetCount()) - if(cmd[i].GetLength() != 4 && cmd[i].GetLength() != 5) - lang = 0; - else { + if(cmd[i].GetLength() == 4 || cmd[i].GetLength() == 5) { lang = LNGFromText(cmd[i].ToString()); fn = cmd[i].ToString(); int c = cmd[i][4]; @@ -271,13 +270,19 @@ void CommonInit() charset = c - 'A' + CHARSET_ISO8859_1; } fn << ".tr"; + if(++i < cmd.GetCount() && (cmd[i].GetLength() == 4 || cmd[i].GetLength() == 5)) + lang2 = LNGFromText(cmd[i].ToString()); #ifdef PLATFORM_WIN32 FileOut out(GetExeDirFile(fn)); #else FileOut out(GetHomeDirFile(fn)); #endif - if(lang) - SaveLngFile(out, SetLNGCharset(lang, charset)); + if(lang) { + if(lang2) + SaveLngFile(out, SetLNGCharset(lang, charset), SetLNGCharset(lang2, charset)); + else + SaveLngFile(out, SetLNGCharset(lang, charset)); + } else { Index l = GetLngSet(); for(int i = 0; i < l.GetCount(); i++) diff --git a/uppsrc/Core/i18n.h b/uppsrc/Core/i18n.h index 30d2a5332..154fa3c66 100644 --- a/uppsrc/Core/i18n.h +++ b/uppsrc/Core/i18n.h @@ -48,7 +48,7 @@ String GetLngString(int lang, const char *id); Index GetLngSet(); Index GetLngSet(const String& module); -void SaveLngFile(FileOut& out, int lang); +void SaveLngFile(FileOut& out, int lang, int lang2 = 0); bool LoadLngFile(const char *file); void SetCurrentLanguage(int lang); diff --git a/uppsrc/Core/srcdoc.tpp/i18n$en-us.tpp b/uppsrc/Core/srcdoc.tpp/i18n$en-us.tpp index 1be920b63..f7e1f79e7 100644 --- a/uppsrc/Core/srcdoc.tpp/i18n$en-us.tpp +++ b/uppsrc/Core/srcdoc.tpp/i18n$en-us.tpp @@ -133,13 +133,20 @@ letter character set encoding according this table:&] [s0; &] [s0; example:&] [s0; &] -[s7; theide `-`-export`-tr dede2&] +[s7; myapp `-`-export`-tr dede2&] [s0; &] [s0; will create dede2.tr file (in exe directory on Win32 and `~/.theide on Posix) ready for translation to deDE in windows`-1252. If translations are already present, they are supplied, otherwise .tr file contains empty strings in place of translations.&] [s0; &] +[s0; It is also possible to output secondary already translated language +to .tr file as comments (e.g. in case that translator cannot +understand english, but can understand some other language):&] +[s0; &] +[s0; &] +[s7; myapp `-`-export`-tr dede2 cscz&] +[s0; &] [s0; Each U`+`+ application performs search for .tr files at startup and uses them to extend internal translation tables.&] [s0; &] diff --git a/uppsrc/Core/t.cpp b/uppsrc/Core/t.cpp index e1eb629f9..601267de3 100644 --- a/uppsrc/Core/t.cpp +++ b/uppsrc/Core/t.cpp @@ -319,7 +319,7 @@ Index GetLngSet(const String& module) return ndx; } -void SaveLngFile(FileOut& out, int lang) +void SaveLngFile(FileOut& out, int lang, int lang2) { CriticalSection::Lock __(slng); out << "LANGUAGE " << AsCString(LNGAsText(lang)) << ";\r\n"; @@ -329,6 +329,8 @@ void SaveLngFile(FileOut& out, int lang) out << "// " << m.name << "\r\n"; for(int j = 0; j < m.map.GetCount(); j++) { String id = m.map.GetKey(j).s; + if (lang2) + out << "// " << AsCString(GetLngString_(lang2, id), 60, "\t", ASCSTRING_SMART) << "\r\n"; out << AsCString(id, 70) << ",\r\n" << "\t" << AsCString(GetLngString_(lang, id), 60, "\t", ASCSTRING_SMART) << ";\r\n\r\n";