mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-01 01:12:05 +01:00
lcl, ide: use code compatible with JSon package from FPC 2.6.2
git-svn-id: trunk@43750 -
This commit is contained in:
parent
512afcce68
commit
3296df64f5
@ -27,10 +27,6 @@ unit IDETranslations;
|
|||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
{$IF FPC_FULLVERSION>20602}
|
|
||||||
{$DEFINE HasRSJ}
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -337,10 +333,8 @@ begin
|
|||||||
FileType:=stLrt
|
FileType:=stLrt
|
||||||
else if CompareFileExt(Filename,'.rst',false)=0 then
|
else if CompareFileExt(Filename,'.rst',false)=0 then
|
||||||
FileType:=stRst
|
FileType:=stRst
|
||||||
{$IFDEF HasRSJ}
|
|
||||||
else if CompareFileExt(Filename,'.rsj',false)=0 then
|
else if CompareFileExt(Filename,'.rsj',false)=0 then
|
||||||
FileType:=stRsj
|
FileType:=stRsj
|
||||||
{$ENDIF}
|
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
SrcBuf:=CodeToolBoss.LoadFile(Filename,true,false);
|
SrcBuf:=CodeToolBoss.LoadFile(Filename,true,false);
|
||||||
|
|||||||
@ -60,27 +60,17 @@ unit Translations;
|
|||||||
{$mode objfpc}{$H+}{$INLINE ON}
|
{$mode objfpc}{$H+}{$INLINE ON}
|
||||||
{$include include/lcl_defines.inc}
|
{$include include/lcl_defines.inc}
|
||||||
|
|
||||||
{$IF FPC_FULLVERSION>20602}
|
|
||||||
{$DEFINE HasRSJ}
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, FileUtil, StringHashList, AvgLvlTree,
|
Classes, SysUtils, LCLProc, FileUtil, StringHashList, AvgLvlTree,
|
||||||
LConvEncoding
|
LConvEncoding, jsonparser, fpjson;
|
||||||
{$IFDEF HasRSJ}
|
|
||||||
,jsonparser, fpjson
|
|
||||||
{$ENDIF}
|
|
||||||
;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TStringsType = (
|
TStringsType = (
|
||||||
stLrt, // Lazarus resource string table
|
stLrt, // Lazarus resource string table
|
||||||
stRst // FPC resource string table
|
stRst, // FPC resource string table (before FPC 2.7.1)
|
||||||
{$IFDEF HasRSJ}
|
stRsj // FPC resource string table in JSON format (since FPC 2.7.1)
|
||||||
,stRsj // resource string table in JSON format
|
|
||||||
{$ENDIF}
|
|
||||||
);
|
);
|
||||||
TTranslateUnitResult = (turOK, turNoLang, turNoFBLang, turEmptyParam);
|
TTranslateUnitResult = (turOK, turNoLang, turNoFBLang, turEmptyParam);
|
||||||
|
|
||||||
@ -349,11 +339,9 @@ begin
|
|||||||
|
|
||||||
if CompareFileExt(Filename,'.lrt')=0 then
|
if CompareFileExt(Filename,'.lrt')=0 then
|
||||||
BasePOFile.UpdateStrings(InputLines, stLrt)
|
BasePOFile.UpdateStrings(InputLines, stLrt)
|
||||||
{$IFDEF HasRSJ}
|
|
||||||
else
|
else
|
||||||
if CompareFileExt(Filename,'.rsj')=0 then
|
if CompareFileExt(Filename,'.rsj')=0 then
|
||||||
BasePOFile.UpdateStrings(InputLines, stRsj)
|
BasePOFile.UpdateStrings(InputLines, stRsj)
|
||||||
{$ENDIF}
|
|
||||||
else
|
else
|
||||||
BasePOFile.UpdateStrings(InputLines, stRst);
|
BasePOFile.UpdateStrings(InputLines, stRst);
|
||||||
|
|
||||||
@ -872,38 +860,37 @@ var
|
|||||||
p := 1;
|
p := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF HasRSJ}
|
|
||||||
procedure UpdateFromRsj;
|
procedure UpdateFromRsj;
|
||||||
var
|
var
|
||||||
Parser: TJSONParser;
|
Parser: TJSONParser;
|
||||||
JsonData, JsonItems: TJSONData;
|
JsonItems: TJSONArray;
|
||||||
JsonItem: TJSONObject;
|
JsonData, JsonItem: TJSONObject;
|
||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
Parser := TJSONParser.Create(InputLines.Text);
|
Parser := TJSONParser.Create(InputLines.Text);
|
||||||
try
|
try
|
||||||
JsonData := Parser.Parse;
|
JsonData := Parser.Parse as TJSONObject;
|
||||||
JsonItems := JsonData.GetPath('strings');
|
try
|
||||||
for I := 0 to JsonItems.Count - 1 do
|
JsonItems := JsonData.Arrays['strings'];
|
||||||
begin
|
for I := 0 to JsonItems.Count - 1 do
|
||||||
JsonItem := JsonItems.Items[I] as TJSONObject;
|
begin
|
||||||
UpdateItem(JsonItem.Get('name'), JsonItem.Get('value'));
|
JsonItem := JsonItems.Items[I] as TJSONObject;
|
||||||
|
UpdateItem(JsonItem.Get('name'), JsonItem.Get('value'));
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
JsonData.Free;
|
||||||
end;
|
end;
|
||||||
JsonData.Free;
|
|
||||||
finally
|
finally
|
||||||
Parser.Free;
|
Parser.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ClearModuleList;
|
ClearModuleList;
|
||||||
UntagAll;
|
UntagAll;
|
||||||
{$IFDEF HasRSJ}
|
|
||||||
if SType = stRsj then
|
if SType = stRsj then
|
||||||
UpdateFromRsj
|
UpdateFromRsj
|
||||||
else
|
else
|
||||||
{$ENDIF}
|
|
||||||
begin
|
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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user