From c46bc3409552613eddaf805a1325a2ee10b7c6ea Mon Sep 17 00:00:00 2001 From: Jerozgen Date: Tue, 10 Mar 2026 17:32:18 +0300 Subject: [PATCH] Use `one` for compact numbers in Filipino --- packages/ui/src/composables/format-number.ts | 14 ++++++-------- packages/ui/src/composables/i18n.ts | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/ui/src/composables/format-number.ts b/packages/ui/src/composables/format-number.ts index ce3aec1177..4cd10948cb 100644 --- a/packages/ui/src/composables/format-number.ts +++ b/packages/ui/src/composables/format-number.ts @@ -1,6 +1,7 @@ import { LRUCache } from 'lru-cache' import { injectI18n } from '../providers/i18n' +import { LOCALES } from './i18n.ts' const formatterCache = new LRUCache({ max: 15 }) @@ -35,16 +36,13 @@ export function useCompactNumber() { return twoDigitsCompactFormatter.format(value) } - function formatCompactNumberPlural(value: number | bigint): string { + function formatCompactNumberPlural(value: number | bigint): number | bigint { if (value < 10_000) { - return value.toString() + return value } - if (value < 1_000_000) { - const oneDigitCompactFormatter = getCompactFormatter(locale.value, 1) - return oneDigitCompactFormatter.format(value) - } - const twoDigitsCompactFormatter = getCompactFormatter(locale.value, 2) - return twoDigitsCompactFormatter.format(value) + const currentLocale = locale.value + const localeDefinition = LOCALES.find((l) => l.code === currentLocale) + return localeDefinition?.compactNumberPlural ?? NaN } return { formatCompactNumber, formatCompactNumberPlural } diff --git a/packages/ui/src/composables/i18n.ts b/packages/ui/src/composables/i18n.ts index f7ef713527..12020e0ca7 100644 --- a/packages/ui/src/composables/i18n.ts +++ b/packages/ui/src/composables/i18n.ts @@ -30,6 +30,7 @@ export interface LocaleDefinition { name: string translatedName: MessageDescriptor numeric?: Intl.RelativeTimeFormatNumeric + compactNumberPlural?: number dir?: 'ltr' | 'rtl' iso?: string file?: string @@ -93,6 +94,7 @@ export const LOCALES: LocaleDefinition[] = [ code: 'fil-PH', name: 'Filipino', translatedName: defineMessage({ id: 'locale.fil-PH', defaultMessage: 'Filipino' }), + compactNumberPlural: 1, }, { code: 'fr-FR',