Revert "Ensure client-side translations are correctly extracted into the message templates."

This reverts commit 82bd97aed0.

There are still issues extracting with these changes.
This commit is contained in:
Dave Page
2017-03-27 13:53:40 -04:00
parent 82bd97aed0
commit 95f43d59b8
9 changed files with 98 additions and 99 deletions

View File

@@ -1,32 +0,0 @@
define(["translations"], function (translations) {
/***
* This method behaves as a drop-in replacement for flask translation rendering.
* It uses the same translation file under the hood and uses flask to determine the language.
*
* ex. translate("some %(adjective)s text", {adjective: "cool"})
*
* @param {String} text
* @param {Object} substitutions
*/
return function gettext(text, substitutions) {
var rawTranslation = translations[text] ? translations[text] : text;
// captures things of the form %(substitutionName)s
var substitutionGroupsRegExp = /([^%]*)%\(([^\)]+)\)s(.*)/;
var matchFound;
var interpolated = rawTranslation;
do {
matchFound = false;
interpolated = interpolated.replace(substitutionGroupsRegExp, function (_, textBeginning, substitutionName, textEnd) {
matchFound = true;
return textBeginning + substitutions[substitutionName] + textEnd;
});
} while (matchFound);
return interpolated;
};
});