2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-10-02 00:27:09 +02:00
|
|
|
title: plugin-i18n
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-14 12:52:37 -08:00
|
|
|
Published as [@freesewing/plugin-i18n][1], this plugin facilitates
|
2022-12-13 04:39:07 -08:00
|
|
|
translation of your designs by allowing you to provide your own
|
|
|
|
language translations.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2022-10-02 00:27:09 +02:00
|
|
|
```sh
|
2021-08-25 16:09:31 +02:00
|
|
|
npm install @freesewing/plugin-i18n
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2022-10-02 00:27:09 +02:00
|
|
|
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).
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-13 04:39:07 -08:00
|
|
|
To import the plugin for use:
|
|
|
|
```js
|
|
|
|
import { i18nPlugin } from '@freesewing/plugin-i18n'
|
|
|
|
// or
|
|
|
|
import { pluginI18n } from '@freesewing/plugin-i18n'
|
|
|
|
```
|
|
|
|
|
2022-10-02 00:27:09 +02:00
|
|
|
## Notes
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-13 04:39:07 -08:00
|
|
|
This plugin provides the mechanism for translation but does not come with
|
2024-09-28 13:13:48 +02:00
|
|
|
translations itself. For this, you can use our [i18n
|
2022-12-13 04:39:07 -08:00
|
|
|
package](https://www.npmjs.com/package/@freesewing/i18n).
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-13 04:39:07 -08:00
|
|
|
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:
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```js
|
|
|
|
{
|
|
|
|
strings:
|
|
|
|
en: {
|
2022-12-13 04:39:07 -08:00
|
|
|
example: "Example",
|
|
|
|
examplePhrase: "An example phrase",
|
|
|
|
anotherTranslationKey: "(English translation for the translation key)",
|
|
|
|
// More translations can follow...
|
2021-08-25 16:09:31 +02:00
|
|
|
},
|
|
|
|
nl: {
|
2022-12-13 04:39:07 -08:00
|
|
|
example: "Voorbeeld",
|
|
|
|
examplePhrase: "Een voorbeeldzin",
|
|
|
|
anotherTranslationKey: "(Dutch translation for the translation key)",
|
|
|
|
// More translations can follow...
|
2021-08-25 16:09:31 +02:00
|
|
|
},
|
2022-12-13 04:39:07 -08:00
|
|
|
es: {
|
|
|
|
example: "Ejemplo",
|
|
|
|
examplePhrase: "Una frase de ejemplo",
|
|
|
|
anotherTranslationKey: "(Spanish translation for the translation key)",
|
|
|
|
// More translations can follow...
|
|
|
|
},
|
|
|
|
// More languages can follow...
|
2021-08-25 16:09:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
2022-10-02 00:27:09 +02:00
|
|
|
|
|
|
|
[1]: https://www.npmjs.com/package/@freesewing/plugin-i18n
|