From 191b4116a9b9b264aa306cb5a46603fb1bd68ef8 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Mon, 6 Jan 2020 13:28:17 +0100 Subject: [PATCH] Added silent option to `loadLanguages` (#2147) This adds an option to `loadLanguages` which prevents all warning messages. --- components/index.js | 9 ++++++++- index.html | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/components/index.js b/components/index.js index 450810a7a2..b2edcc2abc 100644 --- a/components/index.js +++ b/components/index.js @@ -30,7 +30,9 @@ function loadLanguages(languages) { getLoader(components, languages, loaded).load(lang => { if (!(lang in components.languages)) { - console.warn('Language does not exist: ' + lang); + if (!loadLanguages.silent) { + console.warn('Language does not exist: ' + lang); + } return; } @@ -46,4 +48,9 @@ function loadLanguages(languages) { }); } +/** + * Set this to `true` to prevent all warning messages `loadLanguages` logs. + */ +loadLanguages.silent = false; + module.exports = loadLanguages; diff --git a/index.html b/index.html index f8451860b4..ab2bfd0e57 100644 --- a/index.html +++ b/index.html @@ -226,6 +226,8 @@

Usage with Node

Note: Do not use loadLanguages() with Webpack or another bundler, as this will cause Webpack to include all languages and plugins. Use the babel plugin described above.

+

Note: loadLanguages() will ignore unknown languages and log warning messages to the console. You can prevent the warnings by setting loadLanguages.silent = true.

+