CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2001
    Location
    Colombo, Sri Lanka.
    Posts
    45

    Multilanguage support Resources

    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.


  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: Multilanguage support Resources

    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


  3. #3
    Join Date
    Mar 2001
    Posts
    3

    Re: Multilanguage support Resources

    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


  4. #4
    Join Date
    Feb 2000
    Location
    Ireland
    Posts
    808

    Re: Multilanguage support Resources

    Have a look at http://www.mvps.org/vbnet
    search for "Modifying a Message Box with SetWindowsHookEx"



  5. #5
    Join Date
    Jan 2001
    Location
    Colombo, Sri Lanka.
    Posts
    45

    Re: Multilanguage support Resources

    Hi Ninnell,

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

    Chinthaka.


  6. #6
    Join Date
    Mar 2001
    Posts
    3

    Re: Multilanguage support Resources

    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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured