0

Objective: I want to change the language on specific control (label) from english to thai.

Code:

Public Class frmClient
    Private ThaiLang As InputLanguage

    Sub ChangeLang(lblControl As Label)
        InputLanguage.CurrentInputLanguage = ThaiLang
    End Sub
    Private Sub frmClient_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim Newctr As Integer

        Newctr = InputLanguage.InstalledInputLanguages.Count

        For i As Integer = 1 To (Newctr - 1)
            If InputLanguage.InstalledInputLanguages(i).LayoutName.Contains("Thai") = True Then
                ThaiLang = InputLanguage.InstalledInputLanguages(i)
                i = (Newctr - 1)
            End If
        Next

        ChangeLang(lblDispThaiName)
        Me.lblDispThaiName.Text = "Test"
    End Sub

but when i run the project, nothing happens. hope anyone can give me a helping hand. thank you.

xander36
  • 79
  • 7
  • 1
    No, you need to read [Globalize and localize .NET applications](https://learn.microsoft.com/en-us/dotnet/core/extensions/globalization-and-localization) chapter to know how to create a _world-ready app_. Switching the input language to one of the installed languages by code is just like pressing `Alt+Shift` or selecting one from the Taskbar language menu. – dr.null Aug 13 '22 at 12:32

1 Answers1

3

A label isn't an input control, and neither does setting the input language translate text values for you. It's your job as a programmer to set text properties to appropriate language text (the normal method being to store local language string in resource files, one per language, and pick the text to be displayed from the current language resource file)

This might help you: How to make multi-language app in Winforms?

Steve Todd
  • 126
  • 5