Private Sub ChangeLanguageToolStripMenuItem_DropDownItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles ChangeLanguageToolStripMenuItem.DropDownItemClicked
Dim Id As String = e.ClickedItem.Tag.ToString
Dim Result As MsgBoxResult = MsgBox(String.Format("{1}{0}{0}{2}", vbCrLf, ChangeLabguageMessage, ChangeLabguageMessage(Id)), MsgBoxStyle.YesNo)
If Result = MsgBoxResult.No Then Exit Sub
My.Settings.LanguageId = e.ClickedItem.Tag.ToString
My.Settings.Save()
Application.Restart()
End Sub
در این آموزش برای یک نرم افزار چندزبانه به تعداد زبانها Resources File ایجاد شده و یک کلاسی استفاده می شه که قادر است طبق زبان انتخاب شده متن را از ریسورس فراخوانی و نمایش دهد....
Public Class CurrentResources
Private Shared ManagerValue As New Resources.ResourceManager("<ProjectAssembly.ResourcesName>", GetType(<AnyClassesOfProject>).Assembly)
Public Shared ReadOnly Property Manager() As Resources.ResourceManager
Get
Return ManagerValue
End Get
End Property
Public Shared ReadOnly Property Strings(resName As String) As String
Get
Return Manager.GetString(resName)
End Get
End Property
Public Shared ReadOnly Property ChangeLabguageMessage() As String
Get
Return Manager.GetString("ChangeLabguageMessage")
End Get
End Property
End Class
در این آموزش شناسایی راست به چپ بودن Layout یک زبان برای نرم افزار چند زبانه و اعمال تغییرات بر روی اشیاء فرم ها توضیح داده شده....
Public ReadOnly Property RightToLeft() As Boolean
Get
Return My.Application.UICulture.TextInfo.IsRightToLeft
End Get
End Property
With OptionsAndSettiongs
If RightToLeft = False Then
.ButtonsTableLayoutPanel.Dock = DockStyle.Right
End If
With .TabControl1
If RightToLeft = False Then
.RightToLeft = Windows.Forms.RightToLeft.No
End If
For Each Page As TabPage In .TabPages
If Page.Tag Is Nothing OrElse Page.Tag.ToString.Length = 0 Then Continue For
Page.Text = CurrentResources.Strings(Page.Tag.ToString)
If RightToLeft = False Then
With DirectCast(Page.Controls(0), ListView)
.RightToLeftLayout = False
End With
End If
Next
End With
End With
در این آموزش ساخت Resource های بخش Message های نرم افزار MultiLanguage توضیح داده می شه...
که در این پروژه زبان های فارسی-عربی-انگلیسی و ویتنامی استفاده شده....
Windows Multi Language Application
Farsi
Arabic
English
Vietnamese
Dim Id As String = My.Settings.LanguageId
If Id.Length = 0 Then Id = My.Application.Culture.Name
Debug.Print(Id)
If My.Application.UICulture.Name <> Id Then
My.Application.ChangeUICulture(Id)
Debug.Print(Id)
End If
-----------------------------------------------------------------------------------------------------------------------
Public Class CurrentResources
Private Shared ManagerValue As New ComponentResourceManager(GetType(MultiLanguageResources))
Public Shared ReadOnly Property Manager() As ComponentResourceManager
Get
Return ManagerValue
End Get
End Property
Public Shared ReadOnly Property Strings(resName As String) As String
Get
Return Manager.GetString(resName)
End Get
End Property
Public Shared ReadOnly Property ChangeLabguageMessage() As String
Get
Return Manager.GetString("ChangeLabguageMessage")
End Get
End Property
End Class
----------------------------------------------------------------------------------------------------------------------
Private Sub ChangeLanguageToolStripMenuItem_DropDownItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles ChangeLanguageToolStripMenuItem.DropDownItemClicked
Dim Result As MsgBoxResult = MsgBox(ChangeLabguageMessage, MsgBoxStyle.YesNo)
If Result = MsgBoxResult.No Then Exit Sub
My.Settings.LanguageId = e.ClickedItem.Tag.ToString
My.Settings.Save()
Application.Restart()
End Sub
--------------------------------------------------------------------------------------------------------------------
در این آموزش بجای استفاده از دسنور Imports در هر فایل (Class, Module, ...) Namespace و Namespace Classes به پروژه اضافه می شه ....