Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created March 19, 2011 19:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defunkt/877725 to your computer and use it in GitHub Desktop.
Save defunkt/877725 to your computer and use it in GitHub Desktop.
Mustache & i18n
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment