Skip to content

Commit 9c7e576

Browse files
committed
Added missing localization strings
1 parent f1b402c commit 9c7e576

19 files changed

+194
-65
lines changed

SecureFolderFS.AvaloniaUI/ValueConverters/VaultHealthStateToStringConverter.cs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
using System;
2-
using System.Globalization;
3-
using Avalonia.Data.Converters;
1+
using Avalonia.Data.Converters;
42
using SecureFolderFS.Sdk.Enums;
3+
using SecureFolderFS.Sdk.Extensions;
4+
using System;
5+
using System.Globalization;
56

67
namespace SecureFolderFS.AvaloniaUI.ValueConverters
78
{
@@ -17,9 +18,9 @@ internal sealed class VaultHealthStateToStringConverter : IValueConverter
1718
// TODO: Localize
1819
return vaultHealthState switch
1920
{
20-
VaultHealthState.Healthy => "No problems found",
21-
VaultHealthState.NeedsAttention => "Needs attention",
22-
VaultHealthState.Error => "Problems found",
21+
VaultHealthState.Healthy => "HealthNoProblems".ToLocalized(),
22+
VaultHealthState.NeedsAttention => "HealthAttention".ToLocalized(),
23+
VaultHealthState.Error => "HealthProblems".ToLocalized(),
2324
_ => throw new ArgumentOutOfRangeException(nameof(vaultHealthState))
2425
};
2526
}

SecureFolderFS.Sdk/ViewModels/Controls/Banners/UpdateBannerViewModel.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System;
1010
using System.Threading;
1111
using System.Threading.Tasks;
12+
using SecureFolderFS.Sdk.Extensions;
1213

1314
namespace SecureFolderFS.Sdk.ViewModels.Controls.Banners
1415
{
@@ -30,7 +31,7 @@ public DateTime LastChecked
3031

3132
public UpdateBannerViewModel()
3233
{
33-
_UpdateText = "Latest version installed";
34+
_UpdateText = "LatestVersionInstalled".ToLocalized();
3435
UpdateService.StateChanged += UpdateService_StateChanged;
3536
}
3637

@@ -52,9 +53,9 @@ public void Report(double value)
5253
var rounded = (int)Math.Round(value);
5354

5455
if (rounded == 100)
55-
UpdateText = "Installing...";
56+
UpdateText = "Installing".ToLocalized();
5657
else
57-
UpdateText = $"Downloading {rounded}%";
58+
UpdateText = string.Format("Downloading".ToLocalized(), rounded);
5859
}
5960

6061
private void UpdateService_StateChanged(object? sender, EventArgs e)
@@ -64,7 +65,7 @@ private void UpdateService_StateChanged(object? sender, EventArgs e)
6465
return;
6566

