public
Last active

Mustache & i18n

  • Download Gist
mustache_i18n.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 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
mustache_i18n2.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.