Click to See Complete Forum and Search --> : Multi-lingual support in DLLs
JonasP
June 8th, 1999, 10:28 AM
WANTED!
If any of you have any good ideas how to make an application support multiple languages, where e.g. all dialog text is stored in a DLL for each country, and just by switching DLL's, also switching language. We have tries different methods, one is to have different textfiles that you include in different rc-files, but this renders the resource editor unusable. We've also tried having the texts replaced at runtime, where we only insert a keyword in the resource editor. There must be a better way out there!(?) Please contact me a.s.a.p. if you know of a way.
Paul McKenzie
June 8th, 1999, 03:57 PM
Did you try something like:
LoadLibrary("English.dll");
OR
LoadLibrary("German.dll");
OR
LoadLibrary(whatever);
where "whatever" is the name of the DLL with string resources? You could easily place the name of the current language in the registry or an INI file of the application. That way, you know which DLL to load at runtime in your application.
Also, the ID's of all of the resource strings identifies your strings. When you call
LoadString(hInstanceDLL, IDS_HELLO, szBuffer, 100);
IDS_HELLO is defined in English.DLL as "HELLO", Spanish.DLL as "HOLA", etc.
Regards,
Paul McKenzie
JonasP
June 9th, 1999, 04:49 AM
Hi and thanks for you quick answer.
You are right, this is exactly what I need. Now to problem number two. Maby you have any suggestions on this matter as well.
The text of the controls in e.g. dialogs has to be updated. And this is the problem.
I figured on setting the text of e.g. a button to "//IDS_OK" and then read the buttons text, then strip the "//" is found and use the FindResource function to load the string from a string table in e.g. "ENGLISH.DLL". I've loaded the DLL ok, but I can't get the loading of the string to work.
I would appreciate if you could tell me how to do it. A bit of code would be grand! :-)
Thanks in advance.
Best regards
/Jonas
Frederic Naudeau
June 9th, 1999, 11:27 AM
Hi,
You can find what your looking for in the CGTetris sample in codeguru. Look into the samples section and then "The Tetris clone CGTetris".
In this sample they use DLLs which contain a the String resources for each language.
I had the same problem as you, and this program answered all my questions !!
Regards.
Frédéric Naudeau.
JonasP
June 10th, 1999, 01:07 AM
Hi Frédéric!
Thank you so much for your help. I will look into that sample right away.
Best regards
Jonas Pettersson
j.pettersson@consultec.se
JonasP
June 10th, 1999, 01:45 AM
Hi again.
Unfortunatly I still can't make this work. In the example there wasn't any strings loaded from the resource, just some midi and wave resources. So I tried to make a string loader out of it, which might I add.. failed :-(
here is the code that is supposed to load the string from the resource DLL (ENGLISH.DLL):
//------------------------------------------
CString LoadStr(CString sIDS)
//
// Loads a string from the current language support file.
//
{
if (!s_hLangLib)
s_hLangLib = LoadLibrary("ENGLISH.DLL");
ASSERT(s_hLangLib);
HRSRC hResInfo = ::FindResource(s_hLangLib, (LPCTSTR)sIDS, RT_STRING);
// This is where this bugger fail. I get hResInfo == NULL no matter what I do, and
// I've failed to find any sample code that actually loads a string. I've found several
// that loads e.g. midi, avi, toolbars etc. But I can't seem to make it work when
// I 'convert' it into a RT_STRING loader :-|
if (hResInfo == 0)
return "::1";
HGLOBAL hRes = ::LoadResource(s_hLangLib, hResInfo);
if (hRes == 0)
return "::2";
LPVOID pVoid = ::LockResource(hRes);
if (pVoid == 0)
return "::3";
// This will later on return the actual string that
// was loaded from the string table in ENGLISH.DLL
return "OK";
}
Can you see what's wrong here?
Best regards
Jonas Pettersson
j.pettersson@consultec.se
Jan Horstmann
August 19th, 1999, 07:54 AM
If you are using MS Visual C++ - MFC, C++ or C there is a new
tool which may help you:
The RapidTranslation System ! This is a collection of
libraries an tools designed especially for the localization
of Windows based applications.
Version 2.5 supports the following features:
- Switching of languages at application run-time. A comfortable
dialog to do this is added to your application automatically.
- The RapidTranslation Editor enables you (or translators,
or even your customers) to create support for new languages
in the easiest way: You just have to type the translation for
your application's strings in an easy-to-use editor, say "save",
and even without quiting your application you can switch it
to the new language.
- The ability of parsing c-format-strings makes it very easy for
non-programmers to use the Editor: You can edit the text
flowing around the placeholders, no knowledge about format
strings is needed.
- A special-character-dialogue enables the translator to select
special characters by a mouseclick.
- The version-update feature of RapidTranslation Editor assures
you don't have to translate your application's texts a second
time if you launch a new version, only the changed / added
texts (this is determined automatically) have to be translated.
- Adding RapidTranslation to new / existing applications
is one of the easiest things:
Just start the RapidTranslation Assistant. This tool analyses
your project and helps you to do very little code changes.
In most cases you have to add only 3 lines of code, and your
application uses RapidTranslation.
- A free edition of RapidTranslation is available now. It is only
limited in the count of texts that can be translated, but for
smaller projects it is sufficient. The testmode lets test you
whether our program works correct. Every string of your application
starts with a x and ends with a y.
For further information about RapidTranslation, please look at
http://www.rapidsolution.de/weben/down/down2.5.htm
You can get the free edition there.
I hope that solves your problem -
Jan Horstmann
------------------------------------------------
Jan Horstmann, Marketing
RapidSolution Software GmbH, Technologiefabrik, Haid-und-Neu-Str.7, D-76131Karlsruhe
Telefon +49-721-9658-601, Fax +49-721-9658-602
horstmann@rapidsolution.de, www.rapidsolution.de
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.