6667
InfoBarViewModel.IsOpen = true;
67-
InfoBarViewModel.Title = "Error";
68+
InfoBarViewModel.Title = "Error".ToLocalized();
6869
InfoBarViewModel.CanBeClosed = true;
6970
InfoBarViewModel.Message = GetMessageForUpdateState(args.UpdateState);
7071
InfoBarViewModel.InfoBarSeverity = InfoBarSeverityType.Error;
@@ -87,7 +88,7 @@ private async Task UpdateAppAsync(CancellationToken cancellationToken)
8788
if (!result.Successful)
8889
{
8990
InfoBarViewModel.IsOpen = true;
90-
InfoBarViewModel.Title = "Error";
91+
InfoBarViewModel.Title = "Error".ToLocalized();
9192
InfoBarViewModel.CanBeClosed = true;
9293
InfoBarViewModel.Message = result.GetMessage();
9394
InfoBarViewModel.InfoBarSeverity = InfoBarSeverityType.Error;

SecureFolderFS.Sdk/ViewModels/Views/Settings/GeneralSettingsViewModel.cs

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
using CommunityToolkit.Mvvm.DependencyInjection;
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
23
using SecureFolderFS.Sdk.Services;
34
using SecureFolderFS.Sdk.ViewModels.Controls;
45
using SecureFolderFS.Sdk.ViewModels.Controls.Banners;
56
using System.Collections.ObjectModel;
7+
using System.Linq;
68
using System.Threading;
79
using System.Threading.Tasks;
810

911
namespace SecureFolderFS.Sdk.ViewModels.Views.Settings
1012
{
11-
public sealed class GeneralSettingsViewModel : BasePageViewModel
13+
public sealed partial class GeneralSettingsViewModel : BasePageViewModel
1214
{
1315
public ILocalizationService LocalizationService { get; } = Ioc.Default.GetRequiredService<ILocalizationService>();
1416

1517
public UpdateBannerViewModel BannerViewModel { get; }
1618

1719
public ObservableCollection<LanguageViewModel> Languages { get; }
1820

21+
[ObservableProperty] private LanguageViewModel? _SelectedLanguage;
22+
1923
public GeneralSettingsViewModel()
2024
{
2125
BannerViewModel = new();
@@ -28,7 +32,17 @@ public override async Task InitAsync(CancellationToken cancellationToken = defau
2832
foreach (var item in LocalizationService.AppLanguages)
2933
Languages.Add(new(item));
3034

35+
// Set selected language
36+
SelectedLanguage = Languages.FirstOrDefault(x => x.CultureInfo.Equals(LocalizationService.CurrentCulture));
37+
38+
// Initialize the banner
3139
await BannerViewModel.InitAsync(cancellationToken);
3240
}
41+
42+
async partial void OnSelectedLanguageChanged(LanguageViewModel? value)
43+
{
44+
if (value is not null)
45+
await LocalizationService.SetCultureAsync(value.CultureInfo);
46+
}
3347
}
3448
}

SecureFolderFS.UI/ValueConverters/BaseBoolToStringConverter.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
using CommunityToolkit.Mvvm.DependencyInjection;
2-
using SecureFolderFS.Sdk.Services;
1+
using SecureFolderFS.Sdk.Extensions;
32
using System;
43

54
namespace SecureFolderFS.UI.ValueConverters
65
{
76
public abstract class BaseBoolToStringConverter : BaseConverter
87
{
9-
private static ILocalizationService LocalizationService { get; } = Ioc.Default.GetRequiredService<ILocalizationService>();
10-
118
/// <inheritdoc/>
129
protected override object? TryConvert(object? value, Type targetType, object? parameter)
1310
{
@@ -24,7 +21,7 @@ public abstract class BaseBoolToStringConverter : BaseConverter
2421
var valueSplit = formatString.Split(':');
2522
var splitOption = bValue ? valueSplit[3].Split('|') : valueSplit[1].Split('|');
2623

27-
return splitOption[0] == "LOCALIZE" ? LocalizationService.GetString(splitOption[1]) : splitOption[1];
24+
return splitOption[0] == "LOCALIZE" ? splitOption[1].ToLocalized() : splitOption[1];
2825
}
2926

3027
/// <inheritdoc/>

SecureFolderFS.UI/ValueConverters/BaseDateTimeToStringConverter.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using SecureFolderFS.Sdk.Extensions;
2+
using System;
23

34
namespace SecureFolderFS.UI.ValueConverters
45
{
@@ -20,7 +21,7 @@ public abstract class BaseDateTimeToStringConverter : BaseConverter
2021
{
2122
var split = formatString.Split('|');
2223
if (split[0] == "LOCALIZE")
23-
return string.Format(split[1], dateString); // TODO: Localize
24+
return string.Format(split[1].ToLocalized(), dateString); // TODO: Localize
2425
else
2526
return string.Format(split[1], dateString);
2627
}

SecureFolderFS.WinUI/Dialogs/SettingsDialog.xaml

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:h="using:SecureFolderFS.WinUI.Helpers"
7+
xmlns:l="using:SecureFolderFS.WinUI.Localization"
78
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
89
xmlns:uc="using:SecureFolderFS.WinUI.UserControls.Navigation"
910
Closing="SettingsDialog_Closing"
@@ -30,8 +31,8 @@
3031

3132
<!-- General -->
3233
<NavigationViewItem
33-
AutomationProperties.Name="General"
34-
Content="General"
34+
AutomationProperties.Name="{l:ResourceString Name=SettingsGeneral}"
35+
Content="{l:ResourceString Name=SettingsGeneral}"
3536
IsSelected="True"
3637
Tag="0">
3738
<NavigationViewItem.Icon>
@@ -41,8 +42,8 @@
4142

4243
<!-- Preferences -->
4344
<NavigationViewItem
44-
AutomationProperties.Name="Preferences"
45-
Content="Preferences"
45+
AutomationProperties.Name="{l:ResourceString Name=SettingsPreferences}"
46+
Content="{l:ResourceString Name=SettingsPreferences}"
4647
Tag="1">
4748
<NavigationViewItem.Icon>
4849
<FontIcon Glyph="&#xE90F;" />
@@ -51,8 +52,8 @@
5152

5253
<!-- Privacy -->
5354
<NavigationViewItem
54-
AutomationProperties.Name="Privacy"
55-
Content="Privacy"
55+
AutomationProperties.Name="{l:ResourceString Name=SettingsPrivacy}"
56+
Content="{l:ResourceString Name=SettingsPrivacy}"
5657
Tag="2">
5758
<NavigationViewItem.Icon>
5859
<FontIcon Glyph="&#xEA18;" />
@@ -62,7 +63,8 @@
6263
<!-- About -->
6364
<NavigationViewItem
6465
Margin="0,0,45,0"
65-
Content="About"
66+
AutomationProperties.Name="{l:ResourceString Name=SettingsAbout}"
67+
Content="{l:ResourceString Name=SettingsAbout}"
6668
Tag="3">
6769
<NavigationViewItem.Icon>
6870
<FontIcon Glyph="&#xE946;" />
@@ -90,5 +92,4 @@
9092
<FontIcon FontSize="10" Glyph="&#xE8BB;" />
9193
</Button>
9294
</Grid>
93-
9495
</ContentDialog>

0 commit comments

Comments
 (0)