Recent

Author Topic: [SOLVED] Switch language  (Read 3431 times)

Hansvb

  • Hero Member
  • *****
  • Posts: 602
[SOLVED] Switch language
« on: July 24, 2021, 08:21:34 pm »
With the help of https://wiki.freepascal.org/Step-by-step_instructions_for_creating_multi-language_applications 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;
  8.  
  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;                
« Last Edit: July 25, 2021, 08:34:43 am by Hansvb »

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: Switch language
« Reply #1 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...

Hansvb

  • Hero Member
  • *****
  • Posts: 602
Re: Switch language
« Reply #2 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.


dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Switch language
« Reply #3 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.

https://poedit.net/

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.

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Hansvb

  • Hero Member
  • *****
  • Posts: 602
Re: Switch language
« Reply #4 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