Solved

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

Posted on 2014-12-12
7
334 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

21 Experts available now in Live!

Get 1:1 Help Now