Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable no translation warning #96

Closed
shaunnetherby opened this issue Dec 7, 2016 · 11 comments
Closed

Disable no translation warning #96

shaunnetherby opened this issue Dec 7, 2016 · 11 comments

Comments

@shaunnetherby
Copy link

vue-i18n logs the following as a warning whenever a translation is not found:

[vue-i18n] Cannot translate the value of keypath "Mobile". Use the value of keypath as default

This can be convenient for debugging, but I have certain cases that it is legitimate to not find a translation and I would not like a warning to be logged. In my product we have created components that use the translation internally, and expect a message code to normally be passed in. A good example of this is the Select component we have created. It uses the $t function to translate all of the options. In some uses of the Select component, the options are not message codes because they have been created by the user. It is not desirable to spam the console with a bunch of warnings.

I believe a reasonable approach would be to have a configuration option to disable the warning, or to not log the warning if a missingHandler is registered in the config.

Vue.config.disableNoTranslationWarning = true;
@kazupon
Copy link
Owner

kazupon commented Dec 8, 2016

Thank you for your feedback.
I'll try to improve this issue. 😉

@shaunnetherby
Copy link
Author

@kazupon Thanks!

@ahalimkara
Copy link
Contributor

In case of someone need it:

new VueI18n({
  locale,
  messages,
  silentTranslationWarn: true
})

@frankjoke
Copy link

I am first time user of i18n on Vue cli/ui and looked for that as well.
I was actually looking for a hook function which receives the data and can then return true or false for logging.
The reason is that I wanted to use such a function to log all keys which are still not translated.
the Vue-Ui-plugin report lists only programmatic uses of $t and not data driven translations.

Most of my logic is data driven, so nearly all my buttons, labels, hints, errors, tooltips are generated from data and they are not handled with the report.
Such a function hook could check if if we are development mode and list the missing keys then as well to a personal report object which I could use to understand missing translations or.
I could even use it to write another plugin tool which autotranslates all keys on the fly...

@Louvki
Copy link

Louvki commented Jan 20, 2021

+1 for some sort of hook where i can check wether i want to display the warning or not.

I have an usecase where there's a check for a translation which 60% wont exist. I would like to silence that specific warning however I would still like to receive warnings on different use cases.

@jjsty1e
Copy link

jjsty1e commented May 17, 2022

this not working in vue3

@ats05
Copy link

ats05 commented May 19, 2022

I haven't verified it in detail yet, but it doesn't seem to work in my vue3 app.

@elzodxon
Copy link

It is not working with Vue3 app

@TomaszAdamowicz
Copy link

It is not working with Vue3 app

I suppose you are using v.9.x, you should pass to config following options :  missingWarn: false, fallbackWarn: false,

@josfaber
Copy link

const i18n = createI18n( {
    locale: lang, 
    fallbackLocale: 'en', 
    missingWarn: false, 
    fallbackWarn: false,
    silentTranslationWarn: true,
    messages: {
        nl,
        en,
    }, 
} );

"Not Found" warnings are now gone, but "Fall back" warnings remain when I don't have them in all language objects.

"vue": "^3.2.39",
"vue-i18n": "^9.2.2",

@tpuida
Copy link

tpuida commented Sep 18, 2023

Can I use smth like this only once in the template? I.e. don't change global warn settings but use it when I get data from the server and I don't have every key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests