-
Notifications
You must be signed in to change notification settings - Fork 0
05. Plugins Translations
Add all the plugins translations in one command, this function is only recommended for plugins with a few translations and single file plugins, if there are many translations it is recommended to use addTranslationFiles() described below.
namespaceshould be the plugins name eg:plugin-conference
translationsrequires an object with a key for each language supported'en-us' is used for fallback so must be provided
Example:
kiwi.addTranslations('plugin-ignorelist', {
'en-us': {
ignore_list: 'Ignore List',
ignore_list_empty: 'ignore list empty'
},
'es-es': {
ignore_list: 'Lista de ignorados',
ignore_list_empty: 'lista de ignorados vacia',
},
});Add a namespace with url to translation files
namespaceshould be the plugins name eg:plugin-conference
urlpath to the language json file
fallbackLocaleoptional fallback 'en-us' translations [if not provided will be requested from url]supported
urlreplacements:
{{lng}}is replaced with language eg: 'en-us'{{ns}}is replaced with namespace eg: 'plugin-conference''en-us' is used for fallback so a file for it must be provided
Example:
import FallbackLocale from '../res/locales/en-us.json'; // note: import is only supported in webpack bundles
kiwi.addTranslationFiles(
'plugin-ignorelist',
'static/plugins/plugin-ignorelist/locales/{{lng}}.json',
FallbackLocale, // optional
);within <template>
<div>{{ $t('plugin-ignorelist:ignore_list_empty') }}</div>within javascript
const TextFormatting = kiwi.require('helpers/TextFormatting');
const myTranslation = TextFormatting.t('plugin-ignorelist:ignore_list');