Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-gettext

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-gettext

i18n gettext.js wrapper for Ember controllers and Handlebars templates

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ember-gettext

i18n gettext.js wrapper for Ember controllers and Handlebars templates

Installation

  1. Retrieve ember-gettext:
bower install ember-gettext --save
  1. Include it in your project:
<script src="./bower_components/gettext.js/dist/gettext.js"></script>
<script src="./bower_components/ember-gettext/lib/ember-gettext.js"></script>

or in your Brocfile if you use ember-cli.

  1. Load your messages

Wherever it suits in your project, load your messages:

Ember.I18n.loadJSON({...});

Your JSON format must be the gettext.js required one

  1. Set the current locale

You could do it from your dom

<html lang="fr">

or from javascript

i18n.setLocate('fr');

Usage

In your controllers

- Singular forms:
Ember.I18n._t("I like apples.");
Ember.I18n._t("I like {{ fruit }}.", {fruit: "bananas"});
- Plural forms:

You must use a count parameter to indicate gettext which plural form to choose

Ember.I18n._n("There is {{ count }} apple", "There are {{ count }} apples", { count: 42 });
Ember.I18n._n("There is {{ count }} apple in the {{ where }}", "There are {{ count }} apples in the {{ where }}", { count: 12, where: "fridge" });

In your templates

- Singular forms:
<p>{{_t "I like apples." }}</p>
<p>{{_t "I like {{ fruit }}." fruit="bananas" }}</p>
- Plural forms:

You must use a count parameter to indicate gettext which plural form to choose

<p>{{_n "There is {{ count }} apple" "There are {{ count }} apples" count=42 }}</p>
<p>{{_n "There is {{ count }} apple in the {{ where }}" "There are {{ count }} apples in the {{ where }}" count=12 where="fridge" }}</p>
- Binded values

You could of course use binded values to be interpreted and automatically re-rendered

<p>{{_t "Hello {{ firstname }} firstnameBinding="user.firstname" }}</p>
<p>{{_n "There is {{ count }} apple in the {{ where }}" "There are {{ count }} apples in the {{ where }}" countBinding="fruits.count" whereBinding="fruits.container" }}</p>

License

MIT

Keywords

FAQs

Package last updated on 29 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc