Recent

Author Topic: [Solved] How to localize confirmation delete dialog? (TDBNavigator)  (Read 3950 times)

tsr

  • New Member
  • *
  • Posts: 21
How to localize/translate confirmation delete dialog of DBNavigator? If shows when ConfirmDelete property is set to true and I try to delete a record.
« Last Edit: March 12, 2016, 12:23:08 am by tsr »
Ubuntu 64bit

anis2505

  • Full Member
  • ***
  • Posts: 201
Re: How to localize confirmation delete dialog? (TDBNavigator)
« Reply #1 on: March 08, 2016, 09:55:54 pm »
Hi   :),

First set ConfirmDelete to false

Second on the BeforeAction Event of the DBNavigator

Code: [Select]
if Button = nbDelete then
     begin
          if MessageDlg('Your confirmation message', mtConfirmation, [mbYes,mbNo], 0) = mrNo then
          begin
               Abort;
          end;
     end;
[code]

Hope this helps

regards
Dear Confucius you said {A picture is worth a thousand words}
I say {a good example is worth a thousand words}

tsr

  • New Member
  • *
  • Posts: 21
Re: How to localize confirmation delete dialog? (TDBNavigator)
« Reply #2 on: March 08, 2016, 10:22:19 pm »
Thank you sir!

I confirm that it works. There is small detali that dialog caption is untranslated on my system but I found solution on my way: added ACaption (first parameter).
Code: Pascal  [Select]
  1. MessageDlg('Window caption', 'Your confirmation message', mtConfirmation, [mbYes,mbNo], 0) = mrNo
Ubuntu 64bit

tsr

  • New Member
  • *
  • Posts: 21
Re: How to localize confirmation delete dialog? (TDBNavigator)
« Reply #3 on: March 11, 2016, 04:23:23 pm »
My question comes back.

In the dialog box are buttons "Yes" and "No". How to localize it?
Ubuntu 64bit

Bart

  • Hero Member
  • *****
  • Posts: 3480
    • Bart en Mariska's Webstek
Re: How to localize confirmation delete dialog? (TDBNavigator)
« Reply #4 on: March 11, 2016, 04:35:59 pm »
If you use the lclstrconst.xx.po (where xx is your language) (together with the translations unit) then all this should be localized.

About the original question.
If these strings aren't localized then feel free to supply a patch.

Add the resourcestring to lclstrconsts unit.
Rebuild the .po files.
(There's a tool in ($Lazarus)/tools)
Edit the pofile of your language to get the proper translation of the new resourcestring.

Bart

Windsurfer

  • Sr. Member
  • ****
  • Posts: 362
    • Windsurfer
Re: How to localize confirmation delete dialog? (TDBNavigator)
« Reply #5 on: March 11, 2016, 04:46:05 pm »
There is an example called translation_demo, a wiki page: http://wiki.lazarus.freepascal.org/Getting_translation_strings_right with links at the bottom and a PoChecker package that could be useful be useful.

tsr

  • New Member
  • *
  • Posts: 21
Re: How to localize confirmation delete dialog? (TDBNavigator)
« Reply #6 on: March 11, 2016, 11:04:29 pm »
You have given me very nice clues.

Because LCL strings translation already exists (Polish) I only need to use it.

Good materials on this wiki: http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs

- Added "DefaultTranslator" to program uses.
- Enabled l18n in project options.
- Copied "lclstrconsts.pl.po" file to "MyProjectDir/locale" directory and renamed that file to "MyProjectName.pl.po" then it works.
Anyone knows how to use PO (or MO) file with LCL resourcestrings without renaming it?

@anis2505:
Your solution has en error. Question dialog about deleting appears and if I not select "Yes" but only close the dialog by "x" then deletion succeed. I have corrected it already.
Ubuntu 64bit

wp

  • Hero Member
  • *****
  • Posts: 6149
Re: How to localize confirmation delete dialog? (TDBNavigator)
« Reply #7 on: March 11, 2016, 11:38:56 pm »
- Copied "lclstrconsts.pl.po" file to "MyProjectDir/locale" directory and renamed that file to "MyProjectName.pl.po" then it works.
Anyone knows how to use PO (or MO) file with LCL resourcestrings without renaming it?
Should work without renaming: http://wiki.lazarus.freepascal.org/Step-by-step_instructions_for_creating_multi-language_applications#Strings_defined_by_the_LCL
(Maybe you forgot to add "lclstrconsts" to the uses clause?)
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Bart

  • Hero Member
  • *****
  • Posts: 3480
    • Bart en Mariska's Webstek
Re: How to localize confirmation delete dialog? (TDBNavigator)
« Reply #8 on: March 11, 2016, 11:51:14 pm »
@wp: the actual program does not need to have lclstrstconsts in it's uses clause at all.
Just load the proper lclstrconsts.xx.po and every LCL resource string will be translated (as long as the po file is up-to-date).

Bart

wp

  • Hero Member
  • *****
  • Posts: 6149
Re: How to localize confirmation delete dialog? (TDBNavigator)
« Reply #9 on: March 12, 2016, 12:01:04 am »
Ah sure, stupid! I was testing the tutorial sample with a QuestionDlg and was using one of the strings in that unit.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

tsr

  • New Member
  • *
  • Posts: 21
Re: How to localize confirmation delete dialog? (TDBNavigator)
« Reply #10 on: March 12, 2016, 12:22:43 am »
Thanks.
It works:
Code: Pascal  [Select]
  1. Translations.TranslateUnitResourceStrings('lclstrconsts', 'locale/lclstrconsts.pl.po');
Ubuntu 64bit