Solved

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

Posted on 2014-12-12
7
325 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 69

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 78

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 69

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now