Base: Add Language Module
This commit is contained in:
parent
0c1b070a90
commit
cd3646dca0
@ -79,6 +79,7 @@
|
||||
<Compile Include="IDB\Attributes.vb" />
|
||||
<Compile Include="IDB\Database.vb" />
|
||||
<Compile Include="IDB\FileStore.vb" />
|
||||
<Compile Include="Language.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
32
Base/Language.vb
Normal file
32
Base/Language.vb
Normal file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user