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

Doc: i18n Service

James Alexander Rosen edited this page Jun 24, 2015 · 7 revisions

i18n Service

Many pieces of ember-i18n rely on the service:i18n. Ask for it wherever you need (likely in Routes and Components):

// app/routes/post.js

export default Ember.Object.extend({
  i18n: Ember.inject.service(),

  afterModel: function(post) {
    document.title = this.get('i18n').t('title.post', { post: post });
  }
});

If you find yourself needing it in many places, you can declare an injection:

// app/initializers/i18n.js

export default {
  name: 'i18n',

  after: 'ember-i18n',

  initialize: function(_, app) {
    app.inject('model', 'i18n', 'service:i18n')
  }
};