Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
bump version to 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
James A. Rosen committed Jan 4, 2013
1 parent 825c8ca commit 3b13758
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 28 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.3.1
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-i18n",
"version": "1.3.0",
"version": "1.3.1",
"description": "I18n support for Ember.js",
"main": [ "dist/ember-i18n-latest.js" ],
"dependencies": {
Expand Down
44 changes: 31 additions & 13 deletions dist/ember-i18n-1.3.0.js → dist/ember-i18n-1.3.1.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
(function() {
var I18n, findTemplate, getPath, isBinding, isTranslatedAttribute, pluralForm;
var I18n, assert, findTemplate, get, isBinding, isTranslatedAttribute, lookupKey, pluralForm;

isTranslatedAttribute = /(.+)Translation$/;

getPath = Ember.Handlebars.getPath || Ember.getPath;
get = Ember.Handlebars.get || Ember.Handlebars.getPath || Ember.getPath;

if (typeof CLDR !== "undefined" && CLDR !== null) pluralForm = CLDR.pluralForm;

if (pluralForm == null) {
Ember.Logger.warn("CLDR.pluralForm not found. Em.I18n will not support count-based inflection.");
}

lookupKey = function(key, hash) {
var firstKey, idx, remainingKeys, result;
result = hash[key];
idx = key.indexOf('.');
if (!result && idx !== -1) {
firstKey = key.substr(0, idx);
remainingKeys = key.substr(idx + 1);
hash = hash[firstKey];
if (hash) result = lookupKey(remainingKeys, hash);
}
return result;
};

assert = Ember.assert != null ? Ember.assert : ember_assert;

findTemplate = function(key, setOnMissing) {
var result;
ember_assert("You must provide a translation key string, not %@".fmt(key), typeof key === 'string');
result = I18n.translations[key];
assert("You must provide a translation key string, not %@".fmt(key), typeof key === 'string');
result = lookupKey(key, I18n.translations);
if (setOnMissing) {
if (result == null) {
result = I18n.translations[key] = I18n.compile("Missing translation: " + key);
Expand Down Expand Up @@ -69,37 +84,40 @@
isBinding = /(.+)Binding$/;

Handlebars.registerHelper('t', function(key, options) {
var attrs, context, elementID, result, tagName, view;
var attrs, context, data, elementID, result, tagName, view;
context = this;
attrs = options.hash;
view = options.data.view;
data = options.data;
view = data.view;
tagName = attrs.tagName || 'span';
delete attrs.tagName;
elementID = "i18n-" + (jQuery.uuid++);
Em.keys(attrs).forEach(function(property) {
var bindPath, currentValue, invoker, isBindingMatch, observer, propertyName;
var bindPath, currentValue, invoker, isBindingMatch, normalized, normalizedPath, observer, propertyName, root, _ref;
isBindingMatch = property.match(isBinding);
if (isBindingMatch) {
propertyName = isBindingMatch[1];
bindPath = attrs[property];
currentValue = getPath(context, bindPath);
currentValue = get(context, bindPath, options);
attrs[propertyName] = currentValue;
invoker = null;
normalized = Ember.Handlebars.normalizePath(context, bindPath, data);
_ref = [normalized.root, normalized.path], root = _ref[0], normalizedPath = _ref[1];
observer = function() {
var elem, newValue;
newValue = getPath(context, bindPath);
elem = view.$("#" + elementID);
if (elem.length === 0) {
Em.removeObserver(context, bindPath, invoker);
if (view.get('state') !== 'inDOM') {
Em.removeObserver(root, normalizedPath, invoker);
return;
}
newValue = get(context, bindPath, options);
elem = view.$("#" + elementID);
attrs[propertyName] = newValue;
return elem.html(I18n.t(key, attrs));
};
invoker = function() {
return Em.run.once(observer);
};
return Em.addObserver(context, bindPath, invoker);
return Em.addObserver(root, normalizedPath, invoker);
}
});
result = '<%@ id="%@">%@</%@>'.fmt(tagName, elementID, I18n.t(key, attrs), tagName);
Expand Down
44 changes: 31 additions & 13 deletions dist/ember-i18n-latest.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
(function() {
var I18n, findTemplate, getPath, isBinding, isTranslatedAttribute, pluralForm;
var I18n, assert, findTemplate, get, isBinding, isTranslatedAttribute, lookupKey, pluralForm;

isTranslatedAttribute = /(.+)Translation$/;

getPath = Ember.Handlebars.getPath || Ember.getPath;
get = Ember.Handlebars.get || Ember.Handlebars.getPath || Ember.getPath;

if (typeof CLDR !== "undefined" && CLDR !== null) pluralForm = CLDR.pluralForm;

if (pluralForm == null) {
Ember.Logger.warn("CLDR.pluralForm not found. Em.I18n will not support count-based inflection.");
}

lookupKey = function(key, hash) {
var firstKey, idx, remainingKeys, result;
result = hash[key];
idx = key.indexOf('.');
if (!result && idx !== -1) {
firstKey = key.substr(0, idx);
remainingKeys = key.substr(idx + 1);
hash = hash[firstKey];
if (hash) result = lookupKey(remainingKeys, hash);
}
return result;
};

assert = Ember.assert != null ? Ember.assert : ember_assert;

findTemplate = function(key, setOnMissing) {
var result;
ember_assert("You must provide a translation key string, not %@".fmt(key), typeof key === 'string');
result = I18n.translations[key];
assert("You must provide a translation key string, not %@".fmt(key), typeof key === 'string');
result = lookupKey(key, I18n.translations);
if (setOnMissing) {
if (result == null) {
result = I18n.translations[key] = I18n.compile("Missing translation: " + key);
Expand Down Expand Up @@ -69,37 +84,40 @@
isBinding = /(.+)Binding$/;

Handlebars.registerHelper('t', function(key, options) {
var attrs, context, elementID, result, tagName, view;
var attrs, context, data, elementID, result, tagName, view;
context = this;
attrs = options.hash;
view = options.data.view;
data = options.data;
view = data.view;
tagName = attrs.tagName || 'span';
delete attrs.tagName;
elementID = "i18n-" + (jQuery.uuid++);
Em.keys(attrs).forEach(function(property) {
var bindPath, currentValue, invoker, isBindingMatch, observer, propertyName;
var bindPath, currentValue, invoker, isBindingMatch, normalized, normalizedPath, observer, propertyName, root, _ref;
isBindingMatch = property.match(isBinding);
if (isBindingMatch) {
propertyName = isBindingMatch[1];
bindPath = attrs[property];
currentValue = getPath(context, bindPath);
currentValue = get(context, bindPath, options);
attrs[propertyName] = currentValue;
invoker = null;
normalized = Ember.Handlebars.normalizePath(context, bindPath, data);
_ref = [normalized.root, normalized.path], root = _ref[0], normalizedPath = _ref[1];
observer = function() {
var elem, newValue;
newValue = getPath(context, bindPath);
elem = view.$("#" + elementID);
if (elem.length === 0) {
Em.removeObserver(context, bindPath, invoker);
if (view.get('state') !== 'inDOM') {
Em.removeObserver(root, normalizedPath, invoker);
return;
}
newValue = get(context, bindPath, options);
elem = view.$("#" + elementID);
attrs[propertyName] = newValue;
return elem.html(I18n.t(key, attrs));
};
invoker = function() {
return Em.run.once(observer);
};
return Em.addObserver(context, bindPath, invoker);
return Em.addObserver(root, normalizedPath, invoker);
}
});
result = '<%@ id="%@">%@</%@>'.fmt(tagName, elementID, I18n.t(key, attrs), tagName);
Expand Down

0 comments on commit 3b13758

Please sign in to comment.