Recent

Author Topic: Dutch translated application.messageboxes  (Read 4233 times)

masy

  • New member
  • *
  • Posts: 7
Dutch translated application.messageboxes
« on: January 14, 2022, 04:26:42 am »
Lazarus doesn't include Dutch translated messageboxes. So You get Dutch boxes with buttons like Yes, No, Cancel ipv Ja, Nee, Annuleren...

To eliminate that create a directory named locale and put in these 2 files:
lcldutch.lrs and lclstrconsts.nl.po

In the mainform add the following units to the interface:
LazFileUtils, IniFiles,
LazUtils, LCLType, LCLTranslator, Translations, LazUTF8, DefaultTranslator;

In the mainform.create add the following:
Code: Pascal  [Select][+][-]
  1. const
  2.   NLLang = 'nl';
  3.   FallBackLang = '';
  4.   LCLPOMask = 'lclstrconsts.%s.po';
  5.   LCLStrConsts = 'LCLStrConsts';
  6. var
  7.   PODirectory : string;
  8. begin
  9.  
  10.    // You're own code
  11.   //  ==========
  12.  
  13.    // Vertaal messageboxen (buttons) naar Nederlands
  14.    // ===============================
  15.   appdir:=ExtractFilePath(Application.Location);
  16.   PODirectory := appdir+'locale\';
  17.   TranslateUnitResourceStrings(LCLStrConsts,PODirectory + LCLPOMask, NLLang, FallBackLang);
  18. end;
  19.  
  20. // Testing:
  21. // =====
  22. Button1_click(Sender:TObject);
  23. var
  24.   appini : string;
  25.   BoxStyle,
  26.   Reply  : integer;
  27. begin
  28.      appini:=ExtractFileNameWithoutExt(SaveDialog1.FileName)+'.dat';
  29.      BoxStyle := MB_ICONQUESTION + MB_YESNOCANCEL;
  30.      Reply := Application.MessageBox(pchar(ExtractFileName(appini)+' bestaat al. Doorgaan?'),'Overschrijven',BoxStyle);
  31.       if Reply<> IDYES then
  32.       begin
  33.         exit;
  34.       end;
  35. end;

In the programming phase You need to keep this all the way so!!!
In the installation-phase You don't need this any more.
So You don't need to include the 'locale' directory.

HOWEVER (REMARK ;-)):
Within Internationalitation You've got English/American messageboxes with Dutch buttons, like this:
'Delete this file?','Ja, Nee, Annuleren' ipv Yes, No, Cancel...

The world turned around...

Love Lazarus...

How can I add lcldutch.lrs and lclstrconsts.nl.po to this forum-item?



[Edited to add code tags; please read How to use the Forums.]
« Last Edit: January 14, 2022, 10:51:26 am by masy »

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Dutch translated application.messageboxes
« Reply #1 on: January 15, 2022, 06:45:26 pm »
For those dutch speaking users who want to make their lives even easier: the nlautotranslation unit (which requires the po_nl.lrs resource file) is all you need.
Just include it in the uses clause of your main form and all LCL resource strings should be translated automatically.

You can update the po_nl.lrs resource when needed. You can find the "how to" in the comments of the unit.

This unit uses old style Lazarus resources.
I still need to work out how to redesign it to use new style fpc resources though.

Bart

Sieben

  • Sr. Member
  • ****
  • Posts: 310
Re: Dutch translated application.messageboxes
« Reply #2 on: January 15, 2022, 07:12:48 pm »
Quote from: Bart
I still need to work out how to redesign it to use new style fpc resources though.

Maybe this here might be of any use...?
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Dutch translated application.messageboxes
« Reply #3 on: January 16, 2022, 09:30:16 pm »
Thanks.

Bart

 

TinyPortal © 2005-2018