Open fabis94 opened 3 years ago
This is not a "Proposal" or an "Improvement". Its stated in the docs that the warnings will be prevented, but they don't.
missing Type: MissingHandler
Default: null
A handler for localization missing. The handler gets called with the localization target locale, localization path key, the Vue instance and values.
If missing handler is assigned, and occurred localization missing, it's not warned.
This is very confusing, please update the docs. And possibly fix the issue.
Module versions (please complete the following information):
vue
: 2.6.12vue-i18n
: 8.23.0nuxt-i18n
: 6.21.1 (if relevant)To Reproduce Use
missing
Vuei18n contructor option to set a function that ignores all errors, something like this:Then use one of the translation methods in a Vue template for a key that doesn't exist in any of the translation files:
You'll still get the following warning in development mode:
Expected behavior From the docs it looks like the above implementation of
missing
(https://kazupon.github.io/vue-i18n/api/#constructor-options) should suppress all warnings, but it doesn't.Additional context From the source code of this package it looks like
missing
is only used for the first warning that appears - "Cannot translate the value of keypath X. Use the value of keypath as default." The other warning, however, uses no such check and thus the warning is emitted regardless.Here you can see
missing
is used to skip the warning:Here, however, there is no check and warnings are shown always:
I want to completely suppress all warnings for the default locale, because I'll use the
key
as the message and thus won't need to have any translation file for the default locale. In the case of the default locale$t('Some message')
will just outputSome message
I know that the API supports supressing all warnings or suppressing all warnings if the fallback locale actually has defined translations, but none of these options work for me because my default/fallback locale won't have any translations (the translation file will essentially just contain
{}
) and I still want warnings for when other locales have missing keys.