broccoli-i18n-lazy-lookup

0.0.4 • Public • Published

Broccoli's I18n Lazy Lookup

Build Status

Summary

Broccoli's I18n Lazy Lookup is made to add support for lazy lookup in Ember I18n. This Broccoli filter is best used with ember-cli-i18n-lazy-lookup.

The concept is to automatically prefix your I18n key using the current file path. To do so, start your translation key by a . and it will replaced by the current file path.

Examples

In controllers and components

within app/controllers/posts/edit.js

nameTranslation: '.name'

it will get converted to:

nameTranslation: 'posts.edit.name'

In templates

within app/templates/posts/edit.hbs

{{t '.save'}}

will get converted to:

{{t 'posts.edit.save'}}

but also app/templates/posts/edit.hbs

{{input author as="select"
    collection="controller.authors"
    selection="controller.post.author"
    optionLabelPath="content.name"
    promptTranslation=".select_author"
  }}

will get converted to:

{{input author as="select"
    collection="controller.authors"
    selection="controller.post.author"
    optionLabelPath="content.name"
    promptTranslation="posts.edit.select_author"
  }}

In partial templates, the prefixing dash will be ignored when generating the translation key, so within app/templates/post/-form.hbs

{{t '.submit'}}

will get converted to:

{{t 'posts.form.submit'}}

Installation

npm install --save-dev broccoli-i18n-lazy-lookup

Note: For Ember CLI installation, please check ember-cli-i18n-lazy-lookup.

Usage

Assuming installation via NPM, you can use broccoli-i18n-lazy-lookup in your Brocfile.js like this:

var filterI18nLazyLookup = require('broccoli-i18n-lazy-lookup');
tree = filterI18nLazyLookup(tree);

Note: To use with Ember CLI, please check ember-cli-i18n-lazy-lookup instead.

Tests

Running the tests:

npm install
npm test

License

This project is distributed under the MIT license.

Package Sidebar

Install

npm i broccoli-i18n-lazy-lookup

Weekly Downloads

1

Version

0.0.4

License

MIT

Last publish

Collaborators

  • sebgrosjean