How to change Language? [modified]
-
Hi all, I've created a form which is in English, and would also like it to be displayed French and Spanish via a combobox? I have created a combobox(cboLanguage) and added English, Franch & Spanish too it and added the following code: Dim Language As String Language = cboLanguage.Text If Language = "French" Then Me.lblTitle.Text = ("Titre") Me.lblFirstName.Text = ("Prenom") Me.lblLastName.Text = ("Dernier nom") Else : Me.lblTitle.Text = ("Title") Me.lblFirstName.Text = ("First Name") Me.lblLastName.Text = ("Last Name") End If This all works Ok, but can be very time comsuming esp if your doing muliple Languages on many forms. Can anyone tell me if there is a simlpe way for doing this??? Many Thanks Ian Wells -- modified at 8:34 Sunday 9th September, 2007 Ian Wells
-
Hi all, I've created a form which is in English, and would also like it to be displayed French and Spanish via a combobox? I have created a combobox(cboLanguage) and added English, Franch & Spanish too it and added the following code: Dim Language As String Language = cboLanguage.Text If Language = "French" Then Me.lblTitle.Text = ("Titre") Me.lblFirstName.Text = ("Prenom") Me.lblLastName.Text = ("Dernier nom") Else : Me.lblTitle.Text = ("Title") Me.lblFirstName.Text = ("First Name") Me.lblLastName.Text = ("Last Name") End If This all works Ok, but can be very time comsuming esp if your doing muliple Languages on many forms. Can anyone tell me if there is a simlpe way for doing this??? Many Thanks Ian Wells -- modified at 8:34 Sunday 9th September, 2007 Ian Wells
You factor out all of your display strings into a config file, and then create a different file for each language. Then, once your code selects what file to get it's values from, it's just going to work everywhere.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi all, I've created a form which is in English, and would also like it to be displayed French and Spanish via a combobox? I have created a combobox(cboLanguage) and added English, Franch & Spanish too it and added the following code: Dim Language As String Language = cboLanguage.Text If Language = "French" Then Me.lblTitle.Text = ("Titre") Me.lblFirstName.Text = ("Prenom") Me.lblLastName.Text = ("Dernier nom") Else : Me.lblTitle.Text = ("Title") Me.lblFirstName.Text = ("First Name") Me.lblLastName.Text = ("Last Name") End If This all works Ok, but can be very time comsuming esp if your doing muliple Languages on many forms. Can anyone tell me if there is a simlpe way for doing this??? Many Thanks Ian Wells -- modified at 8:34 Sunday 9th September, 2007 Ian Wells
A different solution could be: - Use the visual studio designer to localize the form (search for "localizing vb.net forms" on google) - Then set the System.Thread.CurrentCulture to the value you want in the combobox selection changed event. - On every control you could reapply the localized resources: (translated to vb.net, not compiled so it may contain some small errors)
Dim resources as System.ComponentModel.ComponentResourceManager = _ new System.ComponentModel.ComponentResourceManager(GetType(YourForm)) For Each c as Control in Me.Controls resources.ApplyResources(c, c.Name) Next
Regards, Jelle Hissink