Skip to content

Commit c06a184

Browse files
committed
Update locales.
1 parent 97bea42 commit c06a184

File tree

15 files changed

+73
-63
lines changed

15 files changed

+73
-63
lines changed

VoiceCraft.Client/VoiceCraft.Client.Linux/NativeBackgroundService.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using VoiceCraft.Client.Services;
66
using VoiceCraft.Core;
77
using VoiceCraft.Core.Interfaces;
8+
using VoiceCraft.Core.Locales;
89

910
namespace VoiceCraft.Client.Linux;
1011

@@ -19,15 +20,13 @@ public override async Task StartBackgroundProcess<T>(T process, int timeout = 50
1920
{
2021
var processType = typeof(T);
2122
if (_processes.ContainsKey(processType))
22-
//TODO Locale This!
2323
throw new InvalidOperationException("A background process of this type has already been queued/started!");
2424

2525
var backgroundProcess = new BackgroundProcess(process);
2626
_processes.TryAdd(processType, backgroundProcess);
2727
if (!StartBackgroundWorker())
2828
{
2929
_processes.Clear();
30-
//TODO Locale This!
3130
throw new Exception("Failed to start background process! Background worker failed to start!");
3231
}
3332

@@ -38,7 +37,6 @@ public override async Task StartBackgroundProcess<T>(T process, int timeout = 50
3837
{
3938
_processes.TryRemove(processType, out _);
4039
backgroundProcess.Dispose();
41-
//TODO Locale This!
4240
throw new Exception("Failed to start background process!");
4341
}
4442

@@ -101,8 +99,7 @@ private async Task BackgroundLogic()
10199
}
102100
catch (Exception ex)
103101
{
104-
//TODO Locale This!
105-
notificationService.SendErrorNotification($"Background Error: {ex}");
102+
notificationService.SendErrorNotification(Localizer.Get($"BackgroundService.BackgroundError:{ex.Message}"));
106103
}
107104
}
108105
}

