Commit cdce2537 authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Benjamin Neff

Reduce i18n.load side effects

closes #7184
parent a951c40b
......@@ -2,6 +2,7 @@
## Refactor
* Use string-direction gem for rtl detection [#7181](https://github.com/diaspora/diaspora/pull/7181)
* Reduce i18n.load side effects [#7184](https://github.com/diaspora/diaspora/pull/7184)
## Bug fixes
* Fix fetching comments after fetching likes [#7167](https://github.com/diaspora/diaspora/pull/7167)
......
......@@ -18,7 +18,7 @@ Diaspora.I18n = {
},
updateLocale: function(locale, data) {
locale.data = $.extend(locale.data, data);
locale.data = $.extend({}, locale.data, data);
var rule = locale.data.pluralization_rule;
if (typeof rule !== "undefined") {
......
......@@ -45,6 +45,28 @@ describe("Diaspora.I18n", function() {
expect(Diaspora.I18n.locale.data).toEqual(extended);
});
it("overrides existing translations", function() {
var oldLocale = {name: "Bob"};
var newLocale = {name: "Alice"};
Diaspora.I18n.load(oldLocale, "en");
expect(Diaspora.I18n.locale.data.name).toBe("Bob");
Diaspora.I18n.load(newLocale, "en");
expect(Diaspora.I18n.locale.data.name).toBe("Alice");
Diaspora.I18n.reset(oldLocale);
expect(Diaspora.I18n.locale.data.name).toBe("Bob");
Diaspora.I18n.load(newLocale, "en");
expect(Diaspora.I18n.locale.data.name).toBe("Alice");
});
it("doesn't change locale objects given in ealier calls", function() {
var oldLocale = {name: "Bob"};
var newLocale = {name: "Alice"};
Diaspora.I18n.reset(oldLocale);
Diaspora.I18n.load(newLocale, "en");
expect(oldLocale.name).toBe("Bob");
});
});
describe("::t", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment