IDE, Options: Translate "restart hint" to new language

This commit is contained in:
Martin 2024-09-23 14:55:01 +02:00
parent 6d5a09d6a1
commit a8fbf8ab7c
2 changed files with 29 additions and 1 deletions

View File

@ -29,7 +29,7 @@ uses
// LCL
Forms, StdCtrls, Dialogs, Controls, ExtCtrls, Spin,
// LazUtils
FileUtil, LazUTF8, LazLoggerBase,
FileUtil, LazUTF8, LazLoggerBase, Translations,
// LazControls
DividerBevel,
// IdeIntf
@ -354,8 +354,21 @@ begin
end;
procedure TDesktopOptionsFrame.LanguageComboBoxChange(Sender: TObject);
var
po: TPOFile;
s: String;
begin
lblLangChangeHint.Visible := LanguageComboBox.Text <> fCurrentLang;
po := GetLazIdePoFile(EnvironmentOptions.GetParsedLazarusDirectory,
CaptionToLangID(LanguageComboBox.Text));
if po <> nil then begin
s := po.Translate('lazarusidestrconsts.dlgEnvLanguageHint','');
if s <> '' then
lblLangChangeHint.Caption := s
else
lblLangChangeHint.Caption := dlgEnvLanguageHint;
po.Free;
end;
end;
function TDesktopOptionsFrame.LangIDToCaption(const LangID: string): string;

View File

@ -74,6 +74,8 @@ type
// translate all resource strings
procedure TranslateResourceStrings(const LazarusDir, CustomLang: string);
function GetLazIdePoFile(const LazarusDir, CustomLang: string): TPOFile;
// get language name for ID
function GetLazarusLanguageLocalizedName(const ID: string): String;
@ -527,6 +529,19 @@ begin
Dir+'lcl/languages/lclstrconsts'+Ext,Lang,FallbackLang);
end;
function GetLazIdePoFile(const LazarusDir, CustomLang: string): TPOFile;
const
Ext = '.%s.po';
var
AFilename: String;
begin
Result := nil;
AFilename:=Format(AppendPathDelim(LazarusDir)+'languages/lazaruside'+Ext, [CustomLang]);
if FileExistsUTF8(AFilename) then
Result := TPOFile.Create(AFilename);
end;
{ TLazarusTranslations }
function TLazarusTranslations.GetItems(Index: integer): TLazarusTranslation;