Search code examples
c#shellautohotkey

AHK script localization


I'm writing a C# library and using AHK to display some text on the screen (together with some other AHK features). I want this text to be localized to different locales. How can this be achieved? I tried searching AHK documentation and forums, but could not find anything. Is this possible?

I'm using the following code to render the text:

Gui, Add, Text, "Text to be localized"

Solution

  • You shall use the built-in variable %A_Language%

    -Click here to see the List of the Language Codes-

    Usage Example:

    if A_Language in 0416,0816
    {
    text:="Olá"
    }
    
    else if A_Language in 040a,080a,0c0a,100a,140a,180a,1c0a,200a,240a,280a,2c0a,300a,340a,380a,3c0a,400a,440a,480a,4c0a,500a
    {
    text:="Holla"
    }
    
    else
    {
    text:="Hello"
    }
    
    Gui, Add, Text, %text%