creatubbles / ember-cli-gettext

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ember-cli-gettext

This README outlines the details of collaborating on this Ember addon.

This addon depends on gettext.js (https://github.com/guillaumepotier/gettext.js).

Installation

ember install ember-cli-gettext

Configuration

To load all translations at build time, use the following code in your environment.js:

var translations = {}
for (var locale of ['en', 'ja']) {
  translations[locale] = JSON.parse(fs.readFileSync('locale/'+locale+'.json', { encoding: 'utf8' }));
}
ENV['gettext'] = { defaultLocale: 'ja', translations: translations }

and to your app.js should contain something like:

App = Ember.Application.extend({
  gettext: config.gettext
});

This would setup your project to default to Japanese locale, and load English and Japanese translations from locale/{{locale}}.json. The JSON files should be follow the format documented in gettext.js readme.

Using

In your templates you can use the following two helpers:

All helpers take an additional hash used to interpolate the given string.

About

License:MIT License


Languages

Language:JavaScript 83.2%Language:HTML 16.8%