|
|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
## I18n |
|
|
|
|
|
|
|
You can customize the initial state of the module from the editor initialization |
|
|
|
You can customize the initial state of the module from the editor initialization, by passing the following [Configuration Object][1] |
|
|
|
|
|
|
|
```js |
|
|
|
const editor = grapesjs.init({ |
|
|
|
@ -10,9 +10,7 @@ const editor = grapesjs.init({ |
|
|
|
locale: 'en', |
|
|
|
localeFallback: 'en', |
|
|
|
messages: { |
|
|
|
en: { |
|
|
|
hello: 'Hello', |
|
|
|
}, |
|
|
|
it: { hello: 'Ciao', ... }, |
|
|
|
... |
|
|
|
} |
|
|
|
} |
|
|
|
@ -35,7 +33,7 @@ const i18n = editor.I18n; |
|
|
|
|
|
|
|
Get module configurations |
|
|
|
|
|
|
|
Returns **[Object][1]** Configuration object |
|
|
|
Returns **[Object][2]** Configuration object |
|
|
|
|
|
|
|
## setLocale |
|
|
|
|
|
|
|
@ -43,7 +41,7 @@ Update current locale |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `locale` **[String][2]** Locale value |
|
|
|
- `locale` **[String][3]** Locale value |
|
|
|
|
|
|
|
### Examples |
|
|
|
|
|
|
|
@ -57,7 +55,7 @@ Returns **this** |
|
|
|
|
|
|
|
Get current locale |
|
|
|
|
|
|
|
Returns **[String][2]** Current locale value |
|
|
|
Returns **[String][3]** Current locale value |
|
|
|
|
|
|
|
## getMessages |
|
|
|
|
|
|
|
@ -65,9 +63,9 @@ Get all messages |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `lang` **[String][2]?** Specify the language of messages to return |
|
|
|
- `opts` **[Object][1]?** Options (optional, default `{}`) |
|
|
|
- `opts.debug` **[Boolean][3]?** Show warnings in case of missing language |
|
|
|
- `lang` **[String][3]?** Specify the language of messages to return |
|
|
|
- `opts` **[Object][2]?** Options (optional, default `{}`) |
|
|
|
- `opts.debug` **[Boolean][4]?** Show warnings in case of missing language |
|
|
|
|
|
|
|
### Examples |
|
|
|
|
|
|
|
@ -78,7 +76,7 @@ i18n.getMessages('en'); |
|
|
|
// -> { hello: '...' } |
|
|
|
``` |
|
|
|
|
|
|
|
Returns **[Object][1]** |
|
|
|
Returns **[Object][2]** |
|
|
|
|
|
|
|
## setMessages |
|
|
|
|
|
|
|
@ -86,7 +84,7 @@ Set new set of messages |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `msg` **[Object][1]** Set of messages |
|
|
|
- `msg` **[Object][2]** Set of messages |
|
|
|
|
|
|
|
### Examples |
|
|
|
|
|
|
|
@ -107,7 +105,7 @@ Update messages |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `msg` **[Object][1]** Set of messages to add |
|
|
|
- `msg` **[Object][2]** Set of messages to add |
|
|
|
|
|
|
|
### Examples |
|
|
|
|
|
|
|
@ -128,10 +126,10 @@ Translate the locale message |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `key` **[String][2]** Label to translate |
|
|
|
- `opts` **[Object][1]?** Options for the translation (optional, default `{}`) |
|
|
|
- `opts.params` **[Object][1]?** Params for the translation |
|
|
|
- `opts.debug` **[Boolean][3]?** Show warnings in case of missing resources |
|
|
|
- `key` **[String][3]** Label to translate |
|
|
|
- `opts` **[Object][2]?** Options for the translation (optional, default `{}`) |
|
|
|
- `opts.params` **[Object][2]?** Params for the translation |
|
|
|
- `opts.debug` **[Boolean][4]?** Show warnings in case of missing resources |
|
|
|
|
|
|
|
### Examples |
|
|
|
|
|
|
|
@ -148,10 +146,12 @@ obj.t('msg2', { l: 'it', params: { test: 'hello' } }); // custom local |
|
|
|
// -> outputs `Msg hello it` |
|
|
|
``` |
|
|
|
|
|
|
|
Returns **[String][2]** |
|
|
|
Returns **[String][3]** |
|
|
|
|
|
|
|
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object |
|
|
|
[1]: https://github.com/artf/grapesjs/blob/master/src/i18n/config.js |
|
|
|
|
|
|
|
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String |
|
|
|
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object |
|
|
|
|
|
|
|
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean |
|
|
|
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String |
|
|
|
|
|
|
|
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean |
|
|
|
|