Solved

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

Posted on 2014-12-12
7
357 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 80

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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with error in Query 2 31
Add a Condition in ASP Repeater 6 34
MYSQL responding very slow 3 27
Regarding swagger API 1 17
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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

820 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