1
0
Fork 0

feat(plugin-annotations): Add i18n

This commit is contained in:
joostdecock 2023-09-06 08:14:49 +02:00
parent 84785f67c6
commit 9ae94abd02
14 changed files with 172 additions and 30 deletions

View file

@ -0,0 +1,21 @@
{
"canvas": "canvas",
"cut": "Cut",
"cutOnFold": "Cut on fold",
"cutOnFoldAndGrainline": "Cut on fold / Grainline",
"fabric": "main fabric",
"facing": "facing",
"from": "from",
"fusible": "fusible interfacing",
"interfacing": "interfacing",
"lining": "lining",
"mirrored": "mirorred",
"noName": "No name",
"noVersion": "No version",
"onBias": "on the bias",
"onFold": "on the fold",
"onFoldAndBias": "on the fold, and on bias",
"sewTogether": "Sew together",
"theBlackOutideOfThisBoxShouldMeasure": "The (black) outside of this box should measure",
"theWhiteInsideOfThisBoxShouldMeasure": "The (white) inside of this box should measure"
}

View file

@ -0,0 +1,21 @@
{
"canvas": "canvas",
"cut": "Cut",
"cutOnFold": "Cut on fold",
"cutOnFoldAndGrainline": "Cut on fold / Grainline",
"fabric": "main fabric",
"facing": "facing",
"from": "from",
"fusible": "fusible interfacing",
"interfacing": "interfacing",
"lining": "lining",
"mirrored": "mirorred",
"noName": "No name",
"noVersion": "No version",
"onBias": "on the bias",
"onFold": "on the fold",
"onFoldAndBias": "on the fold, and on bias",
"sewTogether": "Sew together",
"theBlackOutideOfThisBoxShouldMeasure": "The (black) outside of this box should measure",
"theWhiteInsideOfThisBoxShouldMeasure": "The (white) inside of this box should measure"
}

View file

@ -0,0 +1,21 @@
{
"canvas": "canvas",
"cut": "Cut",
"cutOnFold": "Cut on fold",
"cutOnFoldAndGrainline": "Cut on fold / Grainline",
"fabric": "main fabric",
"facing": "facing",
"from": "from",
"fusible": "fusible interfacing",
"interfacing": "interfacing",
"lining": "lining",
"mirrored": "mirorred",
"noName": "No name",
"noVersion": "No version",
"onBias": "on the bias",
"onFold": "on the fold",
"onFoldAndBias": "on the fold, and on bias",
"sewTogether": "Sew together",
"theBlackOutideOfThisBoxShouldMeasure": "The (black) outside of this box should measure",
"theWhiteInsideOfThisBoxShouldMeasure": "The (white) inside of this box should measure"
}

View file

@ -0,0 +1,21 @@
{
"canvas": "canvas",
"cut": "Cut",
"cutOnFold": "Cut on fold",
"cutOnFoldAndGrainline": "Cut on fold / Grainline",
"fabric": "main fabric",
"facing": "facing",
"from": "from",
"fusible": "fusible interfacing",
"interfacing": "interfacing",
"lining": "lining",
"mirrored": "mirorred",
"noName": "No name",
"noVersion": "No version",
"onBias": "on the bias",
"onFold": "on the fold",
"onFoldAndBias": "on the fold, and on bias",
"sewTogether": "Sew together",
"theBlackOutideOfThisBoxShouldMeasure": "The (black) outside of this box should measure",
"theWhiteInsideOfThisBoxShouldMeasure": "The (white) inside of this box should measure"
}

View file

@ -0,0 +1,8 @@
import en from './en.json' assert { type: 'json' }
import de from './de.json' assert { type: 'json' }
import es from './es.json' assert { type: 'json' }
import fr from './fr.json' assert { type: 'json' }
import nl from './nl.json' assert { type: 'json' }
import uk from './uk.json' assert { type: 'json' }
export const i18n = { en, de, es, fr, nl, uk }

View file

