ember-cli-pod-translations

0.0.4 • Public • Published

ember-cli-pod-translations

Build Status

An addon to compile your locale files inside pods.

Installation

$ ember install ember-cli-pod-translations

Usage

  1. 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"
    }
  2. Extend your component, controller or route with the Localizable mixin

    NOTE: This is required for both the JS and template usage

    // app/pods/components/x-foo/component.js
    
    import Ember from 'ember';
    import Localizable from 'ember-cli-pod-translations/mixins/localizable';
    import translations from './translations';
    
    export default Ember.Component.extend(Localizable(translations));
  3. Use your translations in your Ember object

    // app/pods/components/x-foo/component.js
    
    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');
      })
    });
  4. 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 # Runs `ember try:each` to test the addon against multiple Ember versions
$ 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.

Readme

Keywords

Package Sidebar

Install

npm i ember-cli-pod-translations

Weekly Downloads

4

Version

0.0.4

License

BSD-3-Clause

Last publish

Collaborators

  • mirego-dev