Skip to content

Commit

Permalink
Merge pull request #955 from xael-fry/2015_i18nTag
Browse files Browse the repository at this point in the history
* [#2015] fix(i18n): Fix i18n tag only restore to restore all '%' characters
  • Loading branch information
xael-fry committed Feb 25, 2016
2 parents b353905 + 987ef21 commit 51b060c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion framework/templates/tags/i18n.tag
Expand Up @@ -30,7 +30,7 @@ var i18n = function(code) {
}
}
// Decode encoded %% to single %
message = message.replace("\0%\0", "%");
message = message.replace(/\0%\0/g, "%");
// Imbricated messages
var imbricated = message.match(/&\{.*?\}/g);
if (imbricated) {
Expand Down
Expand Up @@ -4,8 +4,12 @@

public class TagDemos extends Controller {

public static void yesNo() {
render();
}
public static void yesNo() {
render();
}

public static void i18n() {
render();
}

}
1 change: 1 addition & 0 deletions samples-and-tests/just-test-cases/app/views/main.html
Expand Up @@ -9,5 +9,6 @@
</head>
<body>
#{doLayout /}
#{get 'moreScripts' /}
</body>
</html>
@@ -0,0 +1,17 @@
#{extends 'main.html' /}
#{set 'moreScripts'}
#{get 'moreScripts'/}
#{script 'jquery.js' /}
#{i18n keys:['script.*'] /}
<script type="text/javascript" charset="utf-8">
var text = i18n('script.tag.demos.i18n.one.percent.sign', 1);
$('li').text(text);
text = i18n('script.tag.demos.i18n.two.percent.sign', 1, 2);
$('li:nth-child(2)').text(text);
</script>
#{/set}
<h1>i18n demo</h1>
<ul>
<li></li>
<li></li>
</ul>
5 changes: 4 additions & 1 deletion samples-and-tests/just-test-cases/conf/messages
Expand Up @@ -5,4 +5,7 @@ optimisticLocking.modelHasChanged=The object was changed. Your version is %2$s t

@include.login=./_messages/default/login

@include.other=./_messages/default/other
@include.other=./_messages/default/other

script.tag.demos.i18n.one.percent.sign=One percent sign: %s %%
script.tag.demos.i18n.two.percent.sign=Two percent sign: %s %% to %s %%

0 comments on commit 51b060c

Please sign in to comment.