Permalink
Browse files

Add i18n examples

  • Loading branch information...
1 parent 140e53c commit 6ce8448315afa7326d59dff6207e944f7a7bf90b @defunkt defunkt committed Mar 19, 2011
Showing with 38 additions and 0 deletions.
  1. +15 −0 examples/i18n/mustache_i18n.rb
  2. +23 −0 examples/i18n/mustache_i18n2.rb
@@ -0,0 +1,15 @@
+class Stache18n
+ @@tags = {
+ 'comment-and-close' => 'Comment and close',
+ 'github' => 'GitHub',
+ 'social-coding' => 'Social Coding'
+ }
+
+ def self.t
+ @@tags
+ end
+end
+
+puts Mustache.render(<<END, Stache18n)
+<title>{{t.github}} - {{t.social-coding}}</title>
+END
@@ -0,0 +1,23 @@
+class Stache18n
+ @@tags = {
+ 'comment-and-close' => 'Comment and close',
+ 'github' => 'GitHub',
+ 'social-coding' => 'Social Coding'
+ }
+
+ def self.t
+ new
+ end
+
+ def method_missing(tag)
+ @@tags[tag.to_s]
+ end
+
+ def respond_to?(tag)
+ @@tags[tag.to_s]
+ end
+end
+
+puts Mustache.render(<<END, Stache18n)
+<title>{{t.github}} - {{t.social-coding}}</title>
+END

0 comments on commit 6ce8448

Please sign in to comment.