Dynamics 365 Business Central: How to get all Locale IDs (Language Culture Names) via AL

Dynamics 365 Business Central

Hi, Readers.
Today I would like to talk about how to get all Locale IDs (Language Culture Names) via AL.

In my previous post, List of Language IDs (1041,1033…) and Locale IDs (ja-JP,en-US…), I briefly shared what are language IDs and what are Locale IDs in Business Central.

Language IDs:

Locale IDs (Language Culture Names): This is mainly used in translation files (XLIFF file).

At that time, I thought that there was no way to get Locale IDs in Business Central, so I had to go to Microsoft’s Docs to find them. But recently, while investigating another problem, I stumbled upon the method. So in this post, I would like to share it, hope it will help.

This time we will use codeunit 10 “Type Helper”.

There are two methods relate this in it, procedure GetCultureName() and procedure LanguageIDToCultureName().

Let’s do a simple test.

The current language is English (United States).

The language ID of Japanese is 1041.

Test code:

Result:

Okay, next we can use table Windows Language (2000000045) to create a new list page.

And add a variable to display Locale ID/Culture Name.

It worked.

Source Code:

page 50101 "Windows Language"
{
    ApplicationArea = All;
    Caption = 'Windows Language';
    PageType = List;
    SourceTable = "Windows Language";
    UsageCategory = Lists;
    Editable = false;

    layout
    {
        area(content)
        {
            repeater(General)
            {
                field("Language ID"; Rec."Language ID")
                {
                    ToolTip = 'Specifies the unique language ID for the Windows language.';
                    ApplicationArea = All;
                }
                field("Primary Language ID"; Rec."Primary Language ID")
                {
                    ToolTip = 'Specifies the value of the Primary Language ID field.';
                    ApplicationArea = All;
                }
                field(Name; Rec.Name)
                {
                    ToolTip = 'Specifies the names of the available Windows languages.';
                    ApplicationArea = All;
                }
                field("Abbreviated Name"; Rec."Abbreviated Name")
                {
                    ToolTip = 'Specifies the value of the Abbreviated Name field.';
                    ApplicationArea = All;
                }
                field(LocaleIDs; LocaleIDs)
                {
                    Caption = 'Locale ID/Culture Name';
                    ApplicationArea = All;
                }
            }
        }
    }

    var
        LocaleIDs: Text[20];

    trigger OnAfterGetRecord()
    var
        TypeHelper: Codeunit "Type Helper";
    begin
        LocaleIDs := TypeHelper.LanguageIDToCultureName(Rec."Language ID");
    end;
}

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL