1
0
Fork 0
freesewing/plugins/plugin-i18n/src/index.js

22 lines
609 B
JavaScript
Raw Normal View History

import pkg from '../package.json'
2018-08-28 07:28:21 +02:00
export default {
name: pkg.name,
version: pkg.version,
2018-08-28 07:28:21 +02:00
hooks: {
preRender: (svg) => svg.attributes.setIfUnset('freesewing:plugin-i18n', pkg.version),
insertText: (locale, text, data) => {
if (!data) {
2019-08-03 15:03:33 +02:00
console.log(
"No data was passed to the i18n plugin. This plugin won't do much without injecting data into it"
)
return text
}
const prefix = data.prefix || ''
return typeof data.strings[locale][prefix + text] === 'undefined'
? text
: data.strings[locale][prefix + text]
2021-04-24 10:16:31 +02:00
},
},
2019-08-03 15:03:33 +02:00
}