kazupon/vue-i18n

[feature request] Have $te check for fallback locales

Open

#971 opened on Aug 12, 2020

View on GitHub
 (6 comments) (5 reactions) (0 assignees)JavaScript (7,181 stars) (886 forks)batch import
Status: ProposalType: Featurehelp wanted

Description

Suppose I have the following messages and fallback config:

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:

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

this.$te('hello')

should be equivalent to

(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).

Contributor guide