1
0
Fork 0

chore(plugin-i18n): Ported to v3

This commit is contained in:
Joost De Cock 2022-09-12 17:52:55 +02:00
parent 75cadc4b7c
commit a85342e6dc
3 changed files with 20 additions and 13 deletions

View file

@ -22,4 +22,3 @@ export const plugin = {
// More specifically named exports // More specifically named exports
export const i18nPlugin = plugin export const i18nPlugin = plugin
export const pluginI18n = plugin export const pluginI18n = plugin

View file

@ -1,26 +1,35 @@
import chai from 'chai' import chai from 'chai'
import { Design } from '@freesewing/core' import { Design } from '@freesewing/core'
import { plugin } from '../dist/index.mjs' import { plugin } from '../src/index.mjs'
const expect = chai.expect const expect = chai.expect
const content = { const content = {
strings: { strings: {
en: { en: {
testString: 'This is a test string for the i18n plugin' testString: 'This is a test string for the i18n plugin',
} },
} },
} }
describe('I18n Plugin Tests', () => { describe('I18n Plugin Tests', () => {
it('Should translate text on insert', () => { it('Should translate text on insert', () => {
const Pattern = new Design() const part = {
const pattern = new Pattern().use(plugin, content) name: 'test',
pattern.parts.test = new pattern.Part() draft: ({ points, Point, macro, part }) => {
pattern.parts.test.points.anchor = new pattern.Point(-12, -34).attr( points.anchor = new pattern.Point(-12, -34).attr('data-text', 'testString')
'data-text', points.from = new Point(10, 20)
'testString' points.to = new Point(10, 230)
) macro('grainline', {
from: points.from,
to: points.to,
})
return part
},
plugins: [[plugin, content]],
}
const Pattern = new Design({ parts: [part] })
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.strings.en.testString)
}) })

View file

@ -4,4 +4,3 @@ import { sharedPluginTests } from '../../../tests/plugins/shared.mjs'
// Run shared tests // Run shared tests
sharedPluginTests(plugin) sharedPluginTests(plugin)