INNER CODE UNIT · TypeScript

checkPluralRules

dietrichmax/colota · apps/mobile/src/i18n/index.ts:18

function checkPluralRules(): void {
  if (typeof Intl !== "undefined" && typeof Intl.PluralRules !== "undefined") return

  const affected = SUPPORTED_LANGUAGES.filter((l) => COMPLEX_PLURAL_LANGUAGES.includes(l))
  if (affected.length > 0) {
    throw new Error(
      `Intl.PluralRules is missing but ${affected.join(", ")} need it. i18next would silently use ` +
        "English plural rules. Add @formatjs/intl-pluralrules."
    )
  }
  logger.warn("[i18n] Intl.PluralRules is unavailable; add @formatjs/intl-pluralrules before a language needs it")
}

export function initI18n(): SupportedLanguage {
  const deviceTag = NativeLocationService.getBuildConfig()?.APP_LANGUAGE
  const language = resolveLanguage(deviceTag)

  i18next.init({ ...I18N_OPTIONS, lng: language })

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…