Fallback Chains
When a message is not found in the current locale, Fluenti tries:
- Current locale
- Fallback chain (if configured)
fallbackLocale(if set)- Returns the message ID
Configuration
Section titled “Configuration”const i18n = createFluentVue({ locale: 'zh-TW', fallbackLocale: 'en', messages: { en, 'zh-CN': zhCN, 'zh-TW': zhTW }, fallbackChain: { 'zh-TW': ['zh-CN', 'en'], 'pt-BR': ['pt', 'en'], '*': ['en'], },})With this config, when locale is zh-TW:
- Try
zh-TWcatalog - Try
zh-CNcatalog (from fallbackChain) - Try
encatalog (from fallbackChain) - Try
encatalog (from fallbackLocale)
Regional Variants
Section titled “Regional Variants”Instead of duplicating an entire catalog for en-GB, let it fall back to en and only translate the differences:
createFluent({ locale: 'en-GB', fallbackLocale: 'en', fallbackChain: { 'en-GB': ['en'], 'zh-TW': ['zh-CN'], 'pt-BR': ['pt'], }, messages,})Missing Handler
Section titled “Missing Handler”For custom behavior when a message is not found:
const i18n = createFluentVue({ locale: 'en', messages, missing: (locale, id) => { console.warn(`Missing translation: ${locale}/${id}`) return undefined // or return a fallback string },})