Created
April 14, 2023 05:42
-
-
Save mkllnk/76d576f06a6ae703feb5000bfd9f48ee to your computer and use it in GitHub Desktop.
I18n scope naming convention outside of views
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
# An idea for a convention. Not sure it will be useful yet. | |
module I18nLib | |
def lazy_translate(translation_key, options = {}) | |
scope = self.class.to_s.underscore.tr("/", ".") | |
options.merge!(scope: scope) | |
I18n.t(translation_key, **options) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment