mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 13:29:37 +02:00
LCLTranslator, Translations units: when translating an item, return original value if translation is empty. Idea by Sergey Bulba. Also improved finding master .po file in LCLTranslator. Fixes bug #33095.
git-svn-id: trunk@58976 -
This commit is contained in:
parent
f492b74d0e
commit
db62862efe
@ -1050,9 +1050,12 @@ begin
|
|||||||
//Load translation only if it is not flagged as badformat.
|
//Load translation only if it is not flagged as badformat.
|
||||||
//This allows to avoid even more crashes related
|
//This allows to avoid even more crashes related
|
||||||
//to formatting arguments mismatches.
|
//to formatting arguments mismatches.
|
||||||
and (pos(sBadFormatFlag, Item.Flags)=0)
|
and (pos(sBadFormatFlag, Item.Flags)=0) then
|
||||||
then begin
|
begin
|
||||||
Result:=Item.Translation;
|
if Item.Translation<>'' then
|
||||||
|
Result:=Item.Translation
|
||||||
|
else
|
||||||
|
Result:=Item.Original;
|
||||||
if Result='' then
|
if Result='' then
|
||||||
Raise Exception.Create('TPOFile.Translate Inconsistency');
|
Raise Exception.Create('TPOFile.Translate Inconsistency');
|
||||||
end else
|
end else
|
||||||
|
@ -105,10 +105,11 @@ var
|
|||||||
begin
|
begin
|
||||||
DefaultLang := LangID;
|
DefaultLang := LangID;
|
||||||
|
|
||||||
|
AppDir := ExtractFilePath(ParamStrUTF8(0));
|
||||||
|
LCFileName := ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), LCExt);
|
||||||
|
|
||||||
if LangID <> '' then
|
if LangID <> '' then
|
||||||
begin
|
begin
|
||||||
AppDir := ExtractFilePath(ParamStrUTF8(0));
|
|
||||||
LCFileName := ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), LCExt);
|
|
||||||
FullLCFileName := ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), '.' + LangID) + LCExt;
|
FullLCFileName := ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), '.' + LangID) + LCExt;
|
||||||
|
|
||||||
if Dir<>'' then
|
if Dir<>'' then
|
||||||
@ -243,6 +244,18 @@ var
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Result := AppDir + LCFileName;
|
||||||
|
if FileExistsUTF8(Result) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
Result := AppDir + 'locale' + DirectorySeparator + LCFileName;
|
||||||
|
if FileExistsUTF8(Result) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
Result := AppDir + 'languages' + DirectorySeparator + LCFileName;
|
||||||
|
if FileExistsUTF8(Result) then
|
||||||
|
exit;
|
||||||
|
|
||||||
Result := '';
|
Result := '';
|
||||||
DefaultLang := '';
|
DefaultLang := '';
|
||||||
end;
|
end;
|
||||||
@ -264,15 +277,6 @@ begin
|
|||||||
LazGetLanguageIDs(Lang, T);
|
LazGetLanguageIDs(Lang, T);
|
||||||
|
|
||||||
Result := GetLocaleFileName(Lang, LCExt, Dir);
|
Result := GetLocaleFileName(Lang, LCExt, Dir);
|
||||||
if Result <> '' then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
Result := ChangeFileExt(ParamStrUTF8(0), LCExt);
|
|
||||||
if FileExistsUTF8(Result) then
|
|
||||||
exit;
|
|
||||||
|
|
||||||
Result := '';
|
|
||||||
DefaultLang := '';
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetIdentifierPath(Sender: TObject;
|
function GetIdentifierPath(Sender: TObject;
|
||||||
@ -459,7 +463,7 @@ constructor TPOTranslator.Create(POFileName: string);
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
// TPOFile expects AFileName in UTF-8 encoding, no conversion required
|
// TPOFile expects AFileName in UTF-8 encoding, no conversion required
|
||||||
FPOFile := TPOFile.Create(POFileName);
|
FPOFile := TPOFile.Create(POFileName, true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TPOTranslator.Create(aPOFile: TPOFile);
|
constructor TPOTranslator.Create(aPOFile: TPOFile);
|
||||||
|
Loading…
Reference in New Issue
Block a user