Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem making application use 2 languages

Status
Not open for further replies.

robUK2

Programmer
Mar 10, 2008
57
0
0
TH
Hello,

I cannot get my application to display in English, it always displays in French

I have an application that uses 2 languages. The default language is en-GB and the second language is French

For setting the text of the buttons and labels. I have set the localized property to true and changing the language to fr-FR on the form. So setting the default languages controls by choosing the default the language property, and then switching to French language to set the French controls. So I have the following files:
Code:
formMain.resx
formMain.fr-FR.resx
formMain.Designer.vb
formMain.vb

And for message boxes and other strings I have added these 2 resource files
Code:
formMain.Strings.resx
formMain.Strings.fr-FR.resx

So if I want to switch to different languages I have changed the cultureInfo as follows:
Code:
If My.Settings.Default.Language = "en-GB" Then
	Thread.CurrentThread.CurrentUICulture = New CultureInfo("fr-FR")
Else
	Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-GB")
End If

And for string I use the following:
Code:
MessageBox.Show(formMain_Strings.SameStringName)

I also an address book form that is a child of the formMain. Which I have used the same method. However, the address book works as normal, but the formMain never changes to the language I want. Even though tested by explictly setting the language to en-GB in the form constuctor before the inializeComponent() it will always default to French.

Not sure why the address book (child) work correctly, the parent form (formMain) will always display in French, no matter if I have set this to en-GB.

I am 100% that my method is correct using what I have show you above.

I was thinkng about deleting the formMain and creating a new one. But that would mean doing everything again and would take too long.

Many thanks for any advice on this,
 
Code:
If My.Settings.Default.Language = "fr-FR" Then
    Thread.CurrentThread.CurrentUICulture = New CultureInfo("fr-FR")
Else
    Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-GB")
End If

edited a mistake a I made. I am using the code above.



 
You shouldn't have to manually change the culture in your program. If it's a WinForm, the .NET runtime will respect the user's Control Panel settings. If it's a WebForm, it will use the Accept-Language HTTP header from your user's browser.

So far as your workflow in localizing your forms, I've found that flipping the localization property for the form should be the last thing you do. Set all properties for your neutral language first, then set it to your first specific supported language (en-GB) and then hand-modify the resource file.

Chip H.


____________________________________________________________________
www.chipholland.com
 
My code was correct.

However, I had a user control also on the main form. This user control fires before the main for started. So over writing the language change in my main form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top