Skip to content

creatubbles/ember-cli-gettext

 
 

Repository files navigation

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

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 83.2%
  • HTML 16.8%