Skip to content

Commit 0afd917

Browse files
committed
i18n Complete
1 parent aa49e47 commit 0afd917

File tree

15 files changed

+671
-79
lines changed

15 files changed

+671
-79
lines changed

CompactGUI/Application.xaml.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Partial Public Class Application
3232
End Sub
3333

3434
Private Sub Application_Startup(sender As Object, e As StartupEventArgs) Handles Me.Startup
35-
' 启动时调用语言配置
35+
' Call the language configuration at startup
3636
LanguageHelper.Initialize()
3737

3838
End Sub

CompactGUI/Components/Converters/IValueConverters.vb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Public Class RelativeDateConverter : Implements IValueConverter
102102
ElseIf ts > TimeSpan.FromMinutes(2) Then
103103
Return String.Format(LanguageHelper.GetString("Time_MinutesAgo"), ts.TotalMinutes)
104104
Else
105-
Return LanguageHelper.GetString("Time_Now")
105+
Return LanguageHelper.GetString("RelativeTimeJustNow")
106106
End If
107107
End Function
108108

@@ -291,15 +291,15 @@ Public Class FolderStatusToStringConverter : Implements IValueConverter
291291
Dim status = CType(value, ActionState)
292292
Select Case status
293293
Case ActionState.Idle
294-
Return "Awaiting Compression"
294+
Return LanguageHelper.GetString("Status_AwaitingCompression")
295295
Case ActionState.Analysing
296-
Return "Analysing"
296+
Return LanguageHelper.GetString("Status_Analysing")
297297
Case ActionState.Working, ActionState.Paused
298-
Return "Working"
298+
Return LanguageHelper.GetString("Status_Working")
299299
Case ActionState.Results
300-
Return "Compressed"
300+
Return LanguageHelper.GetString("Status_Compressed")
301301
Case Else
302-
Return "Unknown"
302+
Return LanguageHelper.GetString("Status_Unknown")
303303
End Select
304304
End Function
305305
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack

CompactGUI/LanguageHelper.vb

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Imports System.Windows.Data
66
Imports System.Reflection
77

88
Public Class LanguageHelper
9-
' 支持的语言列表
9+
' Supported language list
1010
' @i18n
1111
Private Shared ReadOnly SupportedCultures As String() = {"en-US", "zh-CN"}
1212
Private Shared resourceManager As ResourceManager = i18n.i18n.ResourceManager
@@ -49,7 +49,7 @@ Public Class LanguageHelper
4949
Return rawValue
5050
End If
5151
Catch ex As Exception
52-
Debug.WriteLine($"获取多语言文本失败:{key},错误:{ex.Message}")
52+
Debug.WriteLine($"Failed to get multilingual text:{key},Error:{ex.Message}")
5353
Return key
5454
End Try
5555
End Function
@@ -62,7 +62,7 @@ Public Class LanguageHelper
6262
currentCulture = culture
6363

6464
Catch ex As Exception
65-
Debug.WriteLine($"应用语言失败:{cultureName},错误:{ex.Message}")
65+
Debug.WriteLine($"Application language failure:{cultureName},Error:{ex.Message}")
6666
SetDefaultLanguage()
6767
End Try
6868
End Sub
@@ -79,31 +79,16 @@ Public Class LanguageHelper
7979
End Function
8080

8181
Private Shared Sub SetDefaultLanguage()
82-
' 根据系统语言设置默认语言
82+
' Set the default language according to the system language.
8383
'@i18n
8484
Dim langMapping As New Dictionary(Of String, String) From {
8585
{"en", "en-US"},
8686
{"zh", "zh-CN"}
8787
}
88-
'{"ja", "ja-JP"},
89-
'{"ko", "ko-KR"},
90-
'{"fr", "fr-FR"},
91-
'{"de", "de-DE"},
92-
'{"es", "es-ES"},
93-
'{"ru", "ru-RU"}
9488

9589
Dim systemLang As String = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.ToLower()
9690
Dim defaultLang As String = If(langMapping.ContainsKey(systemLang), langMapping(systemLang), "en-US")
9791

