fix(plugin-i18n): Fixes after translation changes
This commit is contained in:
parent
598463f0a0
commit
64f75a54d2
2 changed files with 6 additions and 7 deletions
|
@ -5,10 +5,11 @@ export const plugin = {
|
||||||
version,
|
version,
|
||||||
hooks: {
|
hooks: {
|
||||||
insertText: (locale, text, t, pattern) => {
|
insertText: (locale, text, t, pattern) => {
|
||||||
if (t instanceof Function) return t(text)
|
if (t instanceof Function) return t(text, locale)
|
||||||
|
else if (typeof t[locale] === 'object') return t[locale][text] || text
|
||||||
else {
|
else {
|
||||||
const msg =
|
const msg =
|
||||||
"No translation method was passed to the i18n plugin. This plugin won't do anything without a translation method"
|
"No translation method or object was passed to the i18n plugin. This plugin won't do anything without that"
|
||||||
if (pattern?.store?.log?.warning) {
|
if (pattern?.store?.log?.warning) {
|
||||||
if (!pattern.store.get(['plugins', 'plugin-i18n', 'missingMethodWarning'])) {
|
if (!pattern.store.get(['plugins', 'plugin-i18n', 'missingMethodWarning'])) {
|
||||||
pattern.store.set(['plugins', 'plugin-i18n', 'missingMethodWarning'], true)
|
pattern.store.set(['plugins', 'plugin-i18n', 'missingMethodWarning'], true)
|
||||||
|
|
|
@ -5,10 +5,8 @@ import { plugin } from '../src/index.mjs'
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
const content = {
|
const content = {
|
||||||
strings: {
|
en: {
|
||||||
en: {
|
testString: 'This is a test string for the i18n plugin',
|
||||||
testString: 'This is a test string for the i18n plugin',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +29,6 @@ describe('I18n Plugin Tests', () => {
|
||||||
const Pattern = new Design({ parts: [part] })
|
const Pattern = new Design({ parts: [part] })
|
||||||
const pattern = new Pattern()
|
const pattern = new Pattern()
|
||||||
const svg = pattern.draft().render()
|
const svg = pattern.draft().render()
|
||||||
expect(svg).to.contain(content.strings.en.testString)
|
expect(svg).to.contain(content.en.testString)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue