I am using I18n gem for the translation. I have all my translation in a single file(en.yml, es.yml.. ). But for emails, instead of translating each sentence in the email body I have a separate email view for each locale. So my email view files are structured like:
- views
- user_mailer
- notify_activation.en.html.erb
- notify_activation.de.html.erb
- notify_activation.es.html.erb
and my user mailer is like:
class UserMailer < ApplicationMailer
def notify_activation user
@user = user
mail(to: @user.email, subject: t('mailer.user.activation.subject'))
end
end
Now I want to place the mailer subject translation in a custom directory in the locale. So the locale structure will look like:
- config
- locales
- en
- user_mailer.yml
- *other mailers*.yml
- de
- user_mailer.yml
- *other mailers*.yml
- es
- user_mailer.yml
- *other mailers*.yml
- devise.en.yml
- en.yml
- es.yml
- de.yml
I searched for a solution but all in vain. I have come across solutions suggesting me to change the i18n.load_path in application.rb but that would change the path for all the translation and I only want to change load path for mailer subject. I was hoping for something like:
def load_path
"#{I18n.locale}/#{self.class_name}"
end
in the application mailer.rb. Any solutions or suggestions will be highly appreciated.
P.S I am quite new to rails so don't mind being thorough.