This repository has been archived by the owner on Apr 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 183
Doc: Defining Translations
James Alexander Rosen edited this page Jun 24, 2015
·
9 revisions
Put translation files in app/locales/[locale]/translations.js
. Each file should export an object. If the values are Function
s, they will be used as-is. If they are String
s, they will first be compiled using util:i18n/compile-translation
. A default Handlebars-like implementation is provided. See Doc: Overriding Translation Compiler for more information on overriding the compiler.
For example,
export default {
'user.edit.title': 'Edit User',
'user.followers.title.one': 'One Follower',
'user.followers.title.other': 'All {{count}} Followers',
// nested objects work just like dotted keys
'button': {
'add_user': {
'title': 'Add a user',
'text': 'Add',
'disabled': 'Saving...'
}
}
};
The locale generator will generate a new translations file for you:
$ ember generate locale es
If you have a translations API (so you can manage them across apps centrally or so you can deliver only the translations you need), you can add new translations at runtime via the service:i18n
:
this.get('i18n').addTranslations('en', {
'user.profile.gravatar.help': 'Manage your avatar at gravatar.com.'
});