@ -0,0 +1,21 @@
{
"canvas": "canvas",
"cut": "Cut",
"cutOnFold": "Cut on fold",
"cutOnFoldAndGrainline": "Cut on fold / Grainline",
"fabric": "main fabric",
"facing": "facing",
"from": "from",
"fusible": "fusible interfacing",
"interfacing": "interfacing",
"lining": "lining",
"mirrored": "mirorred",
"noName": "No name",
"noVersion": "No version",
"onBias": "on the bias",
"onFold": "on the fold",
"onFoldAndBias": "on the fold, and on bias",
"sewTogether": "Sew together",
"theBlackOutideOfThisBoxShouldMeasure": "The (black) outside of this box should measure",
"theWhiteInsideOfThisBoxShouldMeasure": "The (white) inside of this box should measure"
}

View file

@ -0,0 +1,21 @@
{
"canvas": "canvas",
"cut": "Cut",
"cutOnFold": "Cut on fold",
"cutOnFoldAndGrainline": "Cut on fold / Grainline",
"fabric": "main fabric",
"facing": "facing",
"from": "from",
"fusible": "fusible interfacing",
"interfacing": "interfacing",
"lining": "lining",
"mirrored": "mirorred",
"noName": "No name",
"noVersion": "No version",
"onBias": "on the bias",
"onFold": "on the fold",
"onFoldAndBias": "on the fold, and on bias",
"sewTogether": "Sew together",
"theBlackOutideOfThisBoxShouldMeasure": "The (black) outside of this box should measure",
"theWhiteInsideOfThisBoxShouldMeasure": "The (white) inside of this box should measure"
}

View file

