ember-i18n
Advanced tools
Comparing version 2.2.1 to 2.2.3
{ | ||
"name": "ember-i18n", | ||
"version": "2.2.1", | ||
"version": "2.2.3", | ||
"description": "I18n support for Ember.js", | ||
@@ -5,0 +5,0 @@ "main": [ "lib/i18n.js" ], |
@@ -0,1 +1,11 @@ | ||
## 2.2.2 2014-09-16 | ||
* Use internal UUID generation, since implementations differ | ||
across Ember versions | ||
* Select template compiler on first use so | ||
`Ember.ENV.I18N_COMPILE_WITHOUT_HANDLEBARS` is sure to have | ||
been set properly. | ||
* Fix TranslateableAttributes tests on Ember Canary | ||
* Better messaging during the build process | ||
## 2.2.1 2014-08-17 | ||
@@ -2,0 +12,0 @@ |
## Running the tests | ||
You'll need [npm](https://npmjs.org) and `make`. | ||
You'll need [npm](https://npmjs.org), `make`, and [PhantomJS](http://phantomjs.org/). | ||
The default `make` target will run tests against several combinations of Ember, | ||
Handlebars, and jQuery. | ||
To run tests against a single combination, run `make test` with a set of environment | ||
variables set: | ||
```bash | ||
make test | ||
$ JQUERY_VERSION=2.0.3 EMBER_VERSION=canary HANDLEBARS_VERSION=1.3.0 make test | ||
``` | ||
@@ -8,0 +14,0 @@ |
(function(window) { | ||
var I18n, assert, findTemplate, get, set, isBinding, lookupKey, pluralForm, | ||
PlainHandlebars, EmHandlebars, keyExists, | ||
compileTemplate, compileWithHandlebars; | ||
PlainHandlebars, EmHandlebars, keyExists; | ||
@@ -69,4 +68,31 @@ PlainHandlebars = window.Handlebars; | ||
compileWithHandlebars = (function() { | ||
if (Ember.ENV.I18N_COMPILE_WITHOUT_HANDLEBARS === undefined) { | ||
var escapeExpression = EmHandlebars.Utils.escapeExpression; | ||
var compileImplementation; | ||
function compileTemplate(template) { | ||
if (compileImplementation === undefined) { | ||
compileImplementation = selectCompileImplementation(); | ||
} | ||
return compileImplementation(template); | ||
} | ||
function selectCompileImplementation() { | ||
var flag = Ember.ENV.I18N_COMPILE_WITHOUT_HANDLEBARS; | ||
if (flag === true) { | ||
return function compileWithoutHandlebars(template) { | ||
return function (data) { | ||
return template | ||
.replace(/\{\{\{(.*?)\}\}\}/g, function(i, match) { | ||
// tripple curlies -> no-escaping | ||
return get(data, match); | ||
}).replace(/\{\{(.*?)\}\}/g, function(i, match) { | ||
return escapeExpression( get(data, match) ); | ||
}); | ||
}; | ||
}; | ||
} | ||
if (flag === undefined) { | ||
warn("Ember.I18n will no longer include Handlebars compilation by default in the future; instead, it will supply its own default compiler. Set Ember.ENV.I18N_COMPILE_WITHOUT_HANDLEBARS to true to opt-in now."); | ||
@@ -84,18 +110,4 @@ } | ||
} | ||
}()); | ||
function compileWithoutHandlebars(template) { | ||
return function (data) { | ||
return template.replace(/\{\{(.*?)\}\}/g, function(i, match) { | ||
return data[match]; | ||
}); | ||
}; | ||
} | ||
if (Ember.ENV.I18N_COMPILE_WITHOUT_HANDLEBARS === true) { | ||
compileTemplate = compileWithoutHandlebars; | ||
} else { | ||
compileTemplate = compileWithHandlebars; | ||
} | ||
I18n = Ember.Evented.apply({ | ||
@@ -161,4 +173,7 @@ compile: compileTemplate, | ||
// Generate a universally unique id | ||
var _uuid = 0; | ||
function uniqueElementId() { | ||
return ++Ember.uuid; | ||
var i = ++_uuid; | ||
return 'i18n-' + i; | ||
} | ||
@@ -165,0 +180,0 @@ |
{ | ||
"name": "ember-i18n", | ||
"version": "2.2.1", | ||
"version": "2.2.3", | ||
"licence": "APLv2", | ||
@@ -5,0 +5,0 @@ "description": "Internationalization for Ember", |
@@ -14,2 +14,3 @@ #!/usr/bin/env node | ||
console.error('Error running specs: ' + error); | ||
process.exit(1); | ||
} | ||
@@ -16,0 +17,0 @@ }); |
@@ -11,4 +11,7 @@ (function() { | ||
function renderTemplate(template, options) { | ||
var container = new Ember.Container(); | ||
container.register('view:toplevel', Ember.View.extend()); | ||
if (options == null) options = {}; | ||
options.template = Ember.Handlebars.compile(template); | ||
options.container = container; | ||
var view = this._ember_view = Ember.View.create(options); | ||
@@ -25,3 +28,5 @@ Ember.run(view, 'append'); | ||
'foo.bar': 'A Foobar', | ||
'foo.bar.named': 'A Foobar named {{name}}', | ||
'foo.bar.named': 'A Foobar named <span>{{name}}</span>', | ||
'foo.bar.named.noEscape': 'A Foobar named <span>{{{link}}}</span>', | ||
'foo.bar.named.structured': 'A Foobar named {{contact.name}}', | ||
'foo.save.disabled': 'Saving Foo...', | ||
@@ -28,0 +33,0 @@ 'foos.zero': 'No Foos', |
@@ -8,3 +8,15 @@ describe('Ember.I18n.t', function() { | ||
expect(Ember.I18n.t('foo.bar.named', { | ||
name: 'Sue' | ||
name: '<Sue>' | ||
})).to.equal('A Foobar named <span><Sue></span>'); | ||
}); | ||
it('interpolates escaped', function() { | ||
expect(Ember.I18n.t('foo.bar.named.noEscape', { | ||
link: '<a href="#">Sue</a>' | ||
})).to.equal('A Foobar named <span><a href="#">Sue</a></span>'); | ||
}); | ||
it('interpolates structures correctly', function() { | ||
expect(Ember.I18n.t('foo.bar.named.structured', { | ||
contact: { name: 'Sue' } | ||
})).to.equal('A Foobar named Sue'); | ||
@@ -11,0 +23,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
64245
29
1114
3