1
0
Fork 0

boom: Updated to new plugin model

This commit is contained in:
Joost De Cock 2018-12-17 15:56:47 +01:00
parent e510a90bc4
commit f327526fca
11 changed files with 831 additions and 927 deletions

View file

@ -1,18 +1,18 @@
import { version, name } from "../package.json";
import locales from "../locales";
export default {
name: name,
version: version,
hooks: {
preRender: function(next) {
this.attributes.add("freesewing:plugin-i18n", version);
next();
preRender: function(svg) {
if(svg.attributes.get('freesewing:plugin-i18n') === false) {
svg.attributes.set('freesewing:plugin-i18n', version);
}
},
insertText: function(next) {
if(typeof locales[this.pattern.settings.locale][this.text] === 'string')
this.text = locales[this.pattern.settings.locale][this.text];
next();
insertText: function(locale, text, data) {
let prefix = data.prefix || "";
if(typeof data.strings[locale][prefix+text] === "undefined") return text;
else return data.strings[locale][prefix+text];
}
}
};