"i18n Package" - set the language at the start of form

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

"i18n Package" - set the language at the start of form

Postby n1056n » January 31st, 2017, 11:18 am

Colleagues, good afternoon!

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?
n1056n
Member
Member
 
Posts: 3
Joined: January 31st, 2017, 11:08 am

Re: "i18n Package" - set the language at the start of form

Postby n1056n » January 31st, 2017, 1:22 pm

Simplifying question.
How to transfer to Translator1.Localizer.Culture desired value?
What is the syntax?

Thank you.
n1056n
Member
Member
 
Posts: 3
Joined: January 31st, 2017, 11:08 am

Re: "i18n Package" - set the language at the start of form

Postby n1056n » February 1st, 2017, 8:27 am

I found a solution.
Through CultureIndex can select the active language at the start of the form.
The correct structure and syntax as follows:
Code: Select all
Localizer1.CultureIndex := 0;
n1056n
Member
Member
 
Posts: 3
Joined: January 31st, 2017, 11:08 am


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest