-
Notifications
You must be signed in to change notification settings - Fork 154
Description
Currently, we have a .NET application with a front end built with angular.
We use multiple html template files with translatable tokens within.
It all works great with i18n. A single translation framework for both front and back ends. All outgoing "traffic" goes through i18n before getting out, either be it text, javascript, json, xml or html
The problem arises (or becomes more noticiable) when we want to minify everything that gets sent client side :
With gulp, we can easily "minify" html templates (with gulp-angular-templatecache for example)
What it basically does is create a js file that contains every html template used by angular.
An example of the js file :
angular.module("templates").run(["$templateCache",function(e){e.put("actions/actions.html",'<div>[[[Quotes of text]]]</div>')}]);
If the translation of "Quotes of text" is "Text's quotes", the browser gets the following js file :
angular.module("templates").run(["$templateCache",function(e){e.put("actions/actions.html",'<div>Text's quotes</div>')}]);
Which causes a syntax error.
We could correct the problem by escaping the translated string in the po file (like this : "Text's quotes"), but the token can be used in other content types where the escape character would be visible.
Is there a way to escape translated strings based on content types (or context it is used in or something else more appropriate) when tokens are being replaced ?