VoiceCraft.Client/VoiceCraft.Client/Locales/en-US.json

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
{
2+
"BackgroundService": {
3+
"BackgroundError": "Background Error: {0}"
4+
},
25
"Notification": {
3-
"Badges": {
4-
"Servers": "Servers",
5-
"Error": "Error",
6-
"GC": "GC",
7-
"VoiceCraft": "VoiceCraft",
8-
"CrashLogs": "CrashLogs"
6+
"VoiceCraft": {
7+
"Badge": "VoiceCraft"
8+
},
9+
"Servers": {
10+
"Badge": "Servers",
11+
"Added": "{0} has been added.",
12+
"Edited": "{0} has been edited.",
13+
"Removed": "{0} has been removed."
14+
},
15+
"GC": {
16+
"Badge": "GC",
17+
"Triggered": "Garbage Collection Triggered. Memory Cleared: {0}mb."
18+
},
19+
"CrashLogs": {
20+
"Badge": "CrashLogs",
21+
"Cleared": "Successfully cleared all logs."
22+
},
23+
"Error": {
24+
"Badge": "Error",
25+
"VoipFailedToStart": "Background worker failed to start VOIP process!",
26+
"VoipBackgroundError": "Voip Background Error: {0}"
927
}
1028
},
1129
"Home": {

VoiceCraft.Client/VoiceCraft.Client/Models/Settings/ServersSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public string Name
8282
set
8383
{
8484
if (value.Length > NameLimit)
85-
throw new ArgumentException("Name cannot be longer than {NameLimit} characters!");
85+
throw new ArgumentException($"Name cannot be longer than {NameLimit} characters!");
8686
_name = value;
8787
OnUpdated?.Invoke(this);
8888
}
@@ -94,7 +94,7 @@ public string Ip
9494
set
9595
{
9696
if (value.Length > IpLimit)
97-
throw new ArgumentException("IP address cannot be longer than {IPLimit} characters!");
97+
throw new ArgumentException($"IP address cannot be longer than {IpLimit} characters!");
9898
_ip = value;
9999
OnUpdated?.Invoke(this);
100100
}

VoiceCraft.Client/VoiceCraft.Client/Processes/VoipBackgroundProcess.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ public void Start(CancellationToken token)
129129
Thread.Sleep(1); //Don't burn the CPU.
130130
}
131131

132-
_ = _voiceCraftClient.ConnectAsync(settingsService.UserGuid, settingsService.ServerUserGuid, ip, port, locale);
132+
_ = _voiceCraftClient.ConnectAsync(settingsService.UserGuid, settingsService.ServerUserGuid, ip, port,
133+
locale);
133134
Title = "VoiceCraft.Status.Connecting";
134135

135136
var startTime = DateTime.UtcNow;
@@ -151,8 +152,8 @@ public void Start(CancellationToken token)
151152
}
152153
catch (Exception ex)
153154
{
154-
//TODO Locale This!
155-
notificationService.SendErrorNotification($"Voip Background Error: {ex.Message}");
155+
notificationService.SendErrorNotification(
156+
Localizer.Get($"Notification.Error.VoipBackgroundError:{ex.Message}"));
156157
_disconnectReason = "VoiceCraft.DisconnectReason.Error";
157158
throw;
158159
}
@@ -163,7 +164,7 @@ public void Start(CancellationToken token)
163164
var localeReason = Localizer.Get($"VoiceCraft.Status.Disconnected:{_disconnectReason}");
164165
Title = localeReason;
165166
Description = localeReason;
166-
notificationService.SendNotification(localeReason, Localizer.Get("Notification.Badges.VoiceCraft"));
167+
notificationService.SendNotification(localeReason, Localizer.Get("Notification.VoiceCraft.Badge"));
167168

168169
if (_audioRecorder != null)
169170
{

VoiceCraft.Client/VoiceCraft.Client/Services/NotificationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void SendErrorNotification(string message)
3333
if (settingsService.NotificationSettings.DisableNotifications) return;
3434
MessageManager.Default.ShowErrorMessage(message, new MessageOptions()
3535
{
36-
Title = Localizer.Get("Notification.Badges.Error"),
36+
Title = Localizer.Get("Notification.Error.Badge"),
3737
Duration = TimeSpan.FromMilliseconds(settingsService.NotificationSettings.DismissDelayMs)
3838
});
3939
}

VoiceCraft.Client/VoiceCraft.Client/ViewModels/AddServerViewModel.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ private void AddServer()
2828
try
2929
{
3030
Servers.AddServer(Server);
31-
32-
//TODO Locale This!
33-
notificationService.SendSuccessNotification($"{Server.Name} has been added.",
34-
Localizer.Get("Notification.Badges.Servers"));
31+
notificationService.SendSuccessNotification(Localizer.Get($"Notification.Servers.Added:{Server.Name}"),
32+
Localizer.Get("Notification.Servers.Badge"));
3533
Server = new Server();
3634
_ = settings.SaveAsync();
3735
navigationService.Back();

VoiceCraft.Client/VoiceCraft.Client/ViewModels/EditServerViewModel.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ private void EditServer()
3838
Server.Name = EditableServer.Name;
3939
Server.Ip = EditableServer.Ip;
4040
Server.Port = EditableServer.Port;
41-
42-
//TODO Locale This!
43-
notificationService.SendNotification($"{Server.Name} has been edited.",
44-
Localizer.Get("Notification.Badges.Servers"));
41+
42+
notificationService.SendNotification(Localizer.Get($"Notification.Servers.Edited:${Server.Name}"),
43+
Localizer.Get("Notification.Servers.Badge"));
4544
EditableServer = new Server();
4645
_ = settings.SaveAsync();
4746
navigationService.Back();

VoiceCraft.Client/VoiceCraft.Client/ViewModels/Home/CrashLogViewModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ private void ClearLogs()
1919
{
2020
LogService.ClearCrashLogs();
2121
CrashLogs.Clear();
22-
//TODO Locale This!
23-
notificationService.SendSuccessNotification("Successfully cleared all logs.",
24-
Localizer.Get("Notification.Badges.CrashLogs"));
22+
notificationService.SendSuccessNotification(Localizer.Get("Notification.CrashLogs.Cleared"),
23+
Localizer.Get("Notification.CrashLogs.Badge"));
2524
}
2625
catch (Exception ex)
2726
{

VoiceCraft.Client/VoiceCraft.Client/ViewModels/Home/ServersViewModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ private void AddServer()
4141
private void DeleteServer(ServerViewModel server)
4242
{
4343
ServersSettings.ServersSettings.RemoveServer(server.Server);
44-
//TODO Locale This!
45-
notificationService.SendSuccessNotification($"{server.Name} has been removed.",
46-
Localizer.Get("Notification_Badges_Servers"));
44+
notificationService.SendSuccessNotification(Localizer.Get($"Notification.Servers.Badge:{server.Name}"),
45+
Localizer.Get("Notification.Servers.Badge"));
4746
_ = settings.SaveAsync();
4847
}
4948

VoiceCraft.Client/VoiceCraft.Client/ViewModels/SelectedServerViewModel.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ private async Task Connect()
102102
}
103103
catch (Exception ex)
104104
{
105-
//TODO Locale This!
106-
notificationService.SendErrorNotification(
107-
"Background worker failed to start VOIP process!");
105+
notificationService.SendErrorNotification(Localizer.Get("Notification.Error.VoipFailedToStart"));
108106
_ = backgroundService.StopBackgroundProcess<VoipBackgroundProcess>(); //Don't care if it fails.
109107
LogService.Log(ex);
110108
}
@@ -124,9 +122,9 @@ private void DeleteServer()
124122
{
125123
if (SelectedServer == null) return;
126124
ServersSettings.ServersSettings.RemoveServer(SelectedServer.Server);
127-
//TODO Locale This!
128-
notificationService.SendSuccessNotification($"{SelectedServer.Name} has been removed.",
129-
Localizer.Get("Notification.Badges.Servers"));
125+
notificationService.SendSuccessNotification(
126+
Localizer.Get($"Notification.Servers.Removed:{SelectedServer.Name}"),
127+
Localizer.Get("Notification.Servers.Badge"));
130128
_ = settingsService.SaveAsync();
131129
navigationService.Back();
132130
}

0 commit comments

Comments
 (0)