Tech Support > Microsoft Windows > Development Resources > Multi language support - how to do it best?
Multi language support - how to do it best?
Posted by Gerd on March 22nd, 2007


Hi all,

I have to write an application with MS-Visual Studio (but in plain C,
with Win32-API).

This application must be available for different languages. The
current language should be switchable during runtime.

My idea was, to have an ini-file where I read all texts from, and then
set the texts in the desired language (for menu-entries, dialog-
controls, messageboxes etc) at runtime (startup or when switch was
selected).

Is there a better way to do this language switching?

The required languages are: english (off course), french, greek,
swedish, spanish and german. Would I have to use unicode for this, or
is it possible with normal eight bit characters?

The platform is W2k and WinXP. Maybe Vista will be requested later.

Gerd

Posted by [Jongware] on March 22nd, 2007


"Gerd" <GerdM.O@t-online.de> wrote in message
news:1174574493.119410.281720@y80g2000hsf.googlegr oups.com...
The usual way is to stuff this into String resources. If all text strings in
the different languages are in the same order, you only have to program in
the first string identifier per language as a variable, the rest is "base +
1", "base + 2" etc.

Hmm. *Always* load the required string(s) when doing anything? Maybe not for
the menu's.

Beware: there is no such thing as a 'normal 8 bit set'. It depends on your
current active code page and the charset flag in your font creation.
The default Western set provides for French, Spanish & German -- perhaps
Swedish as well. Your odd man out is Greek; you'll need to switch to a font
with a different code page in 8 bit mode.
Switching to Unicode solves these problems -- apart from one! You'll need to
make sure all fonts you use support all of these languages. A nice solution
is to check the Unicode Set bits at run-time and switch to "a default font"
if you sense Greek isn't supported. Then again, not all fonts tell the truth
in its flags ...

<choke>

[Jongware]



Posted by [Jongware] on March 22nd, 2007


"[Jongware]" <sorry@no_spam.plz> wrote in message
news:4602b3d4$0$334$e4fe514c@news.xs4all.nl...
Wot wuz I thinking?
All resources already *have* a language identifier, so it should be possible to
put everything under the SAME identifier in each copy of a resource, with a
different language/sublanguage code. That way switching languages should be done
at some higher level for all resources at once, and the identifiers in your code
should handle the rest automagically.
Anyone actually used this? I never did, wouldn't know where to start...

[JW]



Posted by Grzegorz Wróbel on March 23rd, 2007


Gerd wrote:
The official way is to create resource-only DLLs independently for each
language (except English - resources for this language can be embedded
in the application). Then in the config menu/file you would define which
language dll to use. This way it is be possible to add support for new
languages later.

If your language-dependent resources are only text strings, then storing
these in your own file format is an option as well. If you make human
readable/editable ini files you leave possibility to add native language
support for your app to the users easily. Many popular software titles
do it this way.

Use UNICODE then. Otherwise it will work only if the default code page
of the OS is set to match your current program settings.


--
Grzegorz Wróbel
http://www.4neurons.com/
677265676F727940346E6575726F6E732E636F6D

Posted by Gerd on March 23rd, 2007


Can you give me a hint, how to create (and how to access) resource-
DLLs?

I like the idea of supporting new language by simply adding a new dll
instead of rebuilding the application.

This was my first thought, but I see a problem when users edit their
own texts (how to handle too long strings).

What would I have to do to create UNICODE resources, and how make my
application UNICODE enabled? I didn't use UNICODE in the past.

Gerd


Grzegorz Wróbel schrieb:


Posted by KIENI on March 23rd, 2007


It is working perfectly this way but I would not recommend it for
projects with lots of resources. It is also a 'little' difficult to
switch the language during runtime.
I recommend resource-only DLLs.

Posted by Grzegorz Wróbel on March 23rd, 2007


Gerd wrote:
Creating resource only dll is simple. You just create a dll project and
add resources to it. (string, images, and anything else that has to be
localized. Accesing is also simple. During your application startup and
during "switch language" routine you load dynamically the specified dll
and load all language specific resources using corresponding load
finction, ie LoadString(), LoadImage(), LoadResource(), etc passing as
first parameter the hIntance of that dll.

either have and enforce a limit for the maximum string lenght or better
use dynamic strings that have no maximum limit thus there is no such
thing as "too long strings".

Use wchar_t instead of char (and WCHAR instead of CHAR) and wide
equivalent of all string manipulation functions ie wcscpy instead of
strcpy and so on. Also define both UNICODE and _UNICODE in your project
so all the APIS that use strings are the "wide" versions.

--
Grzegorz Wróbel
http://www.4neurons.com/
677265676F727940346E6575726F6E732E636F6D

Posted by Gerd on March 27th, 2007


Many thanks for your help.

Gerd


Similar Posts