There is an application on the basis of localized "i18n Package" package.
It is necessary to specify at the start of the form of the code which language is active. The program will look what language was selected the last time and use it.
The question is how to transfer the package information on the language you want to display.
My researches are as follows:
The language to be loaded at the start of the application (not to be confused with the default language), you can specify the properties of the object Translator1-> Localizer-> Culture, through the object inspector. There listbokse selected language on the full name, such as Russian (Russia).
At the same time the project is saved, this structure appears in the dfm-file:
---
object Localizer1: TLocalizer
URI = 'C: \ Users \ user \ Documents \ Embarcadero \ Studio \ Projects \ test \ test_i18.en-US.i18n'
Left = 384
Top = 144
TragetCulture = 'ru-RU'
end
---
And start the correct language.
Actually I go down this path. Trying to change this parameter from the program. I tried different designs on the similarity of "Translator1.Localizer.Culture: = 'ru-RU';" but I get the error or incompatibility of the types of any of the other. Here is a sample listing of the test:
- Code: Select all
unit test_i18;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, i18nCore, i18nCtrls,
i18nDialogs, i18nLocalizer , test_i18_f2;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Localizer1: TLocalizer;
Translator1: TTranslator;
CultureLabel1: TCultureLabel;
CultureListBox1: TCultureListBox;
CultureCheckListBox1: TCultureCheckListBox;
MessageDialog1: TMessageDialog;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption := Translator1.GetText('Agent 007');
ShowMessage(Translator1.GetText('Agent is End'));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//Form2.Show;
form2.showmodal;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
//System.Globalization.CultureInfo.DefaultThreadCurrentCulture=CultureInfo.InstalledUICulture;
//Translator1.Localizer.Culture :=
//CultureLabel1.ShowHint [1];
CultureListBox1.DisplayName := cnNativeDisplayName;
//CultureListBox1.;
//CultureListBox1 := SetDisplayName
//Translator1.Localizer.Culture := TCultureInfo.Create.Create(409);
//Translator1.Localizer.Culture := 'Russian (Russia)';
//Localizer1 := 'Russian (Russia)';
//TCultureInfo.(0409);
//TCultureInfo(0409, true);
//TCultureInfo. := 'Russian (Russia)';
//Translator1.Localizer.URI := 'C:\Users\user\Documents\Embarcadero\Studio\Projects\test\test_i18.en-US.i18n';
//Translator1.Localizer.Culture.LocalizedDisplayName := 'ru-RU';
//Localizer1.Culture := 'ru-RU';
//CultureLabel1.Localizer.Culture := 'Russian (Russia)';
end;
end.
How to implement this?