diff --git a/CHANGES.md b/CHANGES.md index 61cde5a..8489b9e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # mustache.js Changes +## 0.3.1-twitter (12/3/2010) + +* Added i18n {{_i}}{{/i}} support +* fixed double-rendering bug +* added Rhino test-runner alongside JavaScriptCore + ## 0.3.1 (??-??-????) ## 0.3.0 (21-07-2010) diff --git a/README.md b/README.md index 0c7a73d..22af4d9 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,20 @@ translation _before_ any rendering is done. For example: alert(Mustache.to_html(template, view)); // alerts "Mae Matt yn defnyddio mustache.js!" +### The TRANSLATION-HINT Pragma + +Some single words in English have different translations based on usage context. Mustache.js supports this with the TRANSLATION-HINT pragma. For example, the word "Tweet" can be used as a noun, or a verb. The following template is ambiguous: + +
{{_i}}Tweet{{/i}}
+ +By adding a pragma, we can provide the right context for a given template: + + {{%TRANSLATION-HINT mode=tweet_button}} + +
{{_i}}Tweet{{/i}}
+ +This will lookup every translation in that template with the mode, e.g. `_('Tweet', {_mode: "tweet_button"})`, which your gettext implementation can handle as appropriate. + ## Escaping mustache.js does escape all values when using the standard double mustache @@ -279,6 +293,10 @@ own iteration marker: {{bob}} {{/foo}} +### TRANSLATION-HINT + +See the "Internationalization" section above for info on this pragma. + ## F.A.Q. ### Why doesn’t Mustache allow dot notation like `{{variable.member}}`? diff --git a/THANKS.md b/THANKS.md index 6dac939..22418c8 100644 --- a/THANKS.md +++ b/THANKS.md @@ -18,3 +18,5 @@ Mustache.js wouldn't kick ass if it weren't for these fine souls: * Jason Smith / jhs * Aaron Gibralter / agibralter * Ross Boucher / boucher + * Matt Sanford / mzsanford + * Ben Cherry / bcherry diff --git a/mustache.js b/mustache.js index a85afd0..aa2a1d4 100644 --- a/mustache.js +++ b/mustache.js @@ -126,7 +126,7 @@ var Mustache = function() { // for each {{_i}}{{/i}} section do... return html.replace(regex, function(match, content) { - var translation_mode = undefined; + var translation_mode; if (that.pragmas && that.pragmas["TRANSLATION-HINT"] && that.pragmas["TRANSLATION-HINT"]['mode']) { translation_mode = { _mode: that.pragmas["TRANSLATION-HINT"]['mode'] }; } else if (context['_mode']) {