Skip to content

Commit 53ba804

Browse files
committed
feat: improve ui
1 parent 5475fcf commit 53ba804

6 files changed

Lines changed: 77 additions & 27 deletions

File tree

src/ByteSync.Client/Assets/Resources/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ByteSync.Client/Assets/Resources/Resources.fr.resx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,4 +1637,11 @@ Voulez-vous enregistrer ce nouveau Profil de Session avec ce nom ?</value>
16371637
<data name="TargetedActionEditionGlobal_AffectedItemsTooltip" xml:space="preserve">
16381638
<value>Éléments affectés :</value>
16391639
</data>
1640+
<!-- Item count localization for pluralization -->
1641+
<data name="ValidationFailure_ItemSingular" xml:space="preserve">
1642+
<value>élément :</value>
1643+
</data>
1644+
<data name="ValidationFailure_ItemPlural" xml:space="preserve">
1645+
<value>éléments :</value>
1646+
</data>
16401647
</root>

src/ByteSync.Client/Assets/Resources/Resources.resx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,4 +1664,11 @@ Do you want to save this new Session Profile with this name?</value>
16641664
<data name="TargetedActionEditionGlobal_AffectedItemsTooltip" xml:space="preserve">
16651665
<value>Affected items:</value>
16661666
</data>
1667+
<!-- Item count localization for pluralization -->
1668+
<data name="ValidationFailure_ItemSingular" xml:space="preserve">
1669+
<value>item:</value>
1670+
</data>
1671+
<data name="ValidationFailure_ItemPlural" xml:space="preserve">
1672+
<value>items:</value>
1673+
</data>
16671674
</root>

src/ByteSync.Client/Services/Converters/IntToBoolConverter.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Avalonia.Controls;
2+
using Avalonia.Data.Converters;
3+
using Autofac;
4+
using ByteSync.Interfaces;
5+
using System.Globalization;
6+
7+
namespace ByteSync.Services.Converters;
8+
9+
public class ItemCountToLocalizedTextConverter : IValueConverter
10+
{
11+
private readonly ILocalizationService _localizationService;
12+
13+
public ItemCountToLocalizedTextConverter()
14+
{
15+
if (!Design.IsDesignMode)
16+
{
17+
_localizationService = ContainerProvider.Container.Resolve<ILocalizationService>();
18+
}
19+
}
20+
21+
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
22+
{
23+
if (Design.IsDesignMode)
24+
{
25+
return "item:";
26+
}
27+
28+
if (value is not int count)
29+
{
30+
// Fallback to singular form for invalid input
31+
return _localizationService["ValidationFailure_ItemSingular"];
32+
}
33+
34+
var key = count <= 1 ? "ValidationFailure_ItemSingular" : "ValidationFailure_ItemPlural";
35+
return _localizationService[key];
36+
}
37+
38+
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
39+
{
40+
throw new NotImplementedException();
41+
}
42+
}

src/ByteSync.Client/Views/Sessions/Comparisons/Actions/TargetedActionGlobalView.axaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</Design.DataContext>
1818

1919
<UserControl.Resources>
20-
<converters:IntToBoolConverter x:Key="IntToBoolConverter"/>
20+
<converters:ItemCountToLocalizedTextConverter x:Key="ItemCountToLocalizedTextConverter"/>
2121
</UserControl.Resources>
2222

2323
<Grid Background="{DynamicResource Gray7}">
@@ -104,9 +104,8 @@
104104
<StackPanel Orientation="Horizontal">
105105
<TextBlock Text="" Margin="0,0,6,0" />
106106
<TextBlock Text="{Binding Count}" FontWeight="SemiBold" />
107-
<TextBlock Text=" item" Margin="0,0,2,0" />
108-
<TextBlock Text="s" IsVisible="{Binding Count, Converter={StaticResource IntToBoolConverter}}" />
109-
<TextBlock Text=": " />
107+
<TextBlock Text=" " />
108+
<TextBlock Text="{Binding Count, Converter={StaticResource ItemCountToLocalizedTextConverter}}" Margin="0,0,4,0" />
110109
<TextBlock Text="{Binding LocalizedMessage}" />
111110
</StackPanel>
112111
<ToolTip.Tip>

0 commit comments

Comments
 (0)