Added a GetCurrentScreen function for better formatting

This commit is contained in:
Daniel S. Billing 2021-04-19 22:23:06 +02:00
parent 0d03708042
commit 85e1402d0a

View File

@ -94,9 +94,9 @@ Public Class Localization
End Sub
Public Shared Function Translate(ByVal s As String, Optional ByVal DefaultValue As String = "") As String
Dim resultToken As Token = Nothing
Dim CurrentScreen As String = Core.CurrentScreen.ToString.ToLower()
s = s.ToLower().Replace(" ", "_").Replace("'", "").Replace("p3d.", "") ' Lets format the string before finding it
Dim NewTokenName As String = CurrentScreen.Replace("p3d.", "") & "." & s
Dim CurrentScreen As String = GetCurrentScreen()
s = s.ToLower().Replace(" ", "_").Replace("'", "").Replace("p3d.", "").Replace("._", "_") ' Lets format the string before finding it
Dim NewTokenName As String = CurrentScreen & "." & s
If s.Contains(".") = False Then
'Logger.Debug("Localization.vb: s.Contains: " & s)
s = NewTokenName
@ -133,6 +133,14 @@ Public Class Localization
Return LocalizationTokens.ContainsKey(TokenName)
End Function
Public Shared Function GetCurrentScreen() As String
Dim CurrentScreen As String = Core.CurrentScreen.ToString.ToLower()
If CurrentScreen.Contains("+") Then
CurrentScreen = CurrentScreen.Split("+").Last.ToString
End If
Return CurrentScreen.Replace("p3d.", "")
End Function
Public Shared Function GetAvailableLanguagesList() As Dictionary(Of Integer, String)
Dim FullPath As String = GameController.GamePath & GameMode.DefaultLocalizationsPath
Dim AvailableLanguages As New Dictionary(Of Integer, String)