Closed SebastianS90 closed 5 years ago
Any thoughts on this @kazupon? 🤔
-- Edit
Hmmm, seems like the silentTranslationWarn
option does the trick, are there any side effects?
In case of someone need it
new VueI18n({
locale,
messages,
silentTranslationWarn: true
})
Based on the description of fallbackRoot
it seems like setting fallbackRoot to true should stop this warning from logging as well, but I still get the message. It seems like silentTranslationWarn
might stop you from seeing all warnings rather than just ones with valid fallbacks.
If there was a way to specify that the translation should come from the root, it might be a good way to confirm it's being done purposefully, but it might end up making things too verbose.
In my opinion, if fallbackRoot
is false
and value of key was not found, it's should warning, and is returned the key, as documented.
If fallbackRoot
is true
, the warning should only be triggered if the key value is not found, neither in the current locale, nor in root locale.
Considering what @jsfeldman suggests
specify that the translation should come from the root
a possibility could be to implement something like the "lazy" lookup of rails i18n, and decide that component based translations should always start with a .
(v-t="'.path.to.localMessage'"
). On the other hand it would surely break tons of existing code, and also it seems unnecessary, since the fallback system works great.
Personally, I'm on @alexandremagro 's opinion: there should be a way to configure vue-i18n
so that one gets warning if and only if there is no translation available neither on component nor on root level.
Hey @kazupon, would you consider re-opening this issue based on @alexandremagro 's suggestion?
I do want to be warned when a translation is missing but right now it's impossible to see it in the middle of all the "Fall back with root locale" warnings.
Any news or workarounds on this issue? It makes it pretty much insane to use this feature and the fix should probably be trivial to implement.
What about indtroducing another option, like silentFallbackWarn
?
Then warnings like
[vue-i18n] Value of key 'path.to.translation' is not a string!
[vue-i18n] Fall back to translate the keypath 'path.to.translation' with 'en-US' locale.
// OR
[vue-i18n] Fall back to translate the keypath 'path.to.translation' with root locale.
would appear only if silentFallbackWarn
is not set to true
or (the first one) if we are on root level and still no translation is found.
It would help more than silencing all translation warnings since it shows if there is really no translation provided.
I think I could submit a PR.
I think new option to suppress warning increase complexity. Instead, I suggest make every warning is produced only while development mode (vue-i18n.js, not min.js).
Instead, I suggest make every warning is produced only while development mode (vue-i18n.js, not min.js).
While developing, the output generated by this plugin is extensive and fills up the console. This makes developing harder as the output of other elements gets lost between all the warnings from vue-i18n.
I would only like to see the plugin warn me if no translation is found at all, but not for an intended fallback.
@exoego I cannot really imagine a situation when adding new logic to a code does not increase its complexity :-)
By the way, there is no warning in production, it is already part of the code, in src/index.js
every call to warn
is placed inside
if (process.env.NODE_ENV !== 'production'/* && ... */) {
warn(/* ... */)
}
And in development there is a possibility to silent all translation warnings (silentTranslationWarn: true
).
What would be more welcome, however, is the possibility to silent warnings for intentional fallback and keep them for when there is really no translation at all (typos, missing paths...)
If by 'increasing complexity' you mean that we should be able to handle this with the existing option silentTranslationWarn
, I am in for it too. Then it could receive true
or, say, 'all'
to silent all translation warnings, and 'fallback'
to warn where no translation is found at all.
What do you think about it? @kazupon what is your opinion?
@SzNagyMisu I look your proposal is good. You can contribute it.
when there is really no translation at all (typos, missing paths...)
I feel that improvement is necessary for that. I got feedback from some users.
Maybe, I'll plan to provide VSCode extension, or API. https://github.com/kazupon/vue-i18n/issues/508
@SzNagyMisu
However, the warning suppression options is increased complexity.
We should be used a suppress warning option with bit operation flags (e.g. flag1 & flag2
).
For anyone wondering it might be worth mentioning that PR #510 adds a new option, silentFallbackWarn
, which if set to true silences all fallback warnings.
new VueI18n({
locale,
messages,
silentFallbackWarn: true
})
In my opinion, if
fallbackRoot
isfalse
and value of key was not found, it's should warning, and is returned the key, as documented.If
fallbackRoot
istrue
, the warning should only be triggered if the key value is not found, neither in the current locale, nor in root locale.
Is there a plan to release a version?
vue & vue-i18n version
2.2.6, 6.0.0
Steps to reproduce
Use the example for component locales
What is Expected?
No warning in developer console
What is actually happening?
My use case for component locales is as follows:
Right now I get warnings whenever I use a global locale. They go away when compiling for production, but it is still annoying as it interrupts the development process. Can you please provide a way to disable these warnings?