98-
' 特殊处理中文简/繁
99-
'If systemLang = "zh" Then
100-
' If Thread.CurrentThread.CurrentUICulture.Name.StartsWith("zh-TW") Then
101-
' defaultLang = "zh-TW"
102-
' ElseIf Thread.CurrentThread.CurrentUICulture.Name.StartsWith("zh-HK") Then
103-
' defaultLang = "zh-HK"
104-
' End If
105-
'End If
106-
10792
ApplyCulture(defaultLang)
10893
WriteAppConfig("language", defaultLang)
10994
End Sub
@@ -117,7 +102,7 @@ Public Class LanguageHelper
117102
Dim config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None)
118103
Return If(config.AppSettings.Settings(key)?.Value, String.Empty)
119104
Catch ex As Exception
120-
Debug.WriteLine($"读取配置失败:{key},错误:{ex.Message}")
105+
Debug.WriteLine($"Read configuration failed:{key},Error:{ex.Message}")
121106
Return String.Empty
122107
End Try
123108
End Function
@@ -133,7 +118,7 @@ Public Class LanguageHelper
133118
config.Save(System.Configuration.ConfigurationSaveMode.Modified)
134119
System.Configuration.ConfigurationManager.RefreshSection("appSettings")
135120
Catch ex As Exception
136-
Debug.WriteLine($"写入配置失败:{key},错误:{ex.Message}")
121+
Debug.WriteLine($"Write configuration failed:{key},Error:{ex.Message}")
137122
End Try
138123
End Sub
139124
End Class

CompactGUI/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@
259259
FocusOnLeftClick="True" MenuOnRightClick="True" TooltipText="CompactGUI">
260260
<tray:NotifyIcon.Menu>
261261
<ContextMenu x:Name="NotifyIconTrayMenu">
262-
<MenuItem Command="{Binding NotifyIconOpenCommand}" Header="Open" />
263-
<MenuItem Command="{Binding NotifyIconExitCommand}" Header="Exit" />
262+
<MenuItem Command="{Binding NotifyIconOpenCommand}" Header="{local:Localize UniOpen}" />
263+
<MenuItem Command="{Binding NotifyIconExitCommand}" Header="{local:Localize UniExit}" />
264264
</ContextMenu>
265265
</tray:NotifyIcon.Menu>
266266
</tray:NotifyIcon>

CompactGUI/Services/CustomSnackBarService.vb

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Public Class CustomSnackBarService
2020

2121
Public Sub ShowCustom(message As UIElement, title As String, appearance As ControlAppearance, Optional icon As IconElement = Nothing, Optional timeout As TimeSpan = Nothing)
2222

23-
If GetSnackbarPresenter() Is Nothing Then Throw New InvalidOperationException("The SnackbarPresenter was never set")
23+
If GetSnackbarPresenter() Is Nothing Then Throw New InvalidOperationException(LanguageHelper.GetString("SnackBar_SnackbarPresenter")) 'The SnackbarPresenter was never set
2424
If _snackbar Is Nothing Then _snackbar = New Snackbar(GetSnackbarPresenter())
2525

2626
_snackbar.SetCurrentValue(Snackbar.TitleProperty, title)
@@ -52,20 +52,21 @@ Public Class CustomSnackBarService
5252

5353
Public Sub ShowInsufficientPermission(folderName As String)
5454
Dim button = New Button With {
55-
.Content = "Restart as Admin",
55+
.Content = LanguageHelper.GetString("SnackBar_RestartAdmin"), '"Restart as Admin"
5656
.Command = New RelayCommand(Sub() RunAsAdmin(folderName)),
5757
.Margin = New Thickness(-3, 10, 0, 0)
5858
}
59-
ShowCustom(button, "Insufficient permission to access this folder.", ControlAppearance.Danger, timeout:=TimeSpan.FromSeconds(60))
59+
ShowCustom(button, LanguageHelper.GetString("SnackBar_RestartAdminTip"), ControlAppearance.Danger, timeout:=TimeSpan.FromSeconds(60)) '"Insufficient permission to access this folder."
6060
End Sub
6161

6262
Public Sub ShowUpdateAvailable(newVersion As String, isPreRelease As Boolean)
6363
Dim textBlock = New TextBlock
64-
textBlock.Text = "Click to download"
64+
textBlock.Text = LanguageHelper.GetString("SnackBar_UpdateDownload") '"Click to download"
6565

6666
' Show the custom snackbar
6767
SnackbarServiceLog.ShowUpdateAvailable(logger, newVersion, isPreRelease)
68-
ShowCustom(textBlock, $"Update Available ▸ Version {newVersion}", If(isPreRelease, ControlAppearance.Info, ControlAppearance.Success), timeout:=TimeSpan.FromSeconds(10))
68+
Dim title As String = String.Format(LanguageHelper.GetString("SnackBar_UpdateAvailable"), newVersion) 'Update Available ▸ Version {newVersion}
69+
ShowCustom(textBlock, title, If(isPreRelease, ControlAppearance.Info, ControlAppearance.Success), timeout:=TimeSpan.FromSeconds(10))
6970

