Click to See Complete Forum and Search --> : Multilanguage support Resources


ChinthakaR
April 9th, 2001, 06:52 AM
Hi Gurus,
I need to build an application which supports multiple languages(say English/Japanese).So I need to know how to get this type of Resources.

Pls tell me how to do this for The double-byte character set (DBCS).

A sample may be appreciated.

Thanks in advance,

Chinthaka.

cksiow
April 9th, 2001, 07:26 AM
There are not auto-translation. However, you can do this :

in the resource file, you can define all those string that are english using base zero, for instance.

ID - 1, OK
ID - 2, YES

and so on...

You then define the same message and use a offset for it, say 10000

so, in other language

ID 10001 - OK (in other language)
ID 10002 - YES (in other language)

so, then in your program, you need to define an offset variable, say

dim offset as long

so you can let the user to choose the language then. if they choose english, set offset to 0, however, if you choose the other language, set the offset to 10000.

in your program then, whenever you want to display an message

you do this

LoadResString(ID+offset) 'can't really remember the syntax

hope this help.

cksiow
http://vblib.virtualave.net - share our codes

Ninnell
April 9th, 2001, 08:37 AM
Hi!
I had the same pb. Here are some solutions I've found:
* you can use the VB Resources Editor and add a new String Table to your resources file. You can select a different language for each string table, and the system will choose the language to load according to the regional parameters when the user will launch the app.

*You can also create one DLLs by language. Each Dll should have a resource file with the same strings index, and a method to load the string (actually, something like the LoadResString function). In your code, you'll just have to create an object from the class of the appropriate DLL

I've tested both solution and they work pretty well. If you need mmore infos, tell me.

BUT I still have a pb: Does anyone know how to translate the MessageBox Buttons (dialogs created with MsgBox function)
It seems to be linked with the DLLs installed with the VisualBasic and I don't know how to change them.

Thankx,

Ninnell

TH1
April 9th, 2001, 09:33 AM
Have a look at http://www.mvps.org/vbnet
search for "Modifying a Message Box with SetWindowsHookEx"

ChinthakaR
April 10th, 2001, 01:16 AM
Hi Ninnell,

Thanks for your reply. If possible send me any samples you have.

Chinthaka.

Ninnell
April 10th, 2001, 04:17 AM
Hi,

Actually, there is not much code...
If you're interested by the first solution, you have nothing to add to your code. Just create as many string tables as you need.

If you want to create a DLL,
Start a new Dll and ActiveX project.
Add your resource file with the strings translated.
And add this (very) simple function:

Function LoadString(byval index as Integer) as string
LoadString = LoadResString(index)
End Function




Your Dll is over!
Compile it and link it to your main project (add a new reference)

In your main project, you should have a LoadResString function:

Sub LoadResStrings(frm as Form)




Add these lines:

Dim lang as Object
'LangApp is a global variable
'for me: 0 is French and 1 is English
If (LangApp = 0) then
'ClassResFrancais is the name of the class
'I've created in my french Dll
set lang = new ClassResFrancais
else
'ClassResEnglish is the name of the class
'I've created in my english Dll
set lang = new ClassResEnglish
End If




then replace all the calls to LoadResString(index)
by lang.LoadString(index)

I hope it was clear and will help you...

Ninnell