From cd3646dca026ad84556372eb0849cd2e1f7fb810 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 15 May 2023 16:02:39 +0200 Subject: [PATCH] Base: Add Language Module --- Base/Base.vbproj | 1 + Base/Language.vb | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Base/Language.vb diff --git a/Base/Base.vbproj b/Base/Base.vbproj index f6ca6eae..42e132b1 100644 --- a/Base/Base.vbproj +++ b/Base/Base.vbproj @@ -79,6 +79,7 @@ + True diff --git a/Base/Language.vb b/Base/Language.vb new file mode 100644 index 00000000..6c9b0e10 --- /dev/null +++ b/Base/Language.vb @@ -0,0 +1,32 @@ +Imports System.Globalization +Imports System.Threading +Imports DigitalData.Modules.Logging + +Public Class Language + Public Shared Sub SetApplicationLanguage(pLogger As Logger, pUserLanguage As String, Optional pUserDateFormat As String = Nothing) + Try + pLogger.Debug("Setting application language..") + + 'Dim Culture = CultureInfo.CreateSpecificCulture(pUserLanguage) + Dim Culture As New CultureInfo(pUserLanguage) + Culture.DateTimeFormat.ShortDatePattern = pUserDateFormat + + pLogger.Debug("Culture object for language [{0}] created", pUserLanguage) + + ' The following line provides localization for data formats. + Thread.CurrentThread.CurrentCulture = Culture + ' The following line provides localization for the application's user interface. + Thread.CurrentThread.CurrentUICulture = Culture + + ' Set this culture as the default culture for all threads in this application. + ' Note: The following properties are supported in the .NET Framework 4.5+ + CultureInfo.DefaultThreadCurrentCulture = Culture + CultureInfo.DefaultThreadCurrentUICulture = Culture + + pLogger.Debug("Application language set to [{0}]", Culture.Name) + Catch ex As Exception + pLogger.Warn("Could not set application language!") + pLogger.Error(ex) + End Try + End Sub +End Class