Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 470
  • Last Modified:

VB.NET OS Language Detection & Best Method for Mutliple Language Form

I have a small application to update user's details in Active Directory. The application works fine in English. But I now want to modify it so it can be used for French, Italian & German users. So I'd like to be able to detect the OS language, and then provide the existing dropdown options in those languages. I should probably also translate the select box & input box labels into those languages as well.

Looking online there is
Thread.CurrentThread.CurrentCulture.Name

Open in new window

which when I run it gives me 'en-GB' which seems right. Is this the correct method to use? Or is there a better method for OS language detection?

If I could use it to get 'fr-FR', 'de-DE' and 'it-IT'. I could then just set the select options as variables, i.e. if language = en-GB, then select1 = English_Option1... elseif language = 'fr-FR', then select1 = French_Option1 etc.

What is the best way to handle the UI form once language has been detected? Should I just have 1 form, with all of the form labels, and textboxes set as different variables for each language, i.e. English = 'Selection Menu One', French = 'Menu de sélection Un'. Or should I have multiple forms, one for each language, i.e. Form1-en, Form1-fr, Form1-de etc and then based on the language detection, load a different form on start up?

I'm using VB.NET/Visual Studio 2012, with an app targeted to .NET 3.5 framework?
0
bjblackmore
Asked:
bjblackmore
  • 4
  • 2
2 Solutions
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
bjblackmoreAuthor Commented:
Thanks for the reply.

I tried to modify the Form1.resx, but when I do, it errors telling me I'm modifying a file that is part of another project? Also, the resource editor doesn't look anything like that in your page, mine just shows the icon I used, no tables or properties.
Screen-Shot-12-12-14-at-04.59-PM.JPG
0
 
bjblackmoreAuthor Commented:
I've followed the instructions, and managed to get the form language translations to work. This works for the form labels & comboboxes. However I've got MsgBox popups in some of the code. Can I use the resource files to translate these - I couldn't see any way - or do I have to set variables following language detection sing Thread.CurrentThread.CurrentCulture.Name?

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
.......
        Catch ex As Exception
            MsgBox("No Connection to domain." & Environment.NewLine & "Please connect to corporate network & try again.", MsgBoxStyle.Critical, "Network Error #2")
            Application.Exit()
        End Try

Open in new window


        ElseIf IsNothing(ComboBox.SelectedItem) Then
            MsgBox("Please Select Security Question", MsgBoxStyle.Exclamation, "Invalid Question")

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bjblackmoreAuthor Commented:
@Éric Moreau,
I re-read the page you linked, and had missed a few items. I know have it working, but have a few questions (also posted ont he page)
Do I need to insert the below code in the finished application, or is this just for testing? Should CurrentUICulture be set to Italian on italian systems, German on German/Austrian systems already?

    Public Sub New()
        MyBase.New()
        System.Threading.Thread.CurrentThread.CurrentUICulture = _
        New System.Globalization.CultureInfo("it")
        InitializeComponent()
    End Sub

Open in new window


Also, if selecting "de" (German) does this cover Austria (de-AT) as well? Likewise does ES (Spanish) also cover Puerto Rico (es-PR)? Or is it specific?
0
 
Éric MoreauSenior .Net ConsultantCommented:
>>Do I need to insert the below code in the finished application, or is this just for testing?

That line was to force the switch to a culture different then the default one. It was for testing only. It could also be used if you would like to force a culture.

>>Also, if selecting "de" (German) does this cover Austria (de-AT) as well?

Yes.
0
 
bjblackmoreAuthor Commented:
using external website & feedback from Eric, I got this working as wanted. Very useful website (when read properly, rather than skimming through as I initially did)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now