MultiLingual Application (English/Espanol)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • smjmitchell

    MultiLingual Application (English/Espanol)

    Hi,

    I am writing an application in VB6.0 that will have the option to
    select the language. For instance when Spanish is selected all the
    text on the program interface will display in Spanish.

    This is easy to do for the majority of the text on a form. I just put
    the following code in Form_Load:

    If language = “English” then
    CmdOK.Caption = “OK”
    etc
    Elseif language = “Spanish” then
    CmdOK.Caption = “Aceptar”
    etc
    End if

    However I have a problem with the main drop down menu (i.e.
    File/Edit/View etc). I did something similar to the above to change
    the text however there are two other problems that I cannot see any
    solution to:

    1. I want underscores under letters in the various options so I can
    activate the option with Alt+Letter. This is normally done in the menu
    editor by placing a & in front of the letter. This does not seem to
    work when I change the caption at run time. The & seems to be ignored.
    2. For a given option in the menu the standard shortcut for English
    and Spanish are different. For example Open (Ctrl+O) in English and
    Abrir (Ctrl+A) in Spanish. How can I change the shortcut at run time ?

    I not the first person to write a multilingual program … how is
    this normally done – am I going about this in the right way ?

    Thanks,

    Stephen
  • J French

    #2
    Re: MultiLingual Application (English/Espanol)

    Inline :-

    On 21 Oct 2003 14:32:03 -0700, smjmitchell@yah oo.com (smjmitchell)
    wrote:
    [color=blue]
    >Hi,
    >
    >I am writing an application in VB6.0 that will have the option to
    >select the language. For instance when Spanish is selected all the
    >text on the program interface will display in Spanish.
    >
    >This is easy to do for the majority of the text on a form. I just put
    >the following code in Form_Load:[/color]

    This looks very odd - are you using VB.NET ?
    Or is your Newsreader playing up ?
    [color=blue]
    >If language = “English” then
    > CmdOK.Caption = “OK”
    > etc
    >Elseif language = “Spanish” then
    > CmdOK.Caption = “Aceptar”
    > etc
    >End if[/color]
    I really would not write the code like that, it is asking for problems
    - the stuff becomes plain unreadable

    The way I wrote a multi-lingual system was by using a Lexicon

    Command1.Captio n = Lex( "Click Ok" )

    Lex() nips of to a string holding something like an INI file, and
    either returns the Spanish, or - if not found - returns the English,
    and adds the word/phrase to the file
    - that way one just translates the data in the file
    [color=blue]
    >
    >However I have a problem with the main drop down menu (i.e.
    >File/Edit/View etc). I did something similar to the above to change
    >the text however there are two other problems that I cannot see any
    >solution to:
    >
    >1. I want underscores under letters in the various options so I can
    >activate the option with Alt+Letter. This is normally done in the menu
    >editor by placing a & in front of the letter. This does not seem to
    >work when I change the caption at run time. The & seems to be ignored.[/color]

    I've just tested it and the & is not ignored in VB5
    [color=blue]
    >2. For a given option in the menu the standard shortcut for English
    >and Spanish are different. For example Open (Ctrl+O) in English and
    >Abrir (Ctrl+A) in Spanish. How can I change the shortcut at run time ?[/color]

    In VB5 only bottom level menu items can have 'design time' Shortcuts
    - and these cannot be altered at run time

    However you can make a menu items Enabled property False
    - also you can set their Visible property to False

    Personally I would design one menu with each line repeated twice
    - both in English
    - each having a different design Shortcut
    - each being a member of a Control Array
    eg: mnuFile(0)
    mnuFile(1)
    mnuClose(0)
    mnuClose(1)

    In one routine, I would run through all the Menu controls, setting the
    Visible property to True or False depending on the language
    - and using Lex() to get the Caption (for consistency)

    Because each Menu Item is a member of a Control Array, the Click event
    will run the same code

    Actually you only really need to bother with using Control Arrays for
    the bottom level menus

    An alternative method would be to use the Tag property
    - hmm - that would probably be much simpler

    Private Sub Command2_Click( )
    Dim C As Control
    Dim English As Boolean

    For Each C In Me.Controls
    If TypeOf C Is Menu Then
    Select Case C.Tag
    Case "E": C.Enabled = English
    C.Visible = English
    Case "F": C.Enabled = Not English
    C.Visible = Not English
    End Select
    End If
    Next
    End Sub[color=blue]
    >
    >I not the first person to write a multilingual program … how is
    >this normally done – am I going about this in the right way ?[/color]

    Basically I strongly recommend that you write the system in your
    native language, and just have one point where you pick up the
    translation

    To solve the Menu design time shortcut problem simply have two menu
    entries and hide the irrelevant one.


    Comment

    • smjmitchell

      #3
      Re: MultiLingual Application (English/Espanol)

      Thanks for the detailed reply ... I will give this a go.

      Yeap .. the Google newsreader facility is plying up hence the weird
      characters in the code .. they should have been quotation marks.

      Steve


      erewhon@nowhere .com (J French) wrote in message news:<3f963663. [email protected] tclick.com>...[color=blue]
      > Inline :-
      >
      > On 21 Oct 2003 14:32:03 -0700, smjmitchell@yah oo.com (smjmitchell)
      > wrote:
      >[color=green]
      > >Hi,
      > >
      > >I am writing an application in VB6.0 that will have the option to
      > >select the language. For instance when Spanish is selected all the
      > >text on the program interface will display in Spanish.
      > >
      > >This is easy to do for the majority of the text on a form. I just put
      > >the following code in Form_Load:[/color]
      >
      > This looks very odd - are you using VB.NET ?
      > Or is your Newsreader playing up ?
      >[color=green]
      > >If language = “English” then
      > > CmdOK.Caption = “OK”
      > > etc
      > >Elseif language = “Spanish” then
      > > CmdOK.Caption = “Aceptar”
      > > etc
      > >End if[/color]
      > I really would not write the code like that, it is asking for problems
      > - the stuff becomes plain unreadable
      >
      > The way I wrote a multi-lingual system was by using a Lexicon
      >
      > Command1.Captio n = Lex( "Click Ok" )
      >
      > Lex() nips of to a string holding something like an INI file, and
      > either returns the Spanish, or - if not found - returns the English,
      > and adds the word/phrase to the file
      > - that way one just translates the data in the file
      >[color=green]
      > >
      > >However I have a problem with the main drop down menu (i.e.
      > >File/Edit/View etc). I did something similar to the above to change
      > >the text however there are two other problems that I cannot see any
      > >solution to:
      > >
      > >1. I want underscores under letters in the various options so I can
      > >activate the option with Alt+Letter. This is normally done in the menu
      > >editor by placing a & in front of the letter. This does not seem to
      > >work when I change the caption at run time. The & seems to be ignored.[/color]
      >
      > I've just tested it and the & is not ignored in VB5
      >[color=green]
      > >2. For a given option in the menu the standard shortcut for English
      > >and Spanish are different. For example Open (Ctrl+O) in English and
      > >Abrir (Ctrl+A) in Spanish. How can I change the shortcut at run time ?[/color]
      >
      > In VB5 only bottom level menu items can have 'design time' Shortcuts
      > - and these cannot be altered at run time
      >
      > However you can make a menu items Enabled property False
      > - also you can set their Visible property to False
      >
      > Personally I would design one menu with each line repeated twice
      > - both in English
      > - each having a different design Shortcut
      > - each being a member of a Control Array
      > eg: mnuFile(0)
      > mnuFile(1)
      > mnuClose(0)
      > mnuClose(1)
      >
      > In one routine, I would run through all the Menu controls, setting the
      > Visible property to True or False depending on the language
      > - and using Lex() to get the Caption (for consistency)
      >
      > Because each Menu Item is a member of a Control Array, the Click event
      > will run the same code
      >
      > Actually you only really need to bother with using Control Arrays for
      > the bottom level menus
      >
      > An alternative method would be to use the Tag property
      > - hmm - that would probably be much simpler
      >
      > Private Sub Command2_Click( )
      > Dim C As Control
      > Dim English As Boolean
      >
      > For Each C In Me.Controls
      > If TypeOf C Is Menu Then
      > Select Case C.Tag
      > Case "E": C.Enabled = English
      > C.Visible = English
      > Case "F": C.Enabled = Not English
      > C.Visible = Not English
      > End Select
      > End If
      > Next
      > End Sub[color=green]
      > >
      > >I not the first person to write a multilingual program … how is
      > >this normally done – am I going about this in the right way ?[/color]
      >
      > Basically I strongly recommend that you write the system in your
      > native language, and just have one point where you pick up the
      > translation
      >
      > To solve the Menu design time shortcut problem simply have two menu
      > entries and hide the irrelevant one.[/color]

      Comment

      • Auric__

        #4
        Re: MultiLingual Application (English/Espanol)

        On Wed, 22 Oct 2003 08:21:35 +0000 (UTC), J French <[email deleted]>
        wrote:
        [color=blue]
        >This looks very odd - are you using VB.NET ?
        >Or is your Newsreader playing up ?
        >[color=green]
        >>If language = “English” then
        >> CmdOK.Caption = “OK”
        >> etc
        >>Elseif language = “Spanish” then
        >> CmdOK.Caption = “Aceptar”
        >> etc
        >>End if[/color][/color]

        OP probably wrote this in Word, with its "smart quotes" (oxymoron if
        I've ever heard one) turned on, and then pasted into Google.
        --
        auric "underscore " "underscore " "at" hotmail "dot" com
        *****
        Bigamy: one wife too many. Monogamy: same idea.

        Comment

        Working...