@ -56,6 +56,9 @@ const cutonfold = function (config, { points, paths, Path, complete, store, scal
*/ */
const mc = { const mc = {
...macroDefaults, ...macroDefaults,
text: config.grainline
? 'plugin-annotations:cutOnFoldAndGrainline'
: 'plugin-annotations:cutOnFold',
...config, ...config,
classes: macroDefaults.classes, classes: macroDefaults.classes,
} }
@ -99,7 +102,7 @@ const cutonfold = function (config, { points, paths, Path, complete, store, scal
.attr('class', mc.classes.line) .attr('class', mc.classes.line)
.attr('marker-start', 'url(#cutonfoldFrom)') .attr('marker-start', 'url(#cutonfoldFrom)')
.attr('marker-end', 'url(#cutonfoldTo)') .attr('marker-end', 'url(#cutonfoldTo)')
.addText(mc.grainline ? 'cutOnFoldAndGrainline' : 'cutOnFold', mc.classes.text) .addText(mc.text, mc.classes.text)
/* /*
* Store all IDs in the store so we can remove this macro with rmcutonfold * Store all IDs in the store so we can remove this macro with rmcutonfold

View file

@ -193,9 +193,9 @@ export const dimensionsMacros = {
rmld: (id, props) => removeDimension(id, props, 'ld'), rmld: (id, props) => removeDimension(id, props, 'ld'),
rmvd: (id, props) => removeDimension(id, props, 'vd'), rmvd: (id, props) => removeDimension(id, props, 'vd'),
rmpd: (id, props) => removeDimension(id, props, 'pd'), rmpd: (id, props) => removeDimension(id, props, 'pd'),
rmhd: (config, props) => removeDimensionType(props, 'hd'), rmahd: (config, props) => removeDimensionType(props, 'hd'),
rmld: (config, props) => removeDimensionType(props, 'ld'), rmald: (config, props) => removeDimensionType(props, 'ld'),
rmvd: (config, props) => removeDimensionType(props, 'vd'), rmavd: (config, props) => removeDimensionType(props, 'vd'),
rmpd: (config, props) => removeDimensionType(props, 'pd'), rmapd: (config, props) => removeDimensionType(props, 'pd'),
rmad: (config, props) => removeAllDimensions(props), rmad: (config, props) => removeAllDimensions(props),
} }

View file

@ -10,7 +10,7 @@ const macroDefaults = {
}, },
id: 'grainline', id: 'grainline',
margin: 0.05, margin: 0.05,
text: 'grainline', text: 'plugin-annotations:grainline',
} }
// Export defs // Export defs

View file

@ -1,4 +1,6 @@
import { name, version } from '../data.mjs' import { name, version } from '../data.mjs'
// i18n
import { i18n as i18nAnnotations } from '../i18n/index.mjs'
// Defs only // Defs only
import { buttonsDefs } from './buttons.mjs' import { buttonsDefs } from './buttons.mjs'
import { logoDefs } from './logo.mjs' import { logoDefs } from './logo.mjs'
@ -62,3 +64,4 @@ export const plugin = {
export const annotationsPlugin = plugin export const annotationsPlugin = plugin
export const pluginAnnotations = plugin export const pluginAnnotations = plugin
export const i18n = i18nAnnotations

View file

@ -7,11 +7,15 @@ const macroDefaults = {
classes: { classes: {
lead: 'text-xs bold', lead: 'text-xs bold',
title: 'text bold', title: 'text bold',
text: 'text-sm', text: 'text-xs',
link: 'text-sm fill-note', link: 'text-sm fill-note bold',
metric: 'text-xs center', metric: 'text-xs center',
imperial: 'text-xs center', imperial: 'text-xs center',
}, },
lead: 'FreeSewing',
link: 'FreeSewing.org/patrons/join',
text: 'plugin-annotations:supportFreesewingBecomeAPatron',
title: false,
} }
/* /*
@ -191,7 +195,7 @@ const scalebox = function (config, { store, points, paths, scale, Point, Path, c
* Add lead text to the part points * Add lead text to the part points
*/ */
points[ids.textLead] = text.lead points[ids.textLead] = text.lead
.addText(mc.lead || 'FreeSewing', mc.classes.lead) .addText(mc.lead, mc.classes.lead)
.attr('data-text-class', 'text-sm') .attr('data-text-class', 'text-sm')
/* /*
@ -199,7 +203,7 @@ const scalebox = function (config, { store, points, paths, scale, Point, Path, c
*/ */
let title = mc.title let title = mc.title
if (!title) { if (!title) {
title = store.data?.name || 'No Name' title = store.data?.name || 'plugin-annotations:noName'
if (title.indexOf('@freesewing/') !== -1) title = title.replace('@freesewing/', '') if (title.indexOf('@freesewing/') !== -1) title = title.replace('@freesewing/', '')
} }
points[ids.textTitle] = text.title points[ids.textTitle] = text.title
@ -209,23 +213,18 @@ const scalebox = function (config, { store, points, paths, scale, Point, Path, c
/* /*
* Add text text to the part points * Add text text to the part points
*/ */
points[ids.textText] = text.text.addText( points[ids.textText] = text.text.addText(mc.text, mc.classes.text)
typeof mc.text === 'string' ? mc.text : 'supportFreesewingBecomeAPatron',
mc.classes.text
)
/* /*
* Add link text to the part points * Add link text to the part points
*/ */
points[ids.textLink] = text.link points[ids.textLink] = text.link.addText(mc.link, mc.classes.link).attr('data-text-lineheight', 4)
.addText('freesewing.org/patrons/join', mc.classes.link)
.attr('data-text-lineheight', 4)
/* /*
* Add metric instructions text to the part points * Add metric instructions text to the part points
*/ */
points[ids.textMetric] = text.metric points[ids.textMetric] = text.metric
.attr('data-text', 'theWhiteInsideOfThisBoxShouldMeasure') .attr('data-text', 'plugin-annotations:theWhiteInsideOfThisBoxShouldMeasure')
.attr('data-text', mdw) .attr('data-text', mdw)
.attr('data-text', 'x') .attr('data-text', 'x')
.attr('data-text', mdh) .attr('data-text', mdh)
@ -235,7 +234,7 @@ const scalebox = function (config, { store, points, paths, scale, Point, Path, c
* Add imperial instructions text to the part points * Add imperial instructions text to the part points
*/ */
points[ids.textImperial] = text.imperial points[ids.textImperial] = text.imperial
.attr('data-text', 'theBlackOutsideOfThisBoxShouldMeasure') .attr('data-text', 'plugin-annotations:theBlackOutsideOfThisBoxShouldMeasure')
.attr('data-text', idw) .attr('data-text', idw)
.attr('data-text', 'x') .attr('data-text', 'x')
.attr('data-text', idh) .attr('data-text', idh)

View file

@ -4,13 +4,14 @@ import { getIds } from './utils.mjs'
* Defaults for the sewtogether macro * Defaults for the sewtogether macro
*/ */
const macroDefaults = { const macroDefaults = {
id: 'sewtogether',
force: false,
classes: { classes: {
curve: 'dotted note stroke-sm', curve: 'dotted note stroke-sm',
hinge: 'note dotted stroke-sm', hinge: 'note dotted stroke-sm',
text: 'center fill-note text-xs', text: 'center fill-note text-xs',
}, },
id: 'sewtogether',
force: false,
text: 'plugin-annotations:sewTogether',
} }
// Export defs // Export defs
@ -101,7 +102,7 @@ const sewtogether = function (config, { points, paths, Path, complete, sa, store
.attr('class', mc.classes.curve) .attr('class', mc.classes.curve)
.attr('marker-start', 'url(#sewTogetherStart)') .attr('marker-start', 'url(#sewTogetherStart)')
.attr('marker-end', 'url(#sewTogetherEnd)') .attr('marker-end', 'url(#sewTogetherEnd)')
.addText('sewTogether', mc.classes.text) .addText(mc.text, mc.classes.text)
/* /*
* Draw the hinge, if needed * Draw the hinge, if needed

View file

@ -13,7 +13,7 @@ const macroDefaults = {
nr: 1, nr: 1,
rotation: 0, rotation: 0,
scale: 1, scale: 1,
title: 'title', title: 'plugin-annotations:noName',
classes: { classes: {
cutlist: 'text-md fill-current', cutlist: 'text-md fill-current',
date: 'text-sm fill-current', date: 'text-sm fill-current',
@ -144,7 +144,7 @@ const addTitleMacro = function (
points[id] = mc.at points[id] = mc.at
.clone() .clone()
.shift(-90, shift) .shift(-90, shift)
.attr('data-text', 'plugin:cut') .attr('data-text', 'plugin-annotations:cut')
.attr('data-text-class', `${mc.classes.cutlist} ${mc.align}`) .attr('data-text-class', `${mc.classes.cutlist} ${mc.align}`)
.attr('data-text-transform', transform) .attr('data-text-transform', transform)
.addText(cut) .addText(cut)
@ -153,21 +153,23 @@ const addTitleMacro = function (
/* /*
* Add instructions if parts are mirrored * Add instructions if parts are mirrored
*/ */
if (!identical && cut > 1) points[id].addText('plugin:mirrored') if (!identical && cut > 1) points[id].addText('plugin-annotations:mirrored')
/* /*
* Add instructions if parts are cut on fold * Add instructions if parts are cut on fold
*/ */
if (partCutlist.cutOnFold && !ignoreOnFold) if (partCutlist.cutOnFold && !ignoreOnFold)
points[id].addText(bias ? 'plugin:onFoldAndBias' : 'plugin:onFoldLower') points[id].addText(
bias ? 'plugin-annotations:onFoldAndBias' : 'plugin-annotations:onFold'
)
/* /*
* Add instructions if parts on on bias * Add instructions if parts on on bias
*/ else if (bias) points[id].addText('plugin:onBias') */ else if (bias) points[id].addText('plugin-annotations:onBias')
/* /*
* Add 'from' (material) text * Add 'from' (material) text
*/ */
points[id].addText('plugin:from').addText('plugin:' + material) points[id].addText('plugin-annotations:from').addText('plugin-annotations:' + material)
}) })
} }
} }
@ -181,8 +183,8 @@ const addTitleMacro = function (
.shift(-90, shift) .shift(-90, shift)
.attr( .attr(
'data-text', 'data-text',
`${(store.data?.name || 'noName').replace('@freesewing/', '')} v ${ `${(store.data?.name || 'plugin-annotations:noName').replace('@freesewing/', '')} v ${
store.data?.version || 'noVersion' store.data?.version || 'plugin-annotations:noVersion'
}` }`
) )
.attr('data-text-class', `${mc.classes.name} ${mc.align}`) .attr('data-text-class', `${mc.classes.name} ${mc.align}`)