diff --git a/src/System Application/App/Language/app.json b/src/System Application/App/Language/app.json index e3ac9b2dd7..9025ae0a66 100644 --- a/src/System Application/App/Language/app.json +++ b/src/System Application/App/Language/app.json @@ -47,8 +47,12 @@ { "from": 535, "to": 535 + }, + { + "from": 3563, + "to": 3563 } ], "target": "OnPrem", "contextSensitiveHelpUrl": "https://learn.microsoft.com/dynamics365/business-central/" -} +} \ No newline at end of file diff --git a/src/System Application/App/Language/permissions/LanguageEdit.PermissionSet.al b/src/System Application/App/Language/permissions/LanguageEdit.PermissionSet.al index 2562e7d40f..ae6dc09e3a 100644 --- a/src/System Application/App/Language/permissions/LanguageEdit.PermissionSet.al +++ b/src/System Application/App/Language/permissions/LanguageEdit.PermissionSet.al @@ -6,7 +6,7 @@ namespace System.Globalization; /// -/// This permission set allows editing of the list of languages. +/// This permission set allows editing of the list of languages and supported languages. /// permissionset 43 "Language - Edit" { @@ -15,5 +15,6 @@ permissionset 43 "Language - Edit" IncludedPermissionSets = "Language - View"; - Permissions = tabledata Language = IMD; + Permissions = tabledata "Allowed Language" = IMD, + tabledata Language = IMD; } diff --git a/src/System Application/App/Language/permissions/LanguageObjects.PermissionSet.al b/src/System Application/App/Language/permissions/LanguageObjects.PermissionSet.al index 08ef8ed742..170d527185 100644 --- a/src/System Application/App/Language/permissions/LanguageObjects.PermissionSet.al +++ b/src/System Application/App/Language/permissions/LanguageObjects.PermissionSet.al @@ -10,6 +10,7 @@ permissionset 164 "Language - Objects" Access = Internal; Assignable = false; - Permissions = page Languages = X, + Permissions = page "Allowed Languages" = X, + page Languages = X, page "Windows Languages" = X; -} +} \ No newline at end of file diff --git a/src/System Application/App/Language/src/AllowedLanguage.Table.al b/src/System Application/App/Language/src/AllowedLanguage.Table.al new file mode 100644 index 0000000000..3535acb412 --- /dev/null +++ b/src/System Application/App/Language/src/AllowedLanguage.Table.al @@ -0,0 +1,46 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.Globalization; + +/// +/// Table that contains a list of specific application languages available for the users. If the table is empty, then all installed application languages will be available. +/// +table 3563 "Allowed Language" +{ + Caption = 'Allowed Language'; + DataClassification = SystemMetadata; + DataPerCompany = false; + InherentEntitlements = X; + InherentPermissions = X; + + fields + { + field(1; "Language Id"; Integer) + { + Caption = 'Language Id'; + NotBlank = true; + BlankZero = true; + TableRelation = "Windows Language" where("Localization Exist" = const(true), "Globally Enabled" = const(true)); + ToolTip = 'Specifies the language id(s) that should be available for this environment.'; + } + field(2; Language; Text[80]) + { + Caption = 'Language'; + Editable = false; + FieldClass = FlowField; + CalcFormula = lookup("Windows Language".Name where("Language ID" = field("Language Id"))); + ToolTip = 'Specifies the language that should be available for this environment.'; + } + } + + keys + { + key(PK; "Language Id") + { + Clustered = true; + } + } +} \ No newline at end of file diff --git a/src/System Application/App/Language/src/AllowedLanguages.Page.al b/src/System Application/App/Language/src/AllowedLanguages.Page.al new file mode 100644 index 0000000000..be15edce17 --- /dev/null +++ b/src/System Application/App/Language/src/AllowedLanguages.Page.al @@ -0,0 +1,37 @@ +// ------------------------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// ------------------------------------------------------------------------------------------------ + +namespace System.Globalization; + +/// +/// Page that shows the list of allows languages which is enabled for this environment. If nothing is specified, then the user will be able to use all available languages. +/// +page 3563 "Allowed Languages" +{ + Caption = 'Allowed Languages'; + PageType = List; + ApplicationArea = All; + UsageCategory = Administration; + SourceTable = "Allowed Language"; + HelpLink = 'https://go.microsoft.com/fwlink/?linkid=2149387'; + AdditionalSearchTerms = 'company,role center,role,language'; + AboutTitle = 'About allowed languages.'; + AboutText = 'Define a list of allowed languages which is enabled for this environment. If nothing is specified, then the user will be able to use all available languages.'; + Permissions = tabledata "Allowed Language" = r; + + layout + { + area(Content) + { + repeater(AllowedLanguages) + { + field("Language Id"; Rec."Language Id") + { } + field(Language; Rec.Language) + { } + } + } + } +} \ No newline at end of file diff --git a/src/System Application/App/Language/src/LanguageImpl.Codeunit.al b/src/System Application/App/Language/src/LanguageImpl.Codeunit.al index 926c63bd1a..42412f0ccd 100644 --- a/src/System Application/App/Language/src/LanguageImpl.Codeunit.al +++ b/src/System Application/App/Language/src/LanguageImpl.Codeunit.al @@ -6,8 +6,8 @@ namespace System.Globalization; using System; -using System.Environment.Configuration; using System.Environment; +using System.Environment.Configuration; codeunit 54 "Language Impl." { @@ -15,7 +15,8 @@ codeunit 54 "Language Impl." SingleInstance = true; InherentEntitlements = X; InherentPermissions = X; - Permissions = tabledata Language = rimd, + Permissions = tabledata "Allowed Language" = rimd, + tabledata Language = rimd, tabledata "Language Selection" = r, tabledata "User Personalization" = rm, tabledata "Windows Language" = r; @@ -151,11 +152,23 @@ codeunit 54 "Language Impl." procedure GetApplicationLanguages(var TempWindowsLanguage: Record "Windows Language" temporary) var + AllowedLanguage: Record "Allowed Language"; WindowsLanguage: Record "Windows Language"; + LanguageFilter: Text; begin + AllowedLanguage.ReadIsolation := IsolationLevel::ReadCommitted; + AllowedLanguage.LoadFields("Language Id"); + if AllowedLanguage.FindSet() then + repeat + AddToFilter(Format(AllowedLanguage."Language Id"), LanguageFilter); + until AllowedLanguage.Next() = 0; + + WindowsLanguage.ReadIsolation := IsolationLevel::ReadCommitted; + if LanguageFilter <> '' then + WindowsLanguage.SetFilter("Language ID", LanguageFilter); + WindowsLanguage.SetRange("Localization Exist", true); WindowsLanguage.SetRange("Globally Enabled", true); - if WindowsLanguage.FindSet() then repeat TempWindowsLanguage := WindowsLanguage; @@ -163,6 +176,14 @@ codeunit 54 "Language Impl." until WindowsLanguage.Next() = 0; end; + local procedure AddToFilter(Value: Text; var ValueFilter: Text) + begin + if ValueFilter = '' then + ValueFilter := Value + else + ValueFilter += '|' + Value; + end; + procedure GetDefaultApplicationLanguageId(): Integer begin exit(1033); // en-US @@ -248,14 +269,16 @@ codeunit 54 "Language Impl." procedure LookupWindowsLanguageId(var LanguageId: Integer) var - WindowsLanguage: Record "Windows Language"; + TempWindowsLanguage: Record "Windows Language" temporary; begin - WindowsLanguage.SetCurrentKey(Name); + GetApplicationLanguages(TempWindowsLanguage); + + TempWindowsLanguage.SetCurrentKey(Name); - if WindowsLanguage.Get(LanguageId) then; + if TempWindowsLanguage.Get(LanguageId) then; - if Page.RunModal(Page::"Windows Languages", WindowsLanguage) = Action::LookupOK then - LanguageId := WindowsLanguage."Language ID"; + if Page.RunModal(Page::"Windows Languages", TempWindowsLanguage) = Action::LookupOK then + LanguageId := TempWindowsLanguage."Language ID"; end; procedure GetParentLanguageId(LanguageId: Integer) ParentLanguageId: Integer diff --git a/src/System Application/App/app.json b/src/System Application/App/app.json index 76e348f19a..f16de82bfb 100644 --- a/src/System Application/App/app.json +++ b/src/System Application/App/app.json @@ -22,7 +22,7 @@ "name": "System Application Test Library", "publisher": "Microsoft" }, - { + { "id": "1a3ac64b-0e25-2345-8e9b-eab2a74b9e9a", "name": "Agent Developer Toolkit", "publisher": "Microsoft" @@ -47,4 +47,4 @@ "includeSourceInSymbolFile": true }, "contextSensitiveHelpUrl": "https://learn.microsoft.com/dynamics365/business-central/" -} +} \ No newline at end of file