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
+30
View File
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Jeffijoe.MessageFormat;
namespace WinWARP.Ui.Helpers;
/// <summary>
/// Provides methods to determine the plural category of a number based on the specified locale and whether it is an ordinal or cardinal number.
/// </summary>
public static class PluralCategory
{
private static readonly MessageFormatter Formatter = new();
private static readonly string CardinalPattern =
"{n, plural, zero{zero} one{one} two{two} few{few} many{many} other{other}}";
private static readonly string OrdinalPattern =
"{n, selectordinal, zero{zero} one{one} two{two} few{few} many{many} other{other}}";
public static string GetCategory(double number, CultureInfo locale, bool isOrdinal = false)
{
var pattern = isOrdinal ? OrdinalPattern : CardinalPattern;
var args = new Dictionary<string, object?> { { "n", number } };
// Formatter resolves the logic and returns the matched keyword block literal
return Formatter.FormatMessage(pattern, args, locale);
}
}