Home > Software engineering >  change inputlanguage in specific control
change inputlanguage in specific control

Time:08-14

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.

CodePudding user response:

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?

  • Related