vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Switch the locales lookup order for missing keys

Open lllopo opened this issue 3 years ago • 1 comments
trafficstars

Clear and concise description of the problem

I mentioned this in another issue, but decided to create a separate one for clearness. So, I'm organizing my language files as follows

  • all common and often repeated translation keys (like days of the week, often repeated errors etc.) are stored in the root locale context.
  • Only strings that are unique for a given component are stored in it's own locale context (and own json file respectively)

I think this is a very common/popular (and logical) organization of translations. By looking to the warnings I get for translations not found, though, what I see is that the keys are looked in the following order : local current locale -> local default locale -> root current locale -> root default locale. Now, this does not create any practical issue, since the keys are not in the local default locale by design, but apart from looking first in the wrong place and being illogical, this also generates "missing key" warnings that are completely wrong for the given organization of the translations.

Suggested solution

So, I suggest to switch the look up order from : local current locale -> local default locale -> root current locale -> root default locale

to : local current locale -> root current locale -> local default locale -> root default locale

This is a more natural order and will save a lot of unnecessary (and so, so, so annoying) warnings in the process.

Alternative

No response

Additional context

No response

Validations

lllopo avatar Feb 05 '22 14:02 lllopo