From 8d5e64a86645901709adf80d982c5aa37b261609 Mon Sep 17 00:00:00 2001 From: Enrico Cimitan Date: Fri, 6 Dec 2024 15:37:17 +0100 Subject: [PATCH] Add current culture to language module --- .../App/Language/src/Language.Codeunit.al | 11 +++++++++++ .../App/Language/src/LanguageImpl.Codeunit.al | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/src/System Application/App/Language/src/Language.Codeunit.al b/src/System Application/App/Language/src/Language.Codeunit.al index 96206adb63..1a6fff92ff 100644 --- a/src/System Application/App/Language/src/Language.Codeunit.al +++ b/src/System Application/App/Language/src/Language.Codeunit.al @@ -308,6 +308,17 @@ codeunit 43 Language exit(LanguageImpl.GetCultureName(LanguageID)); end; + /// + /// Retrieves the current culture name for the session. + /// + /// The culture name. For example, 'en-US'. + procedure GetCurrentCultureName(): Text + var + LanguageImpl: Codeunit "Language Impl."; + begin + exit(LanguageImpl.GetCurrentCultureName()); + end; + /// /// Integration event, emitted from . /// Subscribe to this event to change the default behavior by changing the provided parameter(s). diff --git a/src/System Application/App/Language/src/LanguageImpl.Codeunit.al b/src/System Application/App/Language/src/LanguageImpl.Codeunit.al index 42412f0ccd..bbba4693bd 100644 --- a/src/System Application/App/Language/src/LanguageImpl.Codeunit.al +++ b/src/System Application/App/Language/src/LanguageImpl.Codeunit.al @@ -342,6 +342,13 @@ codeunit 54 "Language Impl." exit(CultureInfo.Name); end; + procedure GetCurrentCultureName(): Text + var + CultureInfo: DotNet CultureInfo; + begin + exit(CultureInfo.CurrentCulture.Name); + end; + [EventSubscriber(ObjectType::Codeunit, Codeunit::"UI Helper Triggers", GetApplicationLanguage, '', false, false)] local procedure SetApplicationLanguageId(var language: Integer) begin