Results 1 to 12 of 12

Thread: .res - files / multi-language-support

  1. #1
    Guest

    Question

    Sometimes I wonder if I'm smart enough for that job...

    I added a .res - file (2 string-tables) to my project but I can't figure out how to specify the table to load the string from.

    Does anyone know how to support different languages with vb?

    Regards,
    robert

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    I have seen it done before. The way i saw it done was with a language file. A file with a list all the words and phrases used in your project.

    When your project starts up, you need to load this table into memory. Then all of the label captions, menus etc need to be set when you load a form.

    Code:
      Label1.Caption = phrase(1)
      MenuFile.Caption = phrase(3)
      'etc...
    A lot of work, but damn impressive when it works.
    Iain, thats with an i by the way!

  3. #3
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    I think the best way is to use a database, my database skills are a bit rust encrusted though so I can't really help.

  4. #4
    Guest

    Question

    I still don't understand...

    Which sense does it make to have multiple string-tables in a .res - file if I only can access one?

  5. #5
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Could you explain exactly what you intend on doing?
    Iain, thats with an i by the way!

  6. #6
    Guest
    It's my task to convert a single-language-project into a multi...; my intention was to use a .res-file. Obviously it's no problem to add more than one string-table
    to this resource-file but I can't figure out how to specify the string-table I want to load my strings from (dependent on the language I want to show).

  7. #7
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Talking You don't have to do anything...

    The system will sort all this out for you!!!!

    Just specify what the language of the string table is and that's it.


    Say resource id 101 in the English (United Kingdom) was the string 'Hello!" and in the French (Standard) it was "Bonjour!"

    Code:
    Private Sub Form_Load()
        Dim cap As String
        
        cap = LoadResString(101)
        Form1.Caption = cap
    End Sub
    Change your regional settings to French (Standard) and the correct string is loaded automatically!



    (I can send you an example if you like)!

    [Edited by Judd on 05-03-2000 at 09:34 AM]

  8. #8
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Question Bypass the system....

    I don't know if its possible to bypass the system....

    But if you want to be able to change languages on the fly, I'd sugest something like using one String Table with eg
    ID 1000 - 1999 English Strings
    ID 2000 - 2999 Spanish Strings (or whatever)

    Then you can have a language 'root' ID_ROOT set as a global
    to ID_ENGLISH = 1000, ID_SPANISH = 2000 then

    LoadResString(ID_ROOT + WELCOME_STRING) where WELCOME_STRING is the 'Welcome String' increment value..



    Dan

  9. #9
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Use a comma seperated file, or semi colons if there are commas in any of the word/phrases.
    Code:
    File; French; German; Dutch
    Save; French; German; Dutch
    When your program starts up get the user to choose a language. e.g German.

    Now go though each line of the file and load the 3rd column into an array.

    You could do this by reading in each line then. Using the split command with ";" as the seperator. Then setting the value in the array to the 3rd split string e.g.

    Code:
    Dim myPhrase(iNum) as String  'iNum = The number of phrases to load
    Dim strInput As String
    Dim strSplit() As String
    Dim iLanguage As Integer
    Dim iCount As Long
    
    iLanguage = 2  'German
    iCount = 0
    
    'how ever you read the file
    While Not myFile.EOF
      strInput = myFile.ReadLine
      strSplit = Split (strInput, ";")
      myPhrase(iCount) = strSplit(iLanguage)
      iCount = iCount + 1;
    Wend
    Now when you set a caption for a control you have to know which phrase number to use.
    Code:
      MenuFile.Caption = phrase(1)
      cmdSave.Caption = phrase(2)
    Iain, thats with an i by the way!

  10. #10
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Cool No disrespect Iain17....

    ....but that seems an awfully long winded solution. Isn't that the kind of thing String Tables were designed to avoid??



    Dan

  11. #11
    Guest
    Thanks a lot!

    I did't know that vb detects the system language settings.

  12. #12
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Multi-langage application

    Seeing this thing working with regional settings is great. One more question persists, if the langage on the current computer is english, can the user choose french even if windows is in english. (Without changing the user's settings)

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