ember-intl / ember-intl

Internationalization for Ember projects
https://ember-intl.github.io
MIT License
434 stars 167 forks source link

Consider message as default key #46

Closed bakura10 closed 9 years ago

bakura10 commented 9 years ago

Hi,

When formatting message, we are forced to specify the full path: {{format-message (intl-get 'messages.foo.bar')}}.

Can't this actually always assume that messages is the root, so that it allows us to simply refer to message using "foo.bar" instead of "messages.foo.bar" ? :)

jasonmit commented 9 years ago

This is already possible today. See my last set of comments in https://github.com/yahoo/ember-intl/issues/23

jasonmit commented 9 years ago

Update since I was on my phone and just want to make one point clear:

import Locale from 'ember-intl/models/locale';

// app/locales/en.js
export default Locale.extend({
  foo: 'bar'
});

{{format-message (intl-get 'foo')}} outputs bar

If this is the path you plan on taking, I suggest creating your own locales class which extends from ember-intl/models/locales where you implement your own addMessage/addMessages (if you plan to use them).

See: https://github.com/yahoo/ember-intl/blob/master/addon/models/locale.js#L12-L29

If you have no plans to sideload messages, then you can ignore changing them.