ClipboardWatcher: Translate frmMatch

This commit is contained in:
Jonathan Jenne
2021-06-07 15:08:50 +02:00
parent e36013d730
commit c411730b6c
8 changed files with 604 additions and 62 deletions

View File

@@ -8,6 +8,8 @@ Imports DigitalData.Modules.Language
Imports DigitalData.Modules.ZooFlow
Imports DigitalData.Modules.ZooFlow.Params
Imports DigitalData.Modules
Imports System.Threading
Imports System.Globalization
''' <summary>
'''
@@ -29,6 +31,7 @@ Public Class frmMatch
Private _Logger As Logger
Private _Environment As Environment
Private _Params As ClipboardWatcherParams
Private _Language As String
Private PrimaryFont As New Font("Segoe UI", 12, FontStyle.Bold)
Private SecondaryFont As New Font("Segoe UI", 10)
@@ -56,14 +59,54 @@ Public Class frmMatch
_Logger = LogConfig.GetLogger()
_Environment = Environment
_Params = Params
_Language = Language.Utils.NotNull(_Environment.User.Language, State.UserState.LANG_EN_US)
Thread.CurrentThread.CurrentUICulture = New CultureInfo(_Language)
End Sub
Private Function GetResultString(CreatedTiles, MatchedProfiles, ClipboardContents) As String
Dim oResultString = IIf(CreatedTiles = 1, "wurde ein Ergebnis", $"wurden {CreatedTiles} Ergebnisse")
Dim oProfileString = IIf(MatchedProfiles = 1, "einem Profil", $"{MatchedProfiles} Profilen")
Dim oBase = "Es {0} in {1} für Ihre Suche nach '{2}' gefunden:"
Dim oLanguage = Language.Utils.NotNull(_Environment.User.Language, State.UserState.LANG_EN_US)
Return String.Format(oBase, oResultString, oProfileString, _Params.ClipboardContents)
Select Case _Language
Case State.UserState.LANG_DE_DE
Dim oResultString = IIf(CreatedTiles = 1, "wurde ein Ergebnis", $"wurden {CreatedTiles} Ergebnisse")
Dim oProfileString = IIf(MatchedProfiles = 1, "einem Profil", $"{MatchedProfiles} Profilen")
Dim oBase = "Es {0} in {1} für Ihre Suche nach '{2}' gefunden:"
Return String.Format(oBase, oResultString, oProfileString, _Params.ClipboardContents)
Case Else
Dim oResultString = IIf(CreatedTiles = 1, "One Result was", $"{CreatedTiles} Results were")
Dim oProfileString = IIf(MatchedProfiles = 1, "one Profile", $"{MatchedProfiles} Profiles")
Dim oBase = "{0} found in {1} for your search for '{2}':"
Return String.Format(oBase, oResultString, oProfileString, _Params.ClipboardContents)
End Select
End Function
Private Function GetResultWindowString(ClipboardContents As String) As String
If _Language = State.UserState.LANG_DE_DE Then
Return $"Suche Nach '{_Params.ClipboardContents}'"
Else
Return $"Search For '{_Params.ClipboardContents}'"
End If
End Function
Private Function GetTileString(Profile As ProfileData, [Type] As ProfileType) As String
If _Language = State.UserState.LANG_DE_DE Then
If [Type] = ProfileType.DATA_ONLY Then
Return $"{Profile.CountData} Datensätze"
Else
Return $"{Profile.CountDocs} Dateien"
End If
End If
If [Type] = ProfileType.DATA_ONLY Then
Return $"{Profile.CountData} Data Records"
Else
Return $"{Profile.CountDocs} Files"
End If
End Function
Private Async Sub frmMatch_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@@ -150,7 +193,7 @@ Public Class frmMatch
_Logger.Debug("ProfileType: DOCS_ONLY or ANY")
If oProfile.CountDocs > 0 Then
Dim oItem = CreateTile(oProfile, $"{oProfile.CountDocs} Dateien")
Dim oItem = CreateTile(oProfile, GetTileString(oProfile, ProfileType.DOCS_ONLY))
oDocumentGroup.Items.Add(oItem)
oCreatedTiles += 1
oProfileMatch = True
@@ -165,7 +208,7 @@ Public Class frmMatch
_Logger.Debug("ProfileType: DATA_ONLY or ANY")
If oProfile.CountData > 0 Then
Dim oItem = CreateTile(oProfile, $"{oProfile.CountData} Datensätze")
Dim oItem = CreateTile(oProfile, GetTileString(oProfile, ProfileType.DATA_ONLY))
oDataGroup.Items.Add(oItem)
oCreatedTiles += 1
oProfileMatch = True
@@ -296,7 +339,7 @@ Public Class frmMatch
Dim oWindowGuid = $"{Profile.Guid}-{oNameSlug}-{String.Join("-", oSearchGuids)}"
Dim oParams = New DocumentResultParams() With {
.WindowGuid = oWindowGuid,
.WindowTitle = $"Suche Nach '{_Params.ClipboardContents}'"
.WindowTitle = GetResultWindowString(_Params.ClipboardContents)
}
For Each oSearch In Searches