Skip to content

Instantly share code, notes, and snippets.

@cbou
Last active June 5, 2018 10:37
Show Gist options
  • Save cbou/910eefc652a09838b15674ffe8e39cd3 to your computer and use it in GitHub Desktop.
Save cbou/910eefc652a09838b15674ffe8e39cd3 to your computer and use it in GitHub Desktop.
i18n
import Ember from 'ember';
import { translationMacro as t } from "ember-i18n";
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
i18n: Ember.inject.service(),
init: function() {
console.log(this.get('i18n').t('plural', {count: 1}).toString());
console.log(this.get('i18n').t('plural', {count: 0}).toString());
console.log(this.get('i18n').t('plural', {count: 1}).toString());
}
});
// Ember-I18n includes configuration for common locales. Most users
// can safely delete this file. Use it if you need to override behavior
// for a locale or define behavior for a locale that Ember-I18n
// doesn't know about.
export default {
// rtl: [true|FALSE],
//
pluralForm: function(count) {
if (count === 0) { return 'zero'; }
if (count === 1) { return 'one'; }
if (count === 2) { return 'two'; }
if (count < 5) { return 'few'; }
if (count >= 5) { return 'many'; }
return 'other';
}
};
export default {
"plural": {
"zero": "Zero plural",
"other": "Other plural"
}
}
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{
"version": "0.13.1",
"EmberENV": {
"FEATURES": {}
},
"i18n": {
"defaultLocale": "en"
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3",
"ember-i18n": "5.2.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment