fix: Handle loading of plugin i18n data in workbench
This commit is contained in:
parent
24851967ef
commit
4aa3c2786b
5 changed files with 24 additions and 4 deletions
|
@ -16,6 +16,7 @@
|
|||
"onFold": "on the fold",
|
||||
"onFoldAndBias": "on the fold, and on bias",
|
||||
"sewTogether": "Sew together",
|
||||
"theBlackOutideOfThisBoxShouldMeasure": "The (black) outside of this box should measure",
|
||||
"supportFreeSewingBecomeAPatron": "Support FreeSewing, become a patron",
|
||||
"theBlackOutsideOfThisBoxShouldMeasure": "The (black) outside of this box should measure",
|
||||
"theWhiteInsideOfThisBoxShouldMeasure": "The (white) inside of this box should measure"
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ const macroDefaults = {
|
|||
},
|
||||
lead: 'FreeSewing',
|
||||
link: 'FreeSewing.org/patrons/join',
|
||||
text: 'plugin-annotations:supportFreesewingBecomeAPatron',
|
||||
text: 'plugin-annotations:supportFreeSewingBecomeAPatron',
|
||||
title: false,
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ export const ns = [
|
|||
...logNs,
|
||||
...inspectNs,
|
||||
...measiesNs,
|
||||
'plugin-annotations',
|
||||
]
|
||||
|
||||
const defaultUi = {
|
||||
|
@ -184,14 +185,13 @@ export const Workbench = ({ design, Design, DynamicDocs }) => {
|
|||
const pattern =
|
||||
(Design.patternConfig.measurements.length === 0 || settings.measurements !== undefined) &&
|
||||
new Design({ layout, embed: true, ...settings })
|
||||
|
||||
// Return early if the pattern is not initialized yet
|
||||
if (typeof pattern.getConfig !== 'function') return null
|
||||
|
||||
const patternConfig = pattern.getConfig()
|
||||
if (ui.renderer === 'svg') {
|
||||
// Add theme to svg renderer
|
||||
pattern.use(pluginI18n, (key) => t(key, { ns: design }))
|
||||
pattern.use(pluginI18n, (key) => t(key))
|
||||
pattern.use(pluginTheme, { skipGrid: ['pages'] })
|
||||
}
|
||||
|
||||
|
|
5
sites/shared/i18n/plugins.mjs
Normal file
5
sites/shared/i18n/plugins.mjs
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { i18n as annotations } from '@freesewing/plugin-annotations'
|
||||
|
||||
export const plugins = {
|
||||
'plugin-annotations': annotations,
|
||||
}
|
|
@ -5,6 +5,7 @@ import yaml from 'js-yaml'
|
|||
import { fileURLToPath } from 'url'
|
||||
import allLanguages from '../../../config/languages.json' assert { type: 'json' }
|
||||
import { designs } from '../i18n/designs.mjs'
|
||||
import { plugins } from '../i18n/plugins.mjs'
|
||||
|
||||
/*
|
||||
* This is where we configure what folders we should check for
|
||||
|
@ -209,6 +210,19 @@ export const prebuildI18n = async (store) => {
|
|||
}
|
||||
for (const language of languages) writeJson(store.site, language, 'designs', designNs[language])
|
||||
|
||||
/*
|
||||
* Handle plugin translations
|
||||
*/
|
||||
const pluginNs = {}
|
||||
for (const plugin in plugins) {
|
||||
for (const language of languages) {
|
||||
if (typeof pluginNs[language] === 'undefined') pluginNs[language] = {}
|
||||
// Write out plugin namespace files
|
||||
writeJson(store.site, language, plugin, plugins[plugin][language])
|
||||
}
|
||||
}
|
||||
for (const language of languages) writeJson(store.site, language, 'plugins', pluginNs[language])
|
||||
|
||||
/*
|
||||
* Update the store
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue