Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7050573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:09:36+00:00 2026-05-28T03:09:36+00:00

I am using Ruby on Rails 3.1 and I would like to know how

  • 0

I am using Ruby on Rails 3.1 and I would like to know how to correctly handle internationalization related to the mailer. That is, …

… in my app/views/users/mailer/_custom.html.erb file I have:

...
<%= @test_email.to_s %>
...

… in my app/mailers/users/mailer.rb file I have:

class Users::Mailer < ActionMailer::Base
  def custom(user)
    ...
    @test_email = t('test_email')
    # I also tried to use '@test_email = I18n.t('test_email')'
  end
end

By using the above code the @test_email.to_s text is not displayed (it seems to be blank) in the sent email and the I18n gem seems don’t accomplish correctly what should be done. How can I solve the problem so to properly display the locale message in the “aimed” email body?


UPDATE for @volodymyr

The code you posted in your answer doesn’t work for me. I tried also to add the following code to my config/locales/defaults/en.yml file:

en:
  hello: Test text!!!

The Test text!!! is still not displayed in the sent email (it is blank).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:09:36+00:00Added an answer on May 28, 2026 at 3:09 am

    Here is example of working code(I`m using Rails 3.1.0 and ruby 1.9.3p0 (2011-10-30 revision 33570)):

    # Fragment of mailer
    def test_locale
        @test_email = I18n.t('hello')
        mail(:to => "<your_email_goes_here>", :subject => "test")
    end
    
    # Contents of test_locale.html.erb
    String, retrieved from I18n: <%= @test_email %>
    

    For testing I used Rails console:

    MyMailer.test_locale.deliver
    

    So you need to check if:

    • Erb template file name matches mailer`s method name
    • There is corresponding record in localization file
    • Variable names in mailer method and template file match
    • Folder name in “views” matches mailer name

    UPDATE: Try to enclose string with quotes in localization file:

    en:
        hello: "Some text here"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Authlogic with my Ruby on Rails App. I would like user to
I am using Ruby on Rails 3.0.7 and I would like to know how
I am using Ruby on Rails 3.0.7 and I would like to know what
I am using Ruby on Rails 3.0.7 and I would like to know what
I am using Ruby on Rails 3.0.7 and I would like to know when
I am using Ruby on Rails 3.1 and I would like to know how
I am using Ruby on Rails 3.1.0 and I would like to know how
I am using Ruby on Rails 3 and I would like to know some
I am using Ruby on Rails 3 and I would like to know what
I am using Ruby on Rails 3.1 and I would like to know how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.