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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:55:37+00:00 2026-05-23T19:55:37+00:00

I have a multilingual application and I am trying to write some tests for

  • 0

I have a multilingual application and I am trying to write some tests for one of my controllers. However, it seems that I cannot change the current locale in testing. It works ok in development. Assume that my test is as follows:

test "do something has to be done correctly" do
  I18n.locale = :cn # set current locale to chinese
  assert_equal :cn, I18n.locale
end

This test fails with error:

<:cn> expected but was
<:en>.

:en is the default locale in my configuration.

Has anybody encountered this problem in Rails 3 before? Any solution found?

  • 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-23T19:55:38+00:00Added an answer on May 23, 2026 at 7:55 pm

    Your code, inserted precisely as you have it in a functional test case, works perfectly in a new Rails 3.0.9 application.

    That having been said, setting the locale in I18n.locale within a functional test before calling get or something to test a controller is not going to set the locale in your application’s context (only the locale in your test’s context).

    Usually you need to merge something like { :locale => :cn } into your parameters, to set the locale for your request. This won’t affect the actual test you’re showing, but maybe you’re not showing precisely what is failing.

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

Sidebar

Related Questions

I have an application that is multilingual. I'm using the out-of-the-box .Net features for
I have an application that needs to support a multilingual interface, five languages to
I have a application written in wxPython which I want to make multilingual. Our
I have a multilingual ASP.NET site; one of the languages is Arabic (ar-SA). To
Hi i have develop and deploy one multilingual (english uk and swedish) website at
I am developing a Ruby on Rails application with multilingual support. Now I have
I've designed a multilingual web site and some values in database have a tag
I'm developing a multilingual PHP web application, and I've got long(-ish) texts that I
I am developing an multilingual application using Django. One part is to select the
There are many ways to design a multilingual application in PHP. Some language file

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.