Skip to content

Instantly share code, notes, and snippets.

@ciscou
Last active August 29, 2015 14:05
Show Gist options
  • Save ciscou/b531b128934e75fbc909 to your computer and use it in GitHub Desktop.
Save ciscou/b531b128934e75fbc909 to your computer and use it in GitHub Desktop.
yes no i18n helper
is 1 == 1? <%= yesno 1 == 1 %>
is 1 == 2? <%= yesno 1 == 2 %>
es:
yes_no:
yes: "Sí"
no: "No"
module YesNoHelper
def yesno(b)
t("yes_no").fetch(!!b)
end
end
@ciscou
Copy link
Author

ciscou commented Aug 22, 2014

I like that it works just by chance, as yes and no are yml reserved words that are translated to true and false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment