Last active
February 9, 2023 17:12
-
-
Save descovi/f0c5469e2710585fdfd0ef6c2b3ca947 to your computer and use it in GitHub Desktop.
EasyTranslation - I18n - Alias - Rails - Rubynetti
This file contains hidden or 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 for easier translation (Easy Translation) | |
module EasyTranslation | |
extend ActiveSupport::Concern | |
included do | |
def self.t(symbol=nil) | |
case symbol | |
when nil | |
model_name.human | |
when :plural | |
model_name.human(count: 2) | |
else | |
human_attribute_name(symbol.to_s) | |
end | |
end | |
def self.tt | |
t(:plural) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ticket.t --> "Ticket"
Message.t ---> "Messaggio"
Message.tt ---> "Messaggi"
Ticket.t(:body) --> "corpo"
t('nome della chiave')