Hallo Comm,
Ich benutze aktuell die Standard VB Übersetzung Funktion mit
Und kann auch die Sprache ohne Probleme nach einen Neustart ändern indem ich MyApplication angepasst habe
Spoiler anzeigen
Meine Frage ist jetzt, kann ich auch die Sprache zur Laufzeit so ändern das ich das Programm nicht neu starten muss?
LG Ruerte
Ich benutze aktuell die Standard VB Übersetzung Funktion mit
Localizable = True
Und kann auch die Sprache ohne Probleme nach einen Neustart ändern indem ich MyApplication angepasst habe
VB.NET-Quellcode
- Dim ApplicationPath As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\TestApp"
- Dim ConfigurationFile As String = "config.json"
- ' Override Application.Designer.vb
- Protected Overrides Sub OnCreateMainForm()
- SetLanguage()
- Me.MainForm = Global.TestApp.MainForm
- End Sub
- ' Defines the program language
- Public Sub SetLanguage()
- Dim json As String = My.Computer.FileSystem.ReadAllText(String.Format("{0}\{1}", ApplicationPath, ConfigurationFile))
- ' Javascript serializer
- Dim jsonSerializer As New System.Web.Script.Serialization.JavaScriptSerializer
- ' Generically convert to json dictionary
- Dim dict1 As Dictionary(Of String, Object) = jsonSerializer.Deserialize(Of Dictionary(Of String, Object))(json)
- ' get system language
- Dim SysLanguageID As String = System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName
- Dim AppLanguageID As String
- AppLanguageID = CStr(dict1("language"))
- ' select shown language
- Dim Culture As System.Globalization.CultureInfo
- Try
- Culture = New System.Globalization.CultureInfo(AppLanguageID)
- If Culture Is Nothing Then
- AppLanguageID = "en"
- Culture = New System.Globalization.CultureInfo(AppLanguageID)
- End If
- Catch ex As Exception
- MessageBox.Show(String.Format("The selected language code '{0}' is invalid", AppLanguageID))
- AppLanguageID = "en"
- Culture = New System.Globalization.CultureInfo(SysLanguageID)
- End Try
- ' set shown language
- System.Threading.Thread.CurrentThread.CurrentUICulture = Culture
- End Sub
Meine Frage ist jetzt, kann ich auch die Sprache zur Laufzeit so ändern das ich das Programm nicht neu starten muss?
LG Ruerte
Unfortunately, this Signature is not available in Germany because it may contain music for which GEMA
has not granted the respective music rights. Sorry about that.
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Ruerte“ ()