ember-cli-pod-translations
An addon to compile your locale files inside pods.
Installation
$ ember install ember-cli-pod-translations
Usage
-
Create translation files for your components, controllers or routes
For example, we could create an english file app/pods/components/x-foo/translations.en.json
{
"hello_world": "Hello World"
}
Then a french file app/pods/components/x-foo/translations.fr.json
:
{
"hello_world": "Bonjour le monde"
}
-
Extend your component, controller or route with the Localizable
mixin
NOTE: This is required for both the JS and template usage
import Ember from 'ember';
import Localizable from 'ember-cli-pod-translations/mixins/localizable';
import translations from './translations';
export default Ember.Component.extend(Localizable(translations));
-
Use your translations in your Ember object
import Ember from 'ember';
import Localizable from 'ember-cli-pod-translations/mixins/localizable';
import translations from './translations';
export default Ember.Component.extend(Localizable(translations), {
helloString: computed(function() {
return this.localTranslation('hello_world');
})
});
-
Use your translations in your template
{{!-- app/pods/components/x-foo/template.hbs --}}
{{local-t localizablePrefix 'hello_world'}}
You can also use a "raw" translation which is not wrapped in a SafeString for ember-moment for example:
{{moment-format date (local-t-raw localizablePrefix 'date_format')}}
Contributing
$ git clone https://github.com/mirego/ember-cli-pod-translations
$ cd ember-cli-pod-translations
$ yarn install
Running the dummy app
$ ember serve
Visit your app at http://localhost:4200.
Running tests
$ npm test
$ ember test
$ ember test --server
Building
$ ember build
For more information on using ember-cli, visit https://ember-cli.com/.
License
ember-cli-pod-translations
is © 2017 Mirego and may be freely distributed under the New BSD license.
See the LICENSE.md
file.
About Mirego
Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We're a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.
We also love open-source software and we try to give back to the community as much as we can.