Modules/Base/Language.vb
2023-05-15 16:02:39 +02:00

33 lines
1.4 KiB
VB.net

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