Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #229 from cibernox/add_initializers_order_to_readme
Browse files Browse the repository at this point in the history
Explain that you can't translate until `ember-i18n` initializer runs
  • Loading branch information
jamesarosen committed Jun 15, 2015
2 parents a42a845 + fcfbef5 commit 1780680
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ injected into every Route, Controller and Component in your app. If you need it
elsewhere, you can register your own injection:

```js
// app/initializers/i18n.js
// app/instance-initializers/i18n.js

export default {
name: 'i18n',
Expand All @@ -92,6 +92,21 @@ export default Ember.Object.extend({
});
```

If you want to use i18n from within an initializer you need to make sure that it runs after the
`ember-i18n` initializer has been executed.

```js
// app/instance-initializers/my-initializer.js

export default {
name: 'my-initializer',
after: 'ember-i18n',
initialize: function({ container }) {
const i18n = container.lookup('service:i18n');
document.title = i18n.t('some.translation');
}
};

#### Adding Translations at Runtime

If you have a translations API (so you can manage them across apps centrally
Expand Down

0 comments on commit 1780680

Please sign in to comment.