summaryrefslogtreecommitdiff
path: root/tools/lpgen/translate.js
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-12-02 12:07:44 +0000
committerRobert Pösel <robyer@seznam.cz>2013-12-02 12:07:44 +0000
commit9ceb8f11ec83d933eb7b0ec3514dffa69eed5928 (patch)
treedb77da35b4b3f771eb61797b4a0eb2c30cbe515c /tools/lpgen/translate.js
parent73f6089553cdf0f52fcc25cebb310edf208a1d0f (diff)
translate.js: If no translation found, try to search for case-insensitive key - this makes decapitalization changes much easier to handle
git-svn-id: http://svn.miranda-ng.org/main/trunk@7037 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'tools/lpgen/translate.js')
-rw-r--r--tools/lpgen/translate.js74
1 files changed, 48 insertions, 26 deletions
diff --git a/tools/lpgen/translate.js b/tools/lpgen/translate.js
index 125a63e357..428ba1883c 100644
--- a/tools/lpgen/translate.js
+++ b/tools/lpgen/translate.js
@@ -372,6 +372,10 @@ while ((string = find.exec(translatefiletext)) != null) {
//add key-item pair into dictionary, if not exists already
if (!dictionary.Exists(key))
dictionary.Add(key,item);
+ // add key-item pair for case-insensitive match (with prefix so it won't interfere with real keys)
+ lowerKey = "__lower__" + key.toLowerCase();
+ if (!dictionary.Exists(lowerKey))
+ dictionary.Add(lowerKey,item);
//use also different variants of Miranda name for translations from old langpacks
key = key.replace("Miranda IM", "Miranda NG");
item = item.replace("Miranda IM", "Miranda NG");
@@ -422,42 +426,60 @@ function TranslateTemplateFile(Template_file,translated_array,untranslated_array
englishstring=line.match(/\[.+\]/);
//If current line is english string covered by [], try to find translation in global db
if (englishstring) {
+ var cycle = -1;
+ var found = false;
+ var search = line;
+
+ while (cycle<1 && !found) {
+ cycle = cycle+1;
+ if (cycle==1) {
+ // second cycle, try to be case-insensitive now
+ search = "__lower__" + line.toLowerCase();
+ }
+
//uncomment next string for more verbose log output
//if (log) WScript.Echo("lookin' for "+englishstring);
//firstly find our string exist in Plugin translate DB dictionary
- if (PluginTranslateDict.Exists(line)) {
+ if (PluginTranslateDict.Exists(search)) {
//yes, we have translation, put translation into array
- translated_array.push(PluginTranslateDict.Item(line));
+ translated_array.push(PluginTranslateDict.Item(search));
//add translation to release array
- release_array.push(PluginTranslateDict.Item(line));
+ release_array.push(PluginTranslateDict.Item(search));
+ found = true;
+ } else {
+ //if we do not found string in plugin translation, check Dupes and if found, put to array
+ if (DupesTranslateDict.Exists(search)) {
+ translated_array.push(DupesTranslateDict.Item(search));
+ release_array.push(DupesTranslateDict.Item(search));
+ found = true;
} else {
- //If we do not foud sting in plugin translation, check Dupes and if found, put to array
- if (DupesTranslateDict.Exists(line)) {
- translated_array.push(DupesTranslateDict.Item(line));
- release_array.push(DupesTranslateDict.Item(line));
- } else {
//not found in dupes? Check CORE
- if (CoreTranslateDict.Exists(line)) {
- translated_array.push(CoreTranslateDict.Item(line));
- release_array.push(CoreTranslateDict.Item(line));
- } else {
- //Sill no luck? Check Langpack...
- if (LangpackTranslateDict.Exists(line)) {
- translated_array.push(LangpackTranslateDict.Item(line));
- release_array.push(LangpackTranslateDict.Item(line));
- } else {
- //no translation found, put empty line
- translated_array.push("");
- //add to untranslated array
- untranslated_array.push(line);
- //remove from release, no translation found.
- release_array.pop();
- }
- }
+ if (CoreTranslateDict.Exists(search)) {
+ translated_array.push(CoreTranslateDict.Item(search));
+ release_array.push(CoreTranslateDict.Item(search));
+ found = true;
+ } else {
+ //still no luck? Check Langpack...
+ if (LangpackTranslateDict.Exists(search)) {
+ translated_array.push(LangpackTranslateDict.Item(search));
+ release_array.push(LangpackTranslateDict.Item(search));
+ found = true;
+ }
}
}
}
- }
+ }
+
+ if (!found) {
+ //no translation found, put empty line
+ translated_array.push("");
+ //add to untranslated array
+ untranslated_array.push(line);
+ //remove from release, no translation found.
+ release_array.pop();
+ }
+ }
+ }
//closing file
stream.Close();
//if we will output one file only, concatenate array