bug: Handling scenario when no data is passed to plugin
This commit is contained in:
parent
2e578a47be
commit
e5f4fe7824
2 changed files with 5 additions and 0 deletions
|
@ -33,6 +33,7 @@
|
||||||
"browserbuild": "rollup -c rollup.js --file dist/browser.js --format iife -m true --name freesewing.plugins.i18n",
|
"browserbuild": "rollup -c rollup.js --file dist/browser.js --format iife -m true --name freesewing.plugins.i18n",
|
||||||
"nodebuild": "rollup -c rollup.js --file dist/index.js --format cjs -m true",
|
"nodebuild": "rollup -c rollup.js --file dist/index.js --format cjs -m true",
|
||||||
"modulebuild": "rollup -c rollup.js --file dist/index.mjs --format es -m true",
|
"modulebuild": "rollup -c rollup.js --file dist/index.mjs --format es -m true",
|
||||||
|
"rebuild": "npm run nodebuild && npm run modulebuild",
|
||||||
"build": "npm run clean && npm run browserbuild && npm run nodebuild && npm run modulebuild"
|
"build": "npm run clean && npm run browserbuild && npm run nodebuild && npm run modulebuild"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
|
|
|
@ -10,6 +10,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
insertText: function(locale, text, data) {
|
insertText: function(locale, text, data) {
|
||||||
|
if(data === false) {
|
||||||
|
console.log("No data was passed to the i18n plugin. This plugin won't do much without injecting data into it");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
let prefix = data.prefix || "";
|
let prefix = data.prefix || "";
|
||||||
if(typeof data.strings[locale][prefix+text] === "undefined") return text;
|
if(typeof data.strings[locale][prefix+text] === "undefined") return text;
|
||||||
else return data.strings[locale][prefix+text];
|
else return data.strings[locale][prefix+text];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue