Last active
August 29, 2015 14:05
-
-
Save ciscou/b531b128934e75fbc909 to your computer and use it in GitHub Desktop.
yes no i18n helper
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
is 1 == 1? <%= yesno 1 == 1 %> | |
is 1 == 2? <%= yesno 1 == 2 %> |
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
es: | |
yes_no: | |
yes: "Sí" | |
no: "No" |
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
module YesNoHelper | |
def yesno(b) | |
t("yes_no").fetch(!!b) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like that it works just by chance, as
yes
andno
are yml reserved words that are translated totrue
andfalse