Resource translator

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Resource translator

Postby Lena » Wed May 06, 2015 11:02 am

Hi.
Please explain to me step by step how I can translate into another language word Confirmation in MessageDlg?
Thanks.
Lena
BCBJ Master
BCBJ Master
 
Posts: 550
Joined: Sun Feb 06, 2011 1:28 pm

Re: Resource translator

Postby HsiaLin » Wed May 06, 2015 4:16 pm

Do you mean make the caption say "Confirmation" in a MessageDlg?
HsiaLin
BCBJ Master
BCBJ Master
 
Posts: 290
Joined: Sun Jul 08, 2007 6:29 pm

Re: Resource translator

Postby Lena » Wed May 06, 2015 9:37 pm

Yes. In MessageDlg translate caption Confirmation. Which sourse file I must change?
Lena
BCBJ Master
BCBJ Master
 
Posts: 550
Joined: Sun Feb 06, 2011 1:28 pm

Re: Resource translator

Postby HsiaLin » Thu May 07, 2015 11:34 am

I think you have to make your own dialog function that calls CreateMessageDialog()

something like this:


Code: Select all
            String MessageStr = L"This is dialogs message string";
            TForm *Dlg = CreateMessageDialog(MessageStr, mtConfirmation, TMsgDlgButtons() << mbOK, mbOK);
            Dlg->Caption = L"This is the Caption";
            Dlg->Position = poMainFormCenter;
            Dlg->PopupParent = /*calling form here*/;
            Dlg->ShowModal();
            delete Dlg;
            Dlg = NULL;
HsiaLin
BCBJ Master
BCBJ Master
 
Posts: 290
Joined: Sun Jul 08, 2007 6:29 pm

Re: Resource translator

Postby rlebeau » Thu May 07, 2015 6:00 pm

MessageDlg() already uses localized strings, where the current language of the calling process is used for the resources. So you just have to localize your app correctly, in particular the resource associated with the Vcl.Constants.SMsgDlgConfirm string.

But if you really want to customize the caption without messing around with resources, one option is to call Vcl.Dialogs.CreateMessageDialog() directly, like HsiaLin suggested. But then you get the old pre-Vista message dialog. MessageDlg() does not use CreateMessageDialog() when running on Vista+ with visual styles enabled, it uses the Win32 API TaskDialogIndirect() function instead.

Another option is to call MessageDlg() with ADlgType=mtCustom, then it will use the Application->Title for the caption (this is what ShowMessage() does), so you can set that to whatever you want. This would also account for all dialog types that MessageDlg() can show.

Another option is to skip MessageDlg() altogether and just call TaskDialog() or TaskDialogIndirect() directly (or create your own custom TForm), then you can specify whatever parameters you want (and you get a lot more flexibility than MessageDlg() offers).
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1498
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: Resource translator

Postby Lena » Thu May 14, 2015 7:49 am

Thanks guys.
I can’t use CreateMessageDialog(). I use uniGUI web components.
MessageDlg(“My custom different text”, mtConfirmation, mbYesNo, &callback function);
I need parameter callback.
I ask on uniGUI forum how translate Confirmation. Answer:
Text are taken from Delphi resources. Same as a VCL app. You need a resource translator to change them to local lang.

How correct localize and how use resource translator?
I have absolutely no attempts to how it's done.
1. Open View->Translator Editor and…?
2...
Lena
BCBJ Master
BCBJ Master
 
Posts: 550
Joined: Sun Feb 06, 2011 1:28 pm

Re: Resource translator

Postby rlebeau » Thu May 14, 2015 12:17 pm

Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1498
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA


Return to Technical

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 20 guests

cron