7071
Dim handler As MouseButtonEventHandler = Nothing
7172
Dim closedHandler As TypedEventHandler(Of Snackbar, RoutedEventArgs) = Nothing
@@ -86,37 +87,49 @@ Public Class CustomSnackBarService
8687
End Sub
8788

8889
Public Sub ShowFailedToSubmitToWiki()
89-
Show("Failed to submit to wiki", "Please check your internet connection and try again", Wpf.Ui.Controls.ControlAppearance.Danger, Nothing, TimeSpan.FromSeconds(5))
90+
Show(LanguageHelper.GetString("SnackBar_SubmitWikiFailed"), LanguageHelper.GetString("SnackBar_SubmitWikiFailedTip"), Wpf.Ui.Controls.ControlAppearance.Danger, Nothing, TimeSpan.FromSeconds(5))
91+
'"Failed to submit to wiki", "Please check your internet connection and try again"
9092
SnackbarServiceLog.ShowFailedToSubmitToWiki(logger)
9193
End Sub
9294

9395
Public Sub ShowSubmittedToWiki(steamsubmitdata As SteamSubmissionData, compressionMode As Integer)
94-
Show("Submitted to wiki", $"UID: {steamsubmitdata.UID}{vbCrLf}Game: {steamsubmitdata.GameName}{vbCrLf}SteamID: {steamsubmitdata.SteamID}{vbCrLf}Compression: {[Enum].GetName(GetType(Core.WOFCompressionAlgorithm), Core.WOFHelper.WOFConvertCompressionLevel(compressionMode))}", Wpf.Ui.Controls.ControlAppearance.Success, Nothing, TimeSpan.FromSeconds(10))
96+
Dim compressionName As String = [Enum].GetName(GetType(Core.WOFCompressionAlgorithm), Core.WOFHelper.WOFConvertCompressionLevel(compressionMode))
97+
Dim message As String = $"{LanguageHelper.GetString("SnackBar_SubmitWiki_UID")}: {steamsubmitdata.UID}{vbCrLf}" &
98+
$"{LanguageHelper.GetString("SnackBar_SubmitWiki_Game")}: {steamsubmitdata.GameName}{vbCrLf}" &
99+
$"{LanguageHelper.GetString("SnackBar_SubmitWiki_SteamID")}: {steamsubmitdata.SteamID}{vbCrLf}" &
100+
$"{LanguageHelper.GetString("SnackBar_SubmitWiki_Compression")}: {compressionName}"
101+
'Show("Submitted to wiki", $"UID: {0}{1}Game: {2}{1}SteamID: {3}{1}Compression: {4}
102+
103+
Show(LanguageHelper.GetString("SnackBar_SubmitWiki"), message, Wpf.Ui.Controls.ControlAppearance.Success, Nothing, TimeSpan.FromSeconds(10))
95104
SnackbarServiceLog.ShowSubmittedToWiki(logger, steamsubmitdata.UID, steamsubmitdata.GameName, steamsubmitdata.SteamID, steamsubmitdata.CompressionMode)
96105
End Sub
97106

98107

99108
Public Sub ShowAppliedToAllFolders()
100-
Show("Applied to all folders", "Compression options have been applied to all folders", Wpf.Ui.Controls.ControlAppearance.Success, Nothing, TimeSpan.FromSeconds(5))
109+
Show(LanguageHelper.GetString("SnackBar_AppliedAllFolders"), LanguageHelper.GetString("SnackBar_AppliedAllFoldersTip"), Wpf.Ui.Controls.ControlAppearance.Success, Nothing, TimeSpan.FromSeconds(5))
110+
'"Applied to all folders", "Compression options have been applied to all folders"
101111
SnackbarServiceLog.ShowAppliedToAllFolders(logger)
102112
End Sub
103113

104114
Public Sub ShowCannotRemoveFolder()
105-
Show("Cannot remove folder", "Please wait until the current operation is finished", Wpf.Ui.Controls.ControlAppearance.Caution, Nothing, TimeSpan.FromSeconds(5))
115+
Show(LanguageHelper.GetString("SnackBar_CannotRemoveFolder"), LanguageHelper.GetString("SnackBar_CannotRemoveFolderTip"), Wpf.Ui.Controls.ControlAppearance.Caution, Nothing, TimeSpan.FromSeconds(5))
116+
'"Cannot remove folder", "Please wait until the current operation is finished"
106117
SnackbarServiceLog.ShowCannotRemoveFolder(logger)
107118
End Sub
108119

