Skip to content

Namespaces

Anthony Fu edited this page Apr 22, 2020 · 5 revisions

Available from 1.14.0

Some i18n frameworks (e.g. i18next, Laravel) support namespaces. It basically maps your locale file names to the root for your i18n keys.

Examples, with namespaces

// en/common.json

{
  "hello": "Hello",
  "foo": {
    "bar": "Foobar"
  }
}
// app.js

i18n.t('common.hello') // Hello
i18n.t('common.foo.bar') // Foobar

This feature is disabled by default, but can be enabled by the framework you use (Laravel for example). You can also set it explicitly.

"i18n-ally.namespace": true

For more complex use cases, please refer to Path Matcher.