Resolve charset .idtx/.idt confusion
NMake inline files are always created using ACP. The "1252" in the .idtx header has no effect on this. However, we must encode the .idt files using correct charset/codepage regardless the ACP being used on the building machine. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
f68cad560a
commit
4c8ef11e9b
BIN
Core/Makefile
BIN
Core/Makefile
Binary file not shown.
6
IDT.js
6
IDT.js
@ -93,7 +93,7 @@ function IDT(path)
|
|||||||
// Parse meta info
|
// Parse meta info
|
||||||
var line = parseRow(dat.ReadText(adReadLine).split("\t")), i = 0;
|
var line = parseRow(dat.ReadText(adReadLine).split("\t")), i = 0;
|
||||||
this.codepage = parseInt(line[i], 10);
|
this.codepage = parseInt(line[i], 10);
|
||||||
if (isNaN(this.codepage)) this.codepage = 1252; else i++;
|
if (isNaN(this.codepage)) this.codepage = 0; else i++;
|
||||||
this.table = line[i++];
|
this.table = line[i++];
|
||||||
this.key = line.slice(i);
|
this.key = line.slice(i);
|
||||||
for (var i in this.key) {
|
for (var i in this.key) {
|
||||||
@ -315,8 +315,8 @@ IDT.prototype.save = function(path)
|
|||||||
dat.WriteText(buildRow(this.columns).join("\t"), adWriteLine);
|
dat.WriteText(buildRow(this.columns).join("\t"), adWriteLine);
|
||||||
dat.WriteText(buildRow(this.types ).join("\t"), adWriteLine);
|
dat.WriteText(buildRow(this.types ).join("\t"), adWriteLine);
|
||||||
var meta = new Array();
|
var meta = new Array();
|
||||||
if (WScript.Arguments.Named.Exists("CP"))
|
if ("codepage" in this)
|
||||||
meta.push(WScript.Arguments.Named("CP"));
|
meta.push(this.codepage.toString(10));
|
||||||
meta.push(this.table);
|
meta.push(this.table);
|
||||||
for (var key in this.key)
|
for (var key in this.key)
|
||||||
meta.push(this.columns[this.key[key]]);
|
meta.push(this.columns[this.key[key]]);
|
||||||
|
23
MSI.wsf
23
MSI.wsf
@ -568,7 +568,7 @@
|
|||||||
<description>Translate IDT file.</description>
|
<description>Translate IDT file.</description>
|
||||||
<unnamed name="<destination.idt>" helpstring="Translated IDT file" required="true"/>
|
<unnamed name="<destination.idt>" helpstring="Translated IDT file" required="true"/>
|
||||||
<unnamed name="<source.idt>" helpstring="Original IDT file" required="true"/>
|
<unnamed name="<source.idt>" helpstring="Original IDT file" required="true"/>
|
||||||
<unnamed name="<catalogue.po>" helpstring="PO catalog file with translations" required="true"/>
|
<unnamed name="<catalogue.po>" helpstring="PO catalog file with translations" required="false"/>
|
||||||
<named name="CP" helpstring="Output code page" type="string" required="false"/>
|
<named name="CP" helpstring="Output code page" type="string" required="false"/>
|
||||||
</runtime>
|
</runtime>
|
||||||
<reference object="ADODB.Stream"/>
|
<reference object="ADODB.Stream"/>
|
||||||
@ -577,7 +577,7 @@
|
|||||||
<script language="JScript" src="PO.js"/>
|
<script language="JScript" src="PO.js"/>
|
||||||
<script language="JScript" src="String.js"/>
|
<script language="JScript" src="String.js"/>
|
||||||
<script language="JScript"><![CDATA[
|
<script language="JScript"><![CDATA[
|
||||||
if (WScript.Arguments.Unnamed.Length < 3) {
|
if (WScript.Arguments.Unnamed.Length < 2) {
|
||||||
WScript.Arguments.ShowUsage();
|
WScript.Arguments.ShowUsage();
|
||||||
WScript.Quit(1);
|
WScript.Quit(1);
|
||||||
}
|
}
|
||||||
@ -587,16 +587,17 @@
|
|||||||
idt_dst_path = WScript.Arguments.Unnamed(0);
|
idt_dst_path = WScript.Arguments.Unnamed(0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Open and parse source IDT file and PO catalogue.
|
// Open and parse source IDT file.
|
||||||
var
|
var idt_src = new IDT(WScript.Arguments.Unnamed(1));
|
||||||
idt_src = new IDT(WScript.Arguments.Unnamed(1)),
|
|
||||||
po = new POCatalog(WScript.Arguments.Unnamed(2));
|
|
||||||
|
|
||||||
// Translate records.
|
if (WScript.Arguments.Unnamed.Length >= 3) {
|
||||||
for (var key in idt_src.data) {
|
// Translate records.
|
||||||
for (var col in idt_src.types) {
|
var po = new POCatalog(WScript.Arguments.Unnamed(2));
|
||||||
if (idt_src.isLocalizable(col) && idt_src.data[key][col] != "")
|
for (var key in idt_src.data) {
|
||||||
idt_src.data[key][col] = po.translate(idt_src.data[key][col]);
|
for (var col in idt_src.types) {
|
||||||
|
if (idt_src.isLocalizable(col) && idt_src.data[key][col] != "")
|
||||||
|
idt_src.data[key][col] = po.translate(idt_src.data[key][col]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
35
String.js
35
String.js
@ -143,21 +143,26 @@ function Time2Str(date)
|
|||||||
function CodePageToId(codepage)
|
function CodePageToId(codepage)
|
||||||
{
|
{
|
||||||
switch (codepage) {
|
switch (codepage) {
|
||||||
case 932 : return "shift-jis";
|
case 0: {
|
||||||
case 936 : return "gb2312";
|
var wsh = new ActiveXObject("WScript.Shell");
|
||||||
case 949 : return "euc-kr";
|
return CodePageToId(parseInt(wsh.RegRead("HKLM\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage\\ACP"), 10));
|
||||||
case 950 : return "big5";
|
}
|
||||||
case 874 :
|
case 932 : return "shift-jis";
|
||||||
case 1250:
|
case 936 : return "gb2312";
|
||||||
case 1251:
|
case 949 : return "euc-kr";
|
||||||
case 1252:
|
case 950 : return "big5";
|
||||||
case 1253:
|
case 874 :
|
||||||
case 1254:
|
case 1250 :
|
||||||
case 1255:
|
case 1251 :
|
||||||
case 1256:
|
case 1252 :
|
||||||
case 1257:
|
case 1253 :
|
||||||
case 1258: return "windows-" + codepage;
|
case 1254 :
|
||||||
default : throw new Error("Unsupported code page.");
|
case 1255 :
|
||||||
|
case 1256 :
|
||||||
|
case 1257 :
|
||||||
|
case 1258 : return "windows-" + codepage.toString(10);
|
||||||
|
case 65001: return "utf-8";
|
||||||
|
default : throw new Error("Unsupported code page.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
UI/Makefile
BIN
UI/Makefile
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user