summaryrefslogtreecommitdiff
path: root/tools/lpgen
diff options
context:
space:
mode:
authorBasil <basil@miranda-ng.org>2013-03-23 09:04:35 +0000
committerBasil <basil@miranda-ng.org>2013-03-23 09:04:35 +0000
commit2230909271bc66ea6d7efe6adcca7e22f5ef901f (patch)
tree95d2b1af7d9649f17828a85976e2cbf85115aeb3 /tools/lpgen
parent53e1b232e4df5efa4f33f45466fcb37878899d53 (diff)
because translate.js have so many switches, I'm too lazy specify em every time, I have add a new switch /sourcelang:"language". This switch can replace four long switches: /core, /dupes, /path, /langpack.
In other words, /sourcelang:"Russian" are equal to: /path:"..\..\langpacks\Russian\Plugins" /core:"..\..\langpacks\Russian\=CORE=.txt" /dupes:"..\..\langpacks\Russian\=DUPES=.txt" /langpack:"..\..\langpacks\russian\Langpack_Russian.txt" git-svn-id: http://svn.miranda-ng.org/main/trunk@4166 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'tools/lpgen')
-rw-r--r--tools/lpgen/translate.js36
1 files changed, 31 insertions, 5 deletions
diff --git a/tools/lpgen/translate.js b/tools/lpgen/translate.js
index 46175dc62c..c7723aa675 100644
--- a/tools/lpgen/translate.js
+++ b/tools/lpgen/translate.js
@@ -9,6 +9,7 @@
//* Usage: cscript /nologo translate.js /path:"path\plugins" translated plugins folder*//
//* Usage: cscript /nologo translate.js /core:"path\=core=.txt" use core file *//
//* Usage: cscript /nologo translate.js /dupes:"path\=dupes=.txt" use dupes file *//
+//* Usage: cscript /nologo translate.js /sourcelang:"language" instead of /path+/core *//
//* Usage: cscript /nologo translate.js /out:"path\plugins" output result to folder *//
//* Usage: cscript /nologo translate.js /outfile:"path\file" output result to one file*//
//* Usage: cscript /nologo translate.js /langpack:"path\lang.txt" - Full langpack *//
@@ -28,6 +29,9 @@
//* will translate path\file using translation from path\lang.txt *//
//* Example3: cscript /nologo translate.js /langpack:"path\lang.txt" /outfile:"path\file"*//
//* will translate all /english/* templates using lang.txt & output langpack in path\file *//
+//* Example4: cscript /nologo translate.js /sourcelang="Russian" /outfile:"path\file" *//
+//* will translate all /english/* tempaltes using files =CORE=.txt, =DUPES=.txt, lanpack_R*//
+//* ussian.txt from ./langpacks/Russian/ folder, including /langpacks/Russian/Plugins/* *//
//*****************************************************************************************//
//Init Variables
@@ -100,6 +104,17 @@ if (WScript.FullName.toLowerCase().charAt(WScript.FullName.length - 11)=="w") {
WScript.Quit();
}
+//when /sourcelang specified, setup all source files already existed in trunk. Usefull for running translate.js from trunk. Currenly seldom languages have same files structure, thus it is much more easier to just specify a language folder name, instead of specifying /core, /path, /dupes, /langpack.
+if (WScript.Arguments.Named.Item("sourcelang")) {
+ var sourcelang=WScript.Arguments.Named.Item("sourcelang");
+ var langpack_path=FSO.BuildPath(FSO.BuildPath(trunk,"langpacks"),sourcelang);
+ var translated_plugins=FSO.BuildPath(langpack_path,"Plugins");
+ var translated_core=FSO.BuildPath(langpack_path,"=CORE=.txt");
+ var translated_dupes=FSO.BuildPath(langpack_path,"=DUPES=.txt");
+ var translated_langpack=FSO.BuildPath(langpack_path,("langpack_"+sourcelang+".txt"));
+ if (log) WScript.Echo("Translating to "+sourcelang);
+}
+
//when /plugin: specified, parse only this path and quit
if (WScript.Arguments.Named.Item("plugin")) {
//First, generate DB of translations from Core and Dupes files
@@ -206,7 +221,7 @@ function OutputFiles(TranslatedArray,UntranslatedArray,FileName) {
UnTranslatedFile=FSO.BuildPath(FSO.GetParentFolderName(out),"untranslated_"+FileName);
}
//if /untralsated:"path/plugins" specified, redefine to parent folder with name "=CORE=.txt"
- if (UnTranslatedPath!="yes") UnTranslatedFile=FSO.BuildPath(FSO.GetParentFolderName(UnTranslatedPath),FileName);
+ if (untranslated && (UnTranslatedPath!="yes")) UnTranslatedFile=FSO.BuildPath(FSO.GetParentFolderName(UnTranslatedPath),FileName);
}
// output translated file if /out and /outfile ommited, or if /out specified
@@ -228,10 +243,10 @@ function OutputFiles(TranslatedArray,UntranslatedArray,FileName) {
}
-//when /core: and /path: are NOT specified, thus we don't have any langpack file(s) to get translated strings. Thus all other job are uselessg
+//when /core: and /path: are NOT specified, thus we don't have any langpack file(s) to get translated strings. Thus all other job are useless
function checkparams() {
-if (!WScript.Arguments.Named.Item("langpack") && !WScript.Arguments.Named.Item("path")) {
- WScript.Echo("you didn't specify /langpack: or /path: parameter, there is no files with translated strings!");
+if (!WScript.Arguments.Named.Item("langpack") & !WScript.Arguments.Named.Item("path") & !sourcelang) {
+ WScript.Echo("you didn't specify /langpack:\"/path/to/langpack.txt\", /path:\"/path/to/plugnis/\" or /sourcelang:\"language\" parameter, there is no files with translated strings!");
WScript.Quit();
};
}
@@ -245,7 +260,16 @@ function CheckFileExist(file) {
//Generate DB with translations from Core and Dupes files
function GenerateDictionaries () {
-//path variables
+//if /sourcelang:"language" specified, use it for generate dicitionaries
+if (sourcelang) {
+ CheckFileExist(translated_core);
+ CheckFileExist(translated_dupes);
+ CheckFileExist(translated_langpack);
+ GenerateTransalteDict(translated_core,CoreTranslateDict);
+ GenerateTransalteDict(translated_dupes,DupesTranslateDict);
+ GenerateTransalteDict(translated_langpack,LangpackTranslateDict);
+}
+//process a dictionaries creation with switch-specified pathes
if (WScript.Arguments.Named.Item("core")) {
//Check file /core:"path" exist or not
CheckFileExist(WScript.Arguments.Named.Item("core"));
@@ -301,6 +325,8 @@ stream.Close();
function TranslateTemplateFile(Template_file,translated_array,untranslated_array) {
//Init PluginTranslate Dictionary from plugins translate file
var PluginTranslateDict=WScript.CreateObject("Scripting.Dictionary");
+ //if /sourcelang specified, use it for search plugin translation.
+ if (sourcelang) GenerateTransalteDict(FSO.BuildPath(translated_plugins,FSO.GetFileName(Template_file)),PluginTranslateDict);
// if /path:"" specified, this is a folder with plugin translations, use it to find out our translation.
if (WScript.Arguments.Named.Item("path")) {
//Generate PluginTranslate Dictionary