1
0
Fork 0

fix(docs): Update plugins documentation

This commit is contained in:
Benjamin F 2022-12-13 04:39:07 -08:00
parent 7063d8ab9f
commit 767d835cc6
23 changed files with 272 additions and 51 deletions

View file

@ -3,7 +3,8 @@ title: plugin-i18n
---
Published as [@freesewing/plugin-i18n][1], this plugin faciliates
translation of your designs.
translation of your designs by allowing you to provide your own
language translations.
## Installation
@ -17,30 +18,52 @@ Either [add it as a part plugins](/reference/api/part/config/plugins) in your
design, or [add it to a pattern instance with
Pattern.use()](/reference/api/pattern/use).
To import the plugin for use:
```js
import { i18nPlugin } from '@freesewing/plugin-i18n'
// or
import { pluginI18n } from '@freesewing/plugin-i18n'
```
## Notes
This plugin provides the mechanism for translation, but does not come with
This plugin provides the mechanism for translation but does not come with
translations itself. For this, you can use our [i18n
package](/reference/packages/i18n).
package](https://www.npmjs.com/package/@freesewing/i18n).
To add (your own) translations, you should pass data to this plugin.
It should be structured as such:
To add your own translations, you will need to pass data to this plugin
containing translation keys and the translations for them for each language.
The data should be in the form of an `Object` structured as such:
```js
{
strings:
en: {
example: "Example"
example: "Example",
examplePhrase: "An example phrase",
anotherTranslationKey: "(English translation for the translation key)",
// More translations can follow...
},
nl: {
example: "Voorbeeld"
example: "Voorbeeld",
examplePhrase: "Een voorbeeldzin",
anotherTranslationKey: "(Dutch translation for the translation key)",
// More translations can follow...
},
// More languages can follow
es: {
example: "Ejemplo",
examplePhrase: "Una frase de ejemplo",
anotherTranslationKey: "(Spanish translation for the translation key)",
// More translations can follow...
},
// More languages can follow...
}
}
```
The i18n plugin is part of our [plugin-bundle](/reference/plugins/bundle)
<Related compact>
To learn more about using translations in a design, see the
[Translation guide](/guides/translation/)
</Related>
[1]: https://www.npmjs.com/package/@freesewing/plugin-i18n