mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-18 08:49:38 +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.
|
||||
//This allows to avoid even more crashes related
|
||||
//to formatting arguments mismatches.
|
||||
and (pos(sBadFormatFlag, Item.Flags)=0)
|
||||
then begin
|
||||
Result:=Item.Translation;
|
||||
and (pos(sBadFormatFlag, Item.Flags)=0) then
|
||||
begin
|
||||
if Item.Translation<>'' then
|
||||
Result:=Item.Translation
|
||||
else
|
||||
Result:=Item.Original;
|
||||
if Result='' then
|
||||
Raise Exception.Create('TPOFile.Translate Inconsistency');
|
||||
end else
|
||||
|
@ -105,10 +105,11 @@ var
|
||||
begin
|
||||
DefaultLang := LangID;
|
||||
|
||||
AppDir := ExtractFilePath(ParamStrUTF8(0));
|
||||
LCFileName := ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), LCExt);
|
||||
|
||||
if LangID <> '' then
|
||||
begin
|
||||
AppDir := ExtractFilePath(ParamStrUTF8(0));
|
||||
LCFileName := ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), LCExt);
|
||||
FullLCFileName := ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), '.' + LangID) + LCExt;
|
||||
|
||||
if Dir<>'' then
|
||||
@ -243,6 +244,18 @@ var
|
||||
exit;
|
||||
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 := '';
|
||||
DefaultLang := '';
|
||||
end;
|
||||
@ -264,15 +277,6 @@ begin
|
||||
LazGetLanguageIDs(Lang, T);
|
||||
|
||||
Result := GetLocaleFileName(Lang, LCExt, Dir);
|
||||
if Result <> '' then
|
||||
exit;
|
||||
|
||||
Result := ChangeFileExt(ParamStrUTF8(0), LCExt);
|
||||
if FileExistsUTF8(Result) then
|
||||
exit;
|
||||
|
||||
Result := '';
|
||||
DefaultLang := '';
|
||||
end;
|
||||
|
||||
function GetIdentifierPath(Sender: TObject;
|
||||
@ -459,7 +463,7 @@ constructor TPOTranslator.Create(POFileName: string);
|
||||
begin
|
||||
inherited Create;
|
||||
// TPOFile expects AFileName in UTF-8 encoding, no conversion required
|
||||
FPOFile := TPOFile.Create(POFileName);
|
||||
FPOFile := TPOFile.Create(POFileName, true);
|
||||
end;
|
||||
|
||||
constructor TPOTranslator.Create(aPOFile: TPOFile);
|
||||
|
Loading…
Reference in New Issue
Block a user