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:
![](https://yzhums.com/wp-content/uploads/2021/12/image-195-1024x603.png)
Locale IDs (Language Culture Names): This is mainly used in translation files (XLIFF file).
![](https://yzhums.com/wp-content/uploads/2021/12/image-197-1024x731.png)
![](https://yzhums.com/wp-content/uploads/2020/10/image-352.png)
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”.
![](https://yzhums.com/wp-content/uploads/2022/06/image-114.png)
There are two methods relate this in it, procedure GetCultureName() and procedure LanguageIDToCultureName().
![](https://yzhums.com/wp-content/uploads/2022/06/image-115.png)
Let’s do a simple test.
The current language is English (United States).
![](https://yzhums.com/wp-content/uploads/2022/06/image-119-1024x493.png)
The language ID of Japanese is 1041.
![](https://yzhums.com/wp-content/uploads/2022/06/image-118-1024x195.png)
Test code:
![](https://yzhums.com/wp-content/uploads/2022/06/image-116-1024x264.png)
Result:
![](https://yzhums.com/wp-content/uploads/2022/06/image-117-1024x493.png)
Okay, next we can use table Windows Language (2000000045) to create a new list page.
![](https://yzhums.com/wp-content/uploads/2022/06/image-120-1024x493.png)
![](https://yzhums.com/wp-content/uploads/2022/06/image-121-924x1024.png)
And add a variable to display Locale ID/Culture Name.
![](https://yzhums.com/wp-content/uploads/2022/06/image-122-1024x816.png)
It worked.
![](https://yzhums.com/wp-content/uploads/2022/06/image-123-1024x493.png)
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
コメント