Idk, dev work goin on

This commit is contained in:
2026-09-09 16:19:45 +03:00 Unverified
parent b0d8bcd742
commit 17a0a9f7a6
318 changed files with 11908 additions and 81 deletions
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Markup;
using Microsoft.Windows.AI.Text;
using WinWARP.Core.Services.Interfaces;
using WinWARP.Ui.Helpers;
namespace WinWARP.Ui.Converters;
[MarkupExtensionReturnType(ReturnType = typeof(IValueConverter))]
public class UpdateIntervalToTextConverter : MarkupExtension, IValueConverter
{
private ILocalizationService _localizationService;
protected override object ProvideValue()
{
_localizationService ??= App.Services.GetRequiredService<ILocalizationService>();
return this;
}
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is double interval)
{
interval = Math.Truncate(interval);
return interval switch
{
-1 => _localizationService.GetString("UpdateInterval_never"),
0 => _localizationService.GetString("UpdateInterval_auto"),
_ => NumberToTranslatedString(interval)
};
}
return "Unknown";
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
private string NumberToTranslatedString(double value)
{
var category = PluralCategory.GetCategory(value, new CultureInfo(_localizationService.GetCurrentLanguage()));
var resourceKey = $"UpdateInterval_{category}";
var localizedTemplate = _localizationService.GetString(resourceKey);
if (string.IsNullOrEmpty(localizedTemplate))
{
// Fallback to a default template if the localized string is not found
localizedTemplate = "Every {0} hours";
}
return string.Format(localizedTemplate, value);
}
}