# Internationationalization (I18n)

Internationalization allows you to define language mappings in separate js files.

To enable i18n, put an i18n folder in your package path and add a javascript file named for each language code (e.g. `en.js` for english).

Here's an example of defining a language mapping:

```javascript
// en.js
module.exports = {
  'search': 'Search',
  'edit': 'Edit',
};

// zh.js
module.exports = {
  'search': '搜索',
  'edit': '编辑',
};
```

The file will be register to i18n table by the key of your `package-name`.

## Translating your text

In javascript code, you can translate a text by `Editor.T`:

```javascript
// NOTE: my package name is "foobar"
Editor.T('foobar.search');
```

You can also perform language mappings in your panel template:

```javascript
// NOTE: my package name is "foobar"
Editor.Panel.extend({
  template: `
    <div class="btn">${Editor.T('foobar.edit')}</div>
  `
});
```

## Choosing a language

By default, Editor-Framework uses the `--lang` command option to setup language. This command
will set the `Editor.lang` when editor initialized via the `init` callback. Also, when a package is loading, it will load the i18n
file through the path `./i18n/${Editor.lang}.js`.

## i18n in Menu Path

TODO
