Filipino compact number plural rule (#5516)
Use `one` for compact numbers in Filipino Signed-off-by: Jerozgen <jerozgen@gmail.com> Co-authored-by: Calum H. <calum@modrinth.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { LRUCache } from 'lru-cache'
|
||||
|
||||
import { injectI18n } from '../providers/i18n'
|
||||
import { LOCALES } from './i18n.ts'
|
||||
|
||||
const formatterCache = new LRUCache<string, Intl.NumberFormat>({ 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 }
|
||||
|
||||
@@ -30,6 +30,7 @@ export interface LocaleDefinition {
|
||||
name: string
|
||||
translatedName: MessageDescriptor
|
||||
numeric?: Intl.RelativeTimeFormatNumeric
|
||||
compactNumberPlural?: number
|
||||
dir?: 'ltr' | 'rtl'
|
||||
serverLanguageCode?: string
|
||||
}
|
||||
@@ -92,6 +93,7 @@ export const LOCALES: LocaleDefinition[] = [
|
||||
code: 'fil-PH',
|
||||
name: 'Filipino',
|
||||
translatedName: defineMessage({ id: 'locale.fil-PH', defaultMessage: 'Filipino' }),
|
||||
compactNumberPlural: 1,
|
||||
serverLanguageCode: 'tl',
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user