mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-29 04:25:52 +02: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
|
||||
Classes, SysUtils, LCLProc, FileUtil, StringHashList, AvgLvlTree,
|
||||
LConvEncoding;
|
||||
LConvEncoding, jsonparser, fpjson;
|
||||
|
||||
type
|
||||
TStringsType = (stLrt, stRst);
|
||||
TStringsType = (stLrt, stRst, stRsj);
|
||||
TTranslateUnitResult = (turOK, turNoLang, turNoFBLang, turEmptyParam);
|
||||
|
||||
type
|
||||
@ -324,8 +324,9 @@ begin
|
||||
// Update po file with lrt or/and rst files
|
||||
for i:=0 to Files.Count-1 do begin
|
||||
Filename:=Files[i];
|
||||
if (CompareFileExt(Filename,'.lrt')=0)
|
||||
or (CompareFileExt(Filename,'.rst')=0) then
|
||||
if (CompareFileExt(Filename,'.lrt')=0) or
|
||||
(CompareFileExt(Filename,'.rst')=0) or
|
||||
(CompareFileExt(Filename,'.rsj')=0) then
|
||||
try
|
||||
//DebugLn('');
|
||||
//DebugLn(['AddFiles2Po Filename="',Filename,'"']);
|
||||
@ -334,6 +335,9 @@ begin
|
||||
|
||||
if CompareFileExt(Filename,'.lrt')=0 then
|
||||
BasePOFile.UpdateStrings(InputLines, stLrt)
|
||||
else
|
||||
if CompareFileExt(Filename,'.rsj')=0 then
|
||||
BasePOFile.UpdateStrings(InputLines, stRsj)
|
||||
else
|
||||
BasePOFile.UpdateStrings(InputLines, stRst);
|
||||
|
||||
@ -852,9 +856,33 @@ var
|
||||
p := 1;
|
||||
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
|
||||
ClearModuleList;
|
||||
UntagAll;
|
||||
if SType = stRsj then
|
||||
UpdateFromRsj
|
||||
else
|
||||
begin
|
||||
// for each string in lrt/rst list check if it's already in PO
|
||||
// if not add it
|
||||
Value := '';
|
||||
@ -955,6 +983,7 @@ begin
|
||||
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
RemoveUntaggedModules;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user