109120
Public Sub ShowAddedToQueue()
110-
Show("Success", "Added to Queue", Wpf.Ui.Controls.ControlAppearance.Success, Nothing, TimeSpan.FromSeconds(5))
121+
Show(LanguageHelper.GetString("SnackBar_Success"), LanguageHelper.GetString("SnackBar_SuccessTip"), Wpf.Ui.Controls.ControlAppearance.Success, Nothing, TimeSpan.FromSeconds(5))
122+
'"Success", "Added to Queue"
111123
SnackbarServiceLog.ShowAddedToQueue(logger)
112124
End Sub
113125

114126
Public Sub ShowDirectStorageWarning(displayName As String)
115127
Show(displayName,
116-
"This game uses DirectStorage technology. If you are using this feature, you should not compress this game.",
128+
LanguageHelper.GetString("SnackBar_DirectStorageTechnology"),
117129
Wpf.Ui.Controls.ControlAppearance.Info,
118130
Nothing,
119131
TimeSpan.FromSeconds(20))
132+
'"This game uses DirectStorage technology. If you are using this feature, you should not compress this game.",
120133
SnackbarServiceLog.ShowDirectStorageWarning(logger, displayName)
121134
End Sub
122135
End Class

CompactGUI/Services/WindowService.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Public Class WindowService
3333
.Title = title,
3434
.Content = content,
3535
.IsPrimaryButtonEnabled = True,
36-
.PrimaryButtonText = "Yes",
37-
.CloseButtonText = "Cancel"
36+
.PrimaryButtonText = LanguageHelper.GetString("UniYes"),
37+
.CloseButtonText = LanguageHelper.GetString("UniCancel")
3838
}
3939
Dim result = Await msgBox.ShowDialogAsync()
4040
Return result = Wpf.Ui.Controls.MessageBoxResult.Primary

CompactGUI/ViewModels/FolderViewModel.vb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ Public NotInheritable Class FolderViewModel : Inherits ObservableObject : Implem
5858
Public ReadOnly Property CompressionDisplayLevel As String
5959
Get
6060
If Folder.AnalysisResults Is Nothing OrElse
61-
Not Folder.AnalysisResults.Any(Function(x) x.CompressionMode <> Core.WOFCompressionAlgorithm.NO_COMPRESSION) Then
62-
Return "Not Compressed"
61+
Not Folder.AnalysisResults.Any(Function(x) x.CompressionMode <> Core.WOFCompressionAlgorithm.NO_COMPRESSION) Then
62+
Return LanguageHelper.GetString("Status_NotCompressed") 'Not Compressed
6363
End If
64-
Return "Compressed"
64+
Return LanguageHelper.GetString("Status_Compressed") 'Compressed
6565
End Get
6666
End Property
6767

CompactGUI/ViewModels/MainWindowViewModel.vb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Partial Public Class MainWindowViewModel : Inherits ObservableRecipient : Implem
3939
<RelayCommand>
4040
Private Async Function NotifyIconExit() As Task
4141
If _watcher.WatchedFolders.Count = 0 Then Application.Current.Shutdown()
42-
Dim confirmed = Await _windowService.ShowMessageBox("CompactGUI", $"You currently have {_watcher.WatchedFolders.Count} folders being watched. Closing CompactGUI will stop them from being monitored.{Environment.NewLine}{Environment.NewLine}Are you sure you want to exit?")
42+
Dim message As String = String.Format(LanguageHelper.GetString("MessageBox_ExitText"), _watcher.WatchedFolders.Count)
43+
Dim confirmed = Await _windowService.ShowMessageBox(LanguageHelper.GetString("Title_CompactGUI"), message)
4344
If Not confirmed Then Return
4445
_watcher.WriteToFile()
4546
Application.Current.Shutdown()

CompactGUI/Views/Components/CompressionMode_Radio.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<ui:TextBlock x:Name="Mode_Text"
3434
Text="{Binding CompressionMode, FallbackValue=XPRESS4K, RelativeSource={RelativeSource TemplatedParent}}"
3535
HorizontalAlignment="Left" VerticalAlignment="Center"
36-
FontSize="15" FontWeight="SemiBold">
36+
FontSize="14" FontWeight="SemiBold">
3737
<ui:TextBlock.RenderTransform>
3838
<TranslateTransform x:Name="ModeTextTransform" Y="0" />
3939
</ui:TextBlock.RenderTransform>

0 commit comments

Comments
 (0)