Localization/Globalization Question

  • Thread starter Thread starter eBob.com
  • Start date Start date
E

eBob.com

I'm writing an application which I'd like to work in either of two
languages. I'd like the end user to be able to switch between the two
languages at any point in time. But I have found MS documentation which
ways ...

Add the following code. In Visual Basic, it should go in the New function,
before calling the InitializeComponent function. ...

' Visual Basic
' Sets the UI culture to French (France).
Thread.CurrentThread.CurrentUICulture = New CultureInfo("fr-FR")


This sounds to me like the language is determined once and for all when the
application is initializing. I guess I should just believe the MS
documentation and move on. But I am hoping that the doc is wrong and the
language can be changed on the fly.

Thanks, Bob
 
Yea written probably by Americans, but for sure not Canadians.

The UI culture is gotten from the settings of the user, if you set it, then
you are probably in trouble trouble.

In a French computer the setting is mostly fr-Fr or fr-BE or fr-CH etc.

Keep it that way, as the software is used on a let say Dutch computer in
Belgium, then it will use by instance

nl-BE

This you can test (now simply in the same way as your showed code), if you
have used the standard in build language methods in forms, then is will be
used like that.

Cor
 
Grant Frisken said:
This sounds to me like the language is determined once and for all when
the
application is initializing. I guess I should just believe the MS
documentation and move on. But I am hoping that the doc is wrong and the
language can be changed on the fly.

You can change the CurrentUICulture at any time however this won't
affect forms that are already open. So by default you need to close
any open forms and reopen them to force them to reload using resources
for the new culture. There are some solutions that address this
issue and allow you to change the culture on the fly. See the
following code project articles:

http://www.codeproject.com/KB/cs/CultureManager.aspx - for windows
forms projects

http://www.codeproject.com/KB/WPF/WPF_Resx_Localization.aspx - for WPF
projects

Thank you Grant. But I still must be missing something because it's still
not working. In my Form1 code I have the following ...

Private Sub Button1_Click(ByVal sender As System.Object, ...

Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-US")

Dim dtf As New Define_New_Template 'define template form

...

dtf.Show()

Then in my Define_New_Template code I have ...

Private Sub Define_New_Template_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
Handles MyBase.Load
...

Dim LocRM As New ResourceManager("FL658323 Invoice Doc Parser
0.WinFormStrings", _
GetType(Form1).Assembly)
Try
MessageBox.Show(LocRM.GetString("define_new_template_form_title"))
Catch ex As Exception
MsgBox(ex.Message)
End Try

So I am executing Thread.CurrentThread.CurrentUICulture = New
CultureInfo("en-US") before I Dim dtf. But still the call to
LocRM.GetString is blowing up as described in my other recent post
("ResourceManager.GetString").

If you can offer any further help I would sure appreciate it.

Thanks, Bob
 
Back
Top