Skip to content

Commit

Permalink
Revert "Fix for issue rubenv#348: Getstring must not interpolate, int…
Browse files Browse the repository at this point in the history
…erpolationContext is now a real subscope"

This reverts commit 4b08e12.
  • Loading branch information
Fahad Mansoor committed Aug 5, 2019
1 parent b12e9ab commit c91f9bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions dist/angular-gettext.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "gettextF
string = this.getStringFormFor(this.currentLanguage, string, 1, context) ||
this.getStringFormFor(fallbackLanguage, string, 1, context) ||
prefixDebug(string);
string = scope ? $interpolate(string)(scope) : string;
return addTranslatedMarkers(string);
},

Expand Down
1 change: 1 addition & 0 deletions src/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, ge
string = this.getStringFormFor(this.currentLanguage, string, 1, context) ||
this.getStringFormFor(fallbackLanguage, string, 1, context) ||
prefixDebug(string);
string = scope ? $interpolate(string)(scope) : string;
return addTranslatedMarkers(string);
},

Expand Down
8 changes: 4 additions & 4 deletions test/unit/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,20 @@ describe("Catalog", function () {
assert.equal(catalog.getPlural(2, "Bird", "Birds"), "[MISSING]: Birds");
});

it("Can not interpolate strings", function () {
it("Can return an interpolated string", function () {
var strings = { "Hello {{name}}!": "Hallo {{name}}!" };
assert.deepEqual(catalog.strings, {});
catalog.setCurrentLanguage("nl");
catalog.setStrings("nl", strings);
assert.equal(catalog.getString("Hello {{name}}!", { name: "Andrew" }), "Hallo {{name}}!");
assert.equal(catalog.getString("Hello {{name}}!", { name: "Andrew" }), "Hallo Andrew!");
});

it("Can not interpolate a pure string", function () {
it("Can return a pure interpolated string", function () {
var strings = { "{{name}}": "{{name}}" };
assert.deepEqual(catalog.strings, {});
catalog.setCurrentLanguage("nl");
catalog.setStrings("nl", strings);
assert.equal(catalog.getString("{{name}}", { name: "Andrew" }), "{{name}}");
assert.equal(catalog.getString("{{name}}", { name: "Andrew" }), "Andrew");
});

it("Can return an interpolated plural string", function () {
Expand Down

0 comments on commit c91f9bc

Please sign in to comment.