2018-08-28 07:28:21 +02:00
|
|
|
import { version, name } from "../package.json";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: name,
|
|
|
|
version: version,
|
|
|
|
hooks: {
|
2018-12-17 15:56:47 +01:00
|
|
|
preRender: function(svg) {
|
|
|
|
if(svg.attributes.get('freesewing:plugin-i18n') === false) {
|
|
|
|
svg.attributes.set('freesewing:plugin-i18n', version);
|
|
|
|
}
|
2018-08-28 07:28:21 +02:00
|
|
|
},
|
2018-12-17 15:56:47 +01:00
|
|
|
insertText: function(locale, text, data) {
|
2018-12-20 08:30:34 +01:00
|
|
|
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;
|
|
|
|
}
|
2018-12-17 15:56:47 +01:00
|
|
|
let prefix = data.prefix || "";
|
|
|
|
if(typeof data.strings[locale][prefix+text] === "undefined") return text;
|
|
|
|
else return data.strings[locale][prefix+text];
|
2018-08-28 07:28:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|