Created
March 19, 2011 19:16
-
-
Save defunkt/877725 to your computer and use it in GitHub Desktop.
Mustache & i18n
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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