Hi, Readers.
Today I would like to briefly share a question that I was asked recently, how to easily get a list of all available languages via AL.
To maximize productivity Dynamics 365 Business Central supports many languages. In Version: W1 24.1 (Platform 24.0.19566.0 + Application 24.1.18927.19282), there are a total of 50 available languages.
More details: Supported languages
But in table 2000000045 “Windows Language”, there are 248 languages.
So is there any easy way to get available languages list? Yes, I will briefly introduce two simple ways in this post. Hope this helps you.
1. If you look into standard processing you might find the following code.
page 9204 “User Settings”:
codeunit 43 Language:
codeunit 54 “Language Impl.”:
Key method: GetApplicationLanguages
So we can do it the same way. (If you don’t need to display it on the page, you can delete the Page.Run line)
Test:
Great.
Source code: Github
pageextension 50217 CustomerListExt extends "Customer List"
{
actions
{
addafter("Co&mments")
{
action(GetAvailableLanguages)
{
ApplicationArea = All;
Caption = 'Get Available Languages';
Promoted = true;
PromotedCategory = Process;
PromotedIsBig = true;
Image = TestFile;
trigger OnAction()
var
Language: Codeunit Language;
TempWindowsLanguage: Record "Windows Language" temporary;
begin
GetApplicationLanguages(TempWindowsLanguage);
Page.Run(Page::"Windows Languages", TempWindowsLanguage);
end;
}
}
}
procedure GetApplicationLanguages(var TempWindowsLanguage: Record "Windows Language" temporary)
var
WindowsLanguage: Record "Windows Language";
begin
WindowsLanguage.SetRange("Localization Exist", true);
WindowsLanguage.SetRange("Globally Enabled", true);
if WindowsLanguage.FindSet() then
repeat
TempWindowsLanguage := WindowsLanguage;
TempWindowsLanguage.Insert();
until WindowsLanguage.Next() = 0;
end;
}
2. Using codeunit 9170 “Conf./Personalization Mgt.” -> procedure FilterToInstalledLanguages
The only thing to note is that this method excludes 1034 Spanish (Spain, International Sort, Traditional Sort).
So the result is only 49.
Source code: Github
pageextension 50217 CustomerListExt extends "Customer List"
{
actions
{
addafter("Co&mments")
{
action(GetAvailableLanguages)
{
ApplicationArea = All;
Caption = 'Get Available Languages';
Promoted = true;
PromotedCategory = Process;
PromotedIsBig = true;
Image = TestFile;
trigger OnAction()
var
ConfPersonalizationMgt: Codeunit "Conf./Personalization Mgt.";
WindowsLanguage: Record "Windows Language";
begin
WindowsLanguage.Reset();
ConfPersonalizationMgt.FilterToInstalledLanguages(WindowsLanguage);
Page.Run(Page::"Windows Languages", WindowsLanguage);
end;
}
}
}
}
After comparing the above two ways, you may have discovered that you only need to filter “Globally Enabled”=true and “Localization Exist”=true in table 2000000045 “Windows Language”.
Very simple, give it a try!!!😁
PS:
1. Dynamics 365 Business Central: Windows Language ID and Global Language ID
2. Dynamics 365 Business Central: List of Language IDs (1041,1033…) and Locale IDs (ja-JP,en-US…)
3. Dynamics 365 Business Central: How to get all Locale IDs (Language Culture Names) via AL
4. Business Central 2023 wave 1 (BC22) new features: New Language Selection table (2000000050)
END
Hope this will help.
Thanks for reading.
ZHU
コメント