By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,341 Members | 1,395 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,341 IT Pros & Developers. It's quick & easy.

MultiLingual Application (English/Espanol)

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Inline :-

On 21 Oct 2003 14:32:03 -0700, sm*********@yahoo.com (smjmitchell)
wrote:
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:
This looks very odd - are you using VB.NET ?
Or is your Newsreader playing up ?
If language = “English” then
CmdOK.Caption = “OK”
etc
Elseif language = “Spanish” then
CmdOK.Caption = “Aceptar”
etc
End if 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.Caption = 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

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.
I've just tested it and the & is not ignored in VB5
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 ?
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
I not the first person to write a multilingual program … how is
this normally done – am I going about this in the right way ?


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.
Jul 17 '05 #2

P: n/a
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
er*****@nowhere.com (J French) wrote in message news:<3f***************@news.btclick.com>...
Inline :-

On 21 Oct 2003 14:32:03 -0700, sm*********@yahoo.com (smjmitchell)
wrote:
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:


This looks very odd - are you using VB.NET ?
Or is your Newsreader playing up ?
If language = “English” then
CmdOK.Caption = “OK”
etc
Elseif language = “Spanish” then
CmdOK.Caption = “Aceptar”
etc
End if

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.Caption = 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

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.


I've just tested it and the & is not ignored in VB5
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 ?


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

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


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.

Jul 17 '05 #3

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


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.
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.