question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot silence fallback warnings like on V8

See original GitHub issue

Reporting a bug

By default when fallbacking fail, two warnings are printed e.g

[intlify] Fall back to translate 'bf.headerBar.homeSearchBarPlaceholder' key with 'en' locale
[intlify] Not found 'bf.headerBar.homeSearchBarPlaceholder' key in 'en' locale messages.

The documentation clearly state:

To suppress these warnings (while keeping those which warn of the total absence of translation for the given key) set silentTranslationWarn: true, and silentFallbackWarn: true when initializing the createI18n.

Since the failing fallback warnings are much too noisy, I want to silence them, but keep other i18n warnings. Unfortunately, it seems that those booleans have been silently renamed and the documentation no longer reflect the state of V9 Apparently silentFallbackWarn has become fallbackWarn and the boolean logic reversed. If so why not I don’t care and indeed setting fallbackWarn remove half of the warnings. silentTranslationWarn seems to now longer exist ? (at least in non-legacy mode), however I cannot find the new boolean. It should have been renamed to translationWarn to be consistent with fallbackWarn renaming but there is no such thing. The ComposerOptions type expose the following candidates:

  • missingWarn: when enabled it effectively hide warnings, but it hide too much warnings e.g I have no key in the fallback languages nor in the user locale. This is in direct contradiction with

while keeping those which warn of the total absence of translation for the given key

  • missing: this boolean might be the new silentTranslationWarn ? weird cause the type is not a boolean despite what the doc claims, I have no idea how to set missing.

I am on the latest stable Vue-i18n 9.1.x release.

const i18n = createI18n({
  fallbackWarn: false,
  missingWarn: false,
  fallbackLocale: ["en", "fr"],
  globalInjection: true,
  legacy: false,
  useScope: "global",
  locale: locale,
  messages: loadTranslations(),
  datetimeFormats,
  numberFormats,
});

edit: the doc confirm that silentTranslationWarn has been renamed to missingWarn. Then how come I have now warning when no key is found for fallbackLocale? @kazupon friendly ping

Validations

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
darkxantercommented, Feb 3, 2022

For example, there is such a file with translation: en.json

{
  "password": "Password"
}

And vue file:

<template>
  <div>{{ t('password' }}</div>
  <div>{{ t('password2' }}</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { useI18n } from 'vue-i18n'

export default defineComponent({
  setup() {
    const { t } = useI18n({ useScope: 'global' })
    return {
      t,
    }
  },
})
</script>

By default I get messages like this in the console:

Fall back to translate 'password' key with 'en' locale. 
Not found 'password' key in 'en' locale messages. 
Fall back to translate 'password' with root locale. 
Fall back to translate 'password2' key with 'en' locale. 
Not found 'password2' key in 'en' locale messages. 
Fall back to translate 'password2' with root locale. 
Fall back to translate 'password2' key with 'en' locale. 
Not found 'password2' key in 'en' locale messages.

missingWarn: false and fallbackWarn: false suppress all of these messages, but I want to see only warning message for password2 and not for password.

1reaction
JWong1105commented, Mar 22, 2022

Hello everybody, just now I found the right config by debug the source code. We just can only set ‘silentTranslationWarn: true’ and ‘silentFallbackWarn: true’ the source codes are in the file ‘vue-i18n.esm-bundler.js’ at line 661. const missingWarn = isBoolean(options.silentTranslationWarn) || isRegExp(options.silentTranslationWarn) ? !options.silentTranslationWarn : true; const fallbackWarn = isBoolean(options.silentFallbackWarn) || isRegExp(options.silentFallbackWarn) ? !options.silentFallbackWarn : true;

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable warnings for fallback to root locale #139 - GitHub
If fallbackRoot is true , the warning should only be triggered if the key value is not found, neither in the current locale,...
Read more >
Unable to resolve npm install pre-gyp error - Stack Overflow
It seems that it is actually an obscure problem that is created by the firebase and node-sass versions you're using.
Read more >
IP Phones Not Registering During call-manager-fallback ...
I am trying to test the SRST failover of an ISR Router, but after I cut the connection to CUCM, the IP Phones...
Read more >
Fallbacking - Vue I18n - Intlify
To suppress the automatic fallback, add the postfix exclamation mark ! , for example de-DE! Explicit fallback with one locale #. Sometimes some...
Read more >
vue-i18n | Yarn - Package Manager
... source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found