'''
''' The MyPage_Load sub handles load event for page.
'''
''' The object that raised the load event.
''' The object that contains the event data of the load event.
Private Sub MyPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Me.Page.IsPostBack Then
' Get the resource directory of the application. It is "bin" for .NET Framework 1.1 applications
' and "App_GlobalResources" for .NET Framework 2.0 applications
Dim resourceDir As String = ""
Dim runtimeVersion As String = System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion()
If runtimeVersion.IndexOf("v2") = -1 Then
resourceDir = "bin"
Else
resourceDir = "App_GlobalResources"
End If
' Get full path of resource directory
Dim resourcePath As String = Me.Request.PhysicalApplicationPath() & resourceDir & "\"
If System.IO.Directory.Exists(resourcePath) Then
' Find all the resource files of the type AppName.culture.resx
Dim resourceFiles() As String = System.IO.Directory.GetFiles(resourcePath, "*.*.resx")
Dim resourceFile As String = ""
For Each resourceFile In resourceFiles
' Get the file name
Dim finfo As System.IO.FileInfo = New System.IO.FileInfo(resourceFile)
Dim fileName As String = finfo.Name
' Split the filename by the "."
Dim splitBy As String ="."
Dim namePieces As String() = fileName.Split(splitBy.ToCharArray())
Dim length As Integer = namePieces.Length
Dim index As Integer = length - 2
' Get the culture name portion of the filename like "en-US"
Dim cultureName As String = namePieces(index)
'Create a CultureInfo object to represent the culture
Dim culutreInfo As System.Globalization.CultureInfo = New System.Globalization.CultureInfo(cultureName)
' Populate the cultures list
Dim li As ListItem = New ListItem(culutreInfo.DisplayName, culutreInfo.Name)
If Not Me.LanguageList.Items.Contains(li) Then
Me.LanguageList.Items.Add(li)
' Select the current culture of the application
If System.Threading.Thread.CurrentThread.CurrentUICulture.Name = culutreInfo.Name Then
li.Selected = True
End If
End If
Next resourceFile
End If
End If
End Sub
|