Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to localize Delphi resources

Posted on 2011-05-12
13
Medium Priority
?
737 Views
Last Modified: 2012-05-11
I am localising an application to english (comes from french)
I use, here and there, the MessageDlg function with mbYes, mbNo
In my french version, the button captions are Oui and Non
I want them in the english version to be Yes and No
I read I had to "localise" some Delphi resources to do that
How shall I achieve that ?
Thanks
0
Comment
Question by:LeTay
  • 7
  • 4
  • 2
13 Comments
 
LVL 25

Expert Comment

by:epasquier
ID: 35747282
you will need that tool. Not the only one, but a definitive MUST-HAVE
http://www.softpedia.com/progDownload/Windows-Portable-Applications-XNResourceEditor-Portable-Edition-Download-80401.html

Now open your .exe with it, and you will see how those resource are stored in the exe file

Here is a bit of Delphi code that creates the buttons in the MessageDlg functions :

        with LTaskDialog.Buttons.Add do
        begin
          [b]Caption := LoadResString(ButtonCaptions[DlgBtn]);[/b]
          Default := DlgBtn = DefaultButton;
          ModalResult := LModalResults[DlgBtn];
        end;

Open in new window


So now, you should be aware of what mechanism needs to be tweaked, and you have the tools to monitor the resources, play a bit by changing those directly in the executable, and try to find a way to 'industrialize' the whole process of localization.

I think there are some tools to help you do that out there.
12-05-2011-17-04-57.png
0
 
LVL 25

Expert Comment

by:epasquier
ID: 35747362
here are a few localization tools in the market :
http://delphi.about.com/od/toppicks/tp/aatplocalize.htm

this you will want to read also, as it regroup a few critical information toward compilation of different language versions of your applications (by replacing the Delphi own units that contains the constants that are later compiled as resources). That is taking the problem at the root, but the net result of this technique is that you end up recompiling each time for each language, and you'll have one full EXE for each.
http://delphi.about.com/od/objectpascalide/l/aa020502a.htm
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 35752732
Well, epasquier has explained "how to" very well.
Anyway I'd use a more simple way, thus I'd use Messagebox that is already localized by the OS
 
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Expert Comment

by:epasquier
ID: 35752809
Localization of messageboxes is only the tip of the iceberg... But yes that is worth mentioning
0
 

Author Comment

by:LeTay
ID: 35752994
Okay, I will try MessageBox
But I anyway wonder if there is no "simple" way inside the Delphi IDE (without any additional tool) to localise the MessageDlg
0
 
LVL 25

Expert Comment

by:epasquier
ID: 35753208
In fact there is a "translation manager" in Delphi, but I don't know since which version, and not available in all editions.
In XE it is in the menu " View->Translation Manager" (I translated that from french, so it might be a little different)
I haven't tried it, I don't know how it work, I only know that developers that really need localization prefer to rely on third party tools (which are not that expensive considering the hassle it can be to manage resources).
0
 

Author Comment

by:LeTay
ID: 35753261
Well, the only thing for me is MessageDlg, nothing else
I will investigate (running Delphi 2009 french)
0
 

Author Comment

by:LeTay
ID: 35753441
I wonder if the MessageBox displays a modal form
For me it should
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 35753582
Not so difficult usin the appropriate flags

MessageBox(handle, 'Do you like this modal MessageBox?', PChar(Application.Title),
    MB_SYSTEMMODAL or MB_SETFOREGROUND or MB_TOPMOST or MB_ICONQUESTION or MB_YESNO);

where MB_SYSTEMMODAL makes it modal, MB_TOPMOST puts it on topmost and MB_SETFOREGROUND meks it the foreground window

the other flags are those for the icon (dialog type) and the buttons
0
 
LVL 25

Accepted Solution

by:
epasquier earned 2000 total points
ID: 35753589
Of course it does. Here is proof ( DoMessageDlgPosHelp is called with a form created by CreateMessageDialog, all within MessageDlg) :
function DoMessageDlgPosHelp(MessageDialog: TForm; HelpCtx: Longint; X, Y: Integer;
  const HelpFileName: string): Integer;
begin
  with MessageDialog do
    try
      HelpContext := HelpCtx;
      HelpFile := HelpFileName;
      if X >= 0 then Left := X;
      if Y >= 0 then Top := Y;
      if (Y < 0) and (X < 0) then Position := poScreenCenter;
      Result := ShowModal;
    finally
      Free;
    end;
end;

Open in new window

0
 
LVL 25

Expert Comment

by:epasquier
ID: 35753596
Oups, I misread the last question !
0
 
LVL 25

Expert Comment

by:epasquier
ID: 35777630
thanks, but that is a strange choice for correct answer. The first two are way better related to the question
0
 

Author Comment

by:LeTay
ID: 35777673
Sorry espasquier, but I am a bit tired these days ...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi databaseā€¦
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calculā€¦
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question