Search result not found.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

On this page

Locize Docs

Introduction

Using locize

Integration

Guides / Tips & Tricks

More

Which integration option should I use?Do I have to use the locize CDN or can I host / bundle the translations directly?How is locize different from the alternatives?Why do I get “The passed json is nested too deeply.” when consuming the API?Is locize only for developers and translators or is project management within the process too?What is the regular way to update the translation memory?Is there any visibility on project’s level of completion that shows how translators are progressing?Why is my namespace suddenly a flat json?How to change the publish format?Why does my namespace contain an array with a lot of null items?Why is the pricing so complicated?How to change credit card or billing information or download the invoices?How to import translations from a file?How to manually publish a specific version?How to delete or rename a namespace?Why is there such a high download amount?Where do I find the namespace backups?How can a segment/key be copied/moved or renamed?Why a new namespace is created, when I upload a translation file?I want to use the locize CDN, but would like to have a fallback that uses local/bundled translationsIs it possible to integrate multiple projects in the same app/website?Why do I see strange new keys marked as ONE, FEW, MANY, OTHERS?How do I open and edit JSON files?i18n vs. i18nexti18next vs. locizeWord CounterHow to style text within locize?What do I have to consider if my translation texts may contain confidential information?How to translate a file and download the results?

Namespaces

Namespaces are a feature in i18next internationalization framework which allows you to separate translations that get loaded into multiple files.

While in a smaller project it might be reasonable to just put everything in one file you might get at a point where you want to break translations into multiple files. Reasons might be:

  • You start loosing the overview having more than 300 segments in a file
  • Not every translation needs to be loaded on the first page, speed up load time
We recommend you to create multiple smaller namespaces.

Semantic reasons

Often you wish to separate some segments out because they belong together. We do this in most of our projects, eg.:

  • common.json -> Things that are reused everywhere, eg. Button labels 'save', 'cancel'
  • validation.json -> All validation texts
  • glossary.json -> Words we want to be reused consistent inside texts sample usage

Technical / editoral reasons

More often you don't want to load all the translations upfront or at least reduce the amount loaded. This reason often goes hand in hand with the one translation file gets to large and you start loosing the overview scrolling through hundred of text fragments.

  • namespace per view/page
  • namespace per application section / feature set (admin area, ...)
  • namespace per module which gets lazy loaded (single page applications)

Configuration / Usage:

locize / i18next

i18next.init({
  ns: ['common', 'moduleA', 'moduleB'],
  defaultNS: 'moduleA'
}, (err, t) => {
  i18next.t('myKey'); // key in moduleA namespace (defined default)
  i18next.t('myKey', { ns: 'common' }); // key in common namespace
  i18next.t('common:myKey'); // key in common namespace
});

// load additional namespaces after initialization
i18next.loadNamespaces('myNamespace', (err, t) => { /* ... */ });

There are advanced options like:

  • calling t function with multiple namespaces to look a key up
  • default fallback namespaces to lookup keys in

more details: locize / i18next

locizify

locizify.init({
  namespace: 'myNamespace'
  ns: ['common', 'myNamespace'] // -> add additional namespaces to load
});

You can access a different namespace by setting the attribute i18next-options:

<div i18next-options='{"ns": "common"}'>
  <p>different namespace common is used</p>
  <p>all the way down</p>
</div>

Optionally you can set locizify to create a namespace per location/route.

locizify.init({
  namespaceFromPath: true
});

more details: locizify

Last updated 1 year ago