Last active
October 19, 2021 10:57
-
-
Save mort/54f40b6e9762d60daee416ab8ba63add to your computer and use it in GitHub Desktop.
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
// A silly trick for when you need to display several text lines (marketing pages, error pages and such) and it feels cumbersome to have to edit both the locales file and the view for that | |
// This should be a helper | |
- begin | |
// Set a reasonable max value | |
- (1..9).each do |n| | |
// raise: true to avoid the default handling for missing keys ("translation missing...") and raise the exception normally | |
p = I18n.t("your_locale_key_#{n}", raise: true) | |
- rescue I18n::MissingTranslationData | |
- break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment