#971·vue-i18n

[feature request] Have $te check for fallback locales

Author: PROgram52bcCreated Aug 12, 2020Updated May 24, 2024
Labelshelp wantedStatus: ProposalType: Feature

Suppose I have the following messages and fallback config:

javascript
messages: {
  en: {
    message: {
      hello: 'hello world',
      greeting: 'good morning'
    }
  }
},
fallbackLocale: 'en'

And with my current $i18n.locale set to "en-US", running $te will have the following output:

javascript
this.$te('hello') // => false

Would it be a bad idea to configure the default behavior of $te to take into account of the fallback locale setting?

So suppose I have the fallbackLocale set to ['es-EC', 'en'], and with $i18n.locale set to "fr", running

javascript
this.$te('hello')

should be equivalent to

javascript
(this.$te('hello', 'fr') ||
 this.$te('hello', 'es-EC') ||
 this.$te('hello', 'es') ||
 this.$te('hello', 'en'))

With that implemented, the current default behavior should still be reproduceable with this.$te('hello', this.$i18n.locale).