You are looking at the old Apostrophe 0.5 documentation. It is deprecated for new projects. Check out the latest version!


← Previous: Setting up Modules

Internationalizing the user interface

Enable internationalization of the user interface by adding the following in your apostrophe-site configuration in app.js:

i18n: {
  // setup some locales - other locales default to defaultLocale silently
  locales:['en', 'de'],

  // you may alter a site wide default locale (optional, defaults to 'en')
  defaultLocale: 'de',

  // sets a custom cookie name to parse locale settings from  - defaults to apos_language (optional)
  cookie: 'yourcookiename',

  // whether to write new locale information to disk automatically - defaults to true (you will want to shut it off in production)
  // updateFiles: false

After doing this, you can internationalise text in your own templates with:

{{ __('A sample string') }}

The __ local will take care of language detection and will spit out the appropriate string from the JSON files that will be located in the locales folder of your project by default. If you look in that folder, you'll see multiple JSON files with a two letter language abbreviation as a filename, for instance:


Those will contain all the necessary strings. By default, i18n will automatically put anything new it finds there. However, you can disable this behaviour by setting updateFiles to false.

If you find text in our templates that is not internationalized, pull requests are welcome!

Internationalizing and localizing your website's content

To localize or internationalize the content of your actual pages, you'll want to check out the optional apostrophe-localization module. See the documentation of that module for complete instructions.

Next: Snippets →