Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

mi18n

Draggable3.3kMIT1.0.3

A simple yet robust i18n solution for universal JavaScript apps.

i18n

readme

mi18n npm version

Add multi-lingual support to any JavaScript app or module with this light-weight package.

Features:

  • Isomorphic/Universal
  • easy translation of static text files
    • benefits: anyone can translate, no more xliff
    • reduced margin of error.
  • Variable support
  • Dependency free
  • Fast

Usage

import { I18n } from 'mi18n'

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>

Add a Language after initialization

i18n.addLanguage('fr-FR', {
  addOption: 'Ajouter une option',
})

Process a confige file

i18n.processConfig(configFileString)

Example .lang file

de-DE = Deutsch
en-US = German

addOption = Option hinzufügen
allFieldsRemoved = Alle Felder wurden entfernt.
allowMultipleFiles = Upload mehrerer Dateien erlauben
autocomplete = Autovervollständigung

changelog

1.0.3 (2024-10-20)

Bug Fixes

1.0.2 (2024-10-20)

Bug Fixes

1.0.1 (2024-10-20)

Bug Fixes

1.0.0 (2024-10-20)

chore

BREAKING CHANGES

  • the build outputs have changed

  • chore: remove unused files

  • chore: update checkout from v2 to v4

0.4.8 (2018-11-05)

Bug Fixes

  • getValue: Add reminder to add tests for getValue (#22) (f948d9c)

0.4.7 (2018-11-02)

Bug Fixes

  • getValue: Add reminder to add tests for getValue, hopefulyl trigger a release (4a7fa02)

0.4.6 (2018-08-14)

Bug Fixes

0.4.5 (2018-08-14)

Bug Fixes

  • npm: dist files should be in npm release (c7c8494)

0.4.4 (2018-08-14)

Bug Fixes

  • npm: files missing from published npm (821c570)

0.4.3 (2018-08-14)

Bug Fixes

  • ci: build not completing (7dea86a)
  • ci: do not install travis-deploy-once globally (90f024d)
  • ci: move after_success to get branches tagged and hopefully auto-updated changelog (ce8d761)
  • ci: Update travis-ci config (378a072)
  • ci: Use multiple stages for travis-ci (e8e43e7)
  • now: deploy (31eac82)
  • semantic-release: add required semantic-release plugins (2af43b2)
  • webpack: absolute url no longer needed in webpack, remove unused files, bithound is dead (0318e10)
  • webpack: Update modules and webpack config, add test case for string with vars (7766316)

mi18n Changelog

  • v0.4.3 - Fix now.sh deploy
  • v0.4.2 - Add semantic release script, fix deploy bug, update changelog.md
  • v0.4.1 - Change preloaded to override, fix bug where overrides would replace loaded languages
  • v0.3.4 - Merge pull request #8 from kevinchappell/chore/update-test
  • v0.3.3 - Merge pull request #3 from Draggable/async
  • v0.3.2 - Merge pull request #2 from Draggable/hotfix/update-tagger
  • v0.3.1 - Chore/Bugfix: Changed how default locale is defined