Add multi-lingual support to any JavaScript app or module with this light-weight package.
- Isomorphic/Universal
- easy translation of static text files
- benefits: anyone can translate, no more xliff
- reduced margin of error.
- Variable support
- Dependency free
- Fast
import { I18n } from '@draggable/i18n'
const i18nOptions = {
extension: '.lang', // extnsion used by your language files, defaults to ".lang"
location: 'https://location.of/language/files/', // absolute or relative url to language files
langs: [
// locales you would like to be active
'en-US',
'pt-BR',
'de-DE', // will attempt to load `https://location.of/language/files/de-DE.lang` with current config
],
locale: 'en-US', // default locale
override: {
'en-US': {
autocomplete: 'Autofinish', // override individual keys or provide entire language definition
},
},
}
const i18n = new I18n(i18nOptions)
... then in your app
<label>{i18n.get('addOption')}</label>
i18n.addLanguage('fr-FR', {
addOption: 'Ajouter une option',
})
i18n.processConfig(configFileString)
de-DE = Deutsch
en-US = German
addOption = Option hinzufügen
allFieldsRemoved = Alle Felder wurden entfernt.
allowMultipleFiles = Upload mehrerer Dateien erlauben
autocomplete = Autovervollständigung