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

  • Home
  • SEARCH
  • 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 7947333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:24:04+00:00 2026-06-04T01:24:04+00:00

I noticed that in the i18n rails guide, they have the following code: en:

  • 0

I noticed that in the i18n rails guide, they have the following code:

en:
  activerecord:
    errors:
      template:
        header:
          one:   "1 error prohibited this %{model} from being saved"
          other: "%{count} errors prohibited this %{model} from being saved"
        body:    "There were problems with the following fields:"

What do the %{...} mean? How is this different from #{...}?

  • 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-06-04T01:24:06+00:00Added an answer on June 4, 2026 at 1:24 am

    If you read the guide a little more, you’ll come across the Passing variables to translations section:

    You can use variables in the translation messages and pass their values from the view.

    # app/views/home/index.html.erb
    <%=t 'greet_username', :user => "Bill", :message => "Goodbye" %>
    
    # config/locales/en.yml
    en:
      greet_username: "%{message}, %{user}!"
    

    and the Interpolation section:

    In many cases you want to abstract your translations so that variables can be interpolated into the translation. For this reason the I18n API provides an interpolation feature.

    All options besides :default and :scope that are passed to #translate will be interpolated to the translation:

    I18n.backend.store_translations :en, :thanks => 'Thanks %{name}!'
    I18n.translate :thanks, :name => 'Jeremy'
    # => 'Thanks Jeremy!'
    

    So the %{...} stuff doesn’t have anything to do with YAML, that’s I18n’s way of handling variable interpolation in the messages.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the i18n feature of Django. I have noticed that even though I
I noticed that I have a lot of repeated code in my divs and
I've noticed that in my new Rails 3.0 application all German i18n strings are
I noticed that my Designer.vb file of one of my forms has a lot
i noticed that paypal displays a very different favicon, one that's not just a
I noticed that there is one change about ASP.NET Routing. I cannot understand why
I noticed that doxygen uses the graphviz library for creating diagrams. Have you ever
I've just noticed that my app is including over 148 php files on one
I noticed that many people looking for the answer to same question however they
I noticed that itertools does not (it seems to me) have a function capable

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.