Programming => General => Topic started by: Hansvb on July 24, 2021, 08:21:34 pm

Title: [SOLVED] Switch language
Post by: Hansvb on July 24, 2021, 08:21:34 pm
With the help of I try to switch between Dutch and English. This works fine when the program is started but i can't switch between the languages runtime.

Se below, this seem to do nothing? I guess I forget something. So ho to switch to another language runtime?

Code: Pascal  [Select][+][-]
  1. procedure TFrm_main.MenuItemOptionsLanguageENClick(Sender: TObject);
  2. begin
  3.   SetDefaultLang('en');
  4.   MenuItemOptionsLanguageEN.Checked := True;
  5.   MenuItemOptionsLanguageNL.Checked := False;
  6.   //GetLocaleFormatSettings($409, DefaultFormatSettings);
  7. end;
  9. procedure TFrm_main.MenuItemOptionsLanguageNLClick(Sender: TObject);
  10. begin
  11.   SetDefaultLang('nl');
  12.     MenuItemOptionsLanguageEN.Checked := False;
  13.   MenuItemOptionsLanguageNL.Checked := True;
  14.   //GetLocaleFormatSettings($413, DefaultFormatSettings);
  15. end;                
Title: Re: Switch language
Post by: wp on July 24, 2021, 08:31:12 pm
Do you have a translation file of your starting language? Suppose your untranslated application is in English. Copy the .pot file (e.g. "project.pot") to have extension .en.po ("project.en.po"). Then open this file in POEdit, click in every line and press CTRL+B to transfer to non-translated English text to the column with the translated strings.

I guess it should be possible to use the .en.po file without the CTRL+B trick, but I never found out how...
Title: Re: Switch language
Post by: Hansvb on July 24, 2021, 10:02:09 pm
Thanks, I will try again tomorow. I really don't get it. Even when i remove the po files en then compile, the new po files have some old translations in it.
I guess i go wrong with the fact that i have all the text labels in Dutch but my system settings are English.

Title: Re: Switch language
Post by: dbannon on July 25, 2021, 02:17:10 am
or use the free (but not open source ?) poedit application.  Its designed for that purpose and, more or less dominates the market.

A lazarus app accepts the --lang=es  type switch 'out of the box'.  If you are processing commandline switches, don't forget to allow --lang through.

It works well.

Title: Re: Switch language
Post by: Hansvb on July 25, 2021, 08:34:14 am
I just need to read better. I tried again this morning and it worked within 10 minutes.
TinyPortal © 2005-2018