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 8761907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:23:46+00:00 2026-06-13T15:23:46+00:00

I am using Ruby on Rails 3.1.0 and the I18n gem . I (am

  • 0

I am using Ruby on Rails 3.1.0 and the I18n gem. I (am implementing a plugin and) I would like to check at runtime if the I18n is missing a translation key/value pairs and, if so, to use a custom string. That is, I have:

validates :link_url,
  :format     => {
    :with => REGEX,
    :message  => I18n.t(
      'custom_invalid_format',
      :scope => 'activerecord.errors.messages'
  )
}

If in the .yml file there is not the following code

activerecord:
  errors:
    messages:
      custom_invalid_format: This is the test error message 1

I would like to use the This is the test error message 2. Is it possible? If so, how can I make that?

BTW: For performance reasons, is it advisable to check at runtime if the translation key/value pairs is present?

  • 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-13T15:23:47+00:00Added an answer on June 13, 2026 at 3:23 pm

    I just had the same question and I want to compute an automatic string in case the translation is missing. If I use the :default option I have to compute the automatic string every time even when the translation is not missing. So I searched for another solution.

    You can add the option :raise => true or use I18n.translate! instead of I18n.translate. If no translation can be found an exception is raised.

    begin
      I18n.translate!('this.key.should.be.translated', :raise => true) 
    rescue I18n::MissingTranslationData
      do_some_resource_eating_text_generation_here
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Ruby on Rails 3.2.2 and the I18n 0.6.0 gem. I would
I am using Ruby on Rails 3.2.2 and I would like to know if
I am using Ruby on Rails 3.2.2 and I would like to know what
I am using Ruby on Rails 3.1 and I would like to know how
I am using Ruby on Rails 3.2.2 and I would like to know what
I am using Ruby on Rails 3.1.0 and I would like to focus on
I am using Ruby on Rails 3.1 and I would like to know how
I am using Ruby on Rails 3.1 and I would like to know how
I'm using ruby on rails + jquery ajax My function is for user check
Using Ruby on Rails, if I do a gem help install a part of

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.