mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-28 01:37:20 +01:00
lcl: add support for rsj translation files
git-svn-id: trunk@43744 -
This commit is contained in:
parent
a51ef5c65e
commit
94e8ee0649
@ -64,10 +64,10 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, FileUtil, StringHashList, AvgLvlTree,
|
Classes, SysUtils, LCLProc, FileUtil, StringHashList, AvgLvlTree,
|
||||||
LConvEncoding;
|
LConvEncoding, jsonparser, fpjson;
|
||||||
|
|
||||||
type
|
type
|
||||||
TStringsType = (stLrt, stRst);
|
TStringsType = (stLrt, stRst, stRsj);
|
||||||
TTranslateUnitResult = (turOK, turNoLang, turNoFBLang, turEmptyParam);
|
TTranslateUnitResult = (turOK, turNoLang, turNoFBLang, turEmptyParam);
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -324,8 +324,9 @@ begin
|
|||||||
// Update po file with lrt or/and rst files
|
// Update po file with lrt or/and rst files
|
||||||
for i:=0 to Files.Count-1 do begin
|
for i:=0 to Files.Count-1 do begin
|
||||||
Filename:=Files[i];
|
Filename:=Files[i];
|
||||||
if (CompareFileExt(Filename,'.lrt')=0)
|
if (CompareFileExt(Filename,'.lrt')=0) or
|
||||||
or (CompareFileExt(Filename,'.rst')=0) then
|
(CompareFileExt(Filename,'.rst')=0) or
|
||||||
|
(CompareFileExt(Filename,'.rsj')=0) then
|
||||||
try
|
try
|
||||||
//DebugLn('');
|
//DebugLn('');
|
||||||
//DebugLn(['AddFiles2Po Filename="',Filename,'"']);
|
//DebugLn(['AddFiles2Po Filename="',Filename,'"']);
|
||||||
@ -334,6 +335,9 @@ begin
|
|||||||
|
|
||||||
if CompareFileExt(Filename,'.lrt')=0 then
|
if CompareFileExt(Filename,'.lrt')=0 then
|
||||||
BasePOFile.UpdateStrings(InputLines, stLrt)
|
BasePOFile.UpdateStrings(InputLines, stLrt)
|
||||||
|
else
|
||||||
|
if CompareFileExt(Filename,'.rsj')=0 then
|
||||||
|
BasePOFile.UpdateStrings(InputLines, stRsj)
|
||||||
else
|
else
|
||||||
BasePOFile.UpdateStrings(InputLines, stRst);
|
BasePOFile.UpdateStrings(InputLines, stRst);
|
||||||
|
|
||||||
@ -852,9 +856,33 @@ var
|
|||||||
p := 1;
|
p := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure UpdateFromRsj;
|
||||||
|
var
|
||||||
|
Parser: TJSONParser;
|
||||||
|
JsonData: TJSONData;
|
||||||
|
JsonItem: TJSONObject;
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
Parser := TJSONParser.Create(InputLines.Text);
|
||||||
|
try
|
||||||
|
JsonData := Parser.Parse.GetPath('strings');
|
||||||
|
for I := 0 to JsonData.Count - 1 do
|
||||||
|
begin
|
||||||
|
JsonItem := JsonData.Items[I] as TJSONObject;
|
||||||
|
UpdateItem(JsonItem.Get('name'), JsonItem.Get('value'));
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Parser.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ClearModuleList;
|
ClearModuleList;
|
||||||
UntagAll;
|
UntagAll;
|
||||||
|
if SType = stRsj then
|
||||||
|
UpdateFromRsj
|
||||||
|
else
|
||||||
|
begin
|
||||||
// for each string in lrt/rst list check if it's already in PO
|
// for each string in lrt/rst list check if it's already in PO
|
||||||
// if not add it
|
// if not add it
|
||||||
Value := '';
|
Value := '';
|
||||||
@ -955,6 +983,7 @@ begin
|
|||||||
|
|
||||||
inc(i);
|
inc(i);
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
RemoveUntaggedModules;
|
RemoveUntaggedModules;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user