Solved

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

Posted on 2014-12-12
7
342 Views
Last Modified: 2014-12-16
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
Comment
Question by:bjblackmore
  • 4
  • 2
7 Comments
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 500 total points
ID: 40496021
0
 

Author Comment

by:bjblackmore
ID: 40496478
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
 

Author Comment

by:bjblackmore
ID: 40497273
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 79

Expert Comment

by:David Johnson, CD, MVP
ID: 40497550
0
 

Author Comment

by:bjblackmore
ID: 40500469
@É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
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 40500508
>>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
 

Author Closing Comment

by:bjblackmore
ID: 40503813
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question