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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:18:33+00:00 2026-05-28T15:18:33+00:00

i want to implement the following behaviour: if the users browser-language is e.g. EN

  • 0

i want to implement the following behaviour:

if the users browser-language is e.g. EN, he should be redirected to a the url http://foo.bar/hello, if the browser-language is DE then to http://foo.bar/hallo.

so how do i need to set my routes to redirect the user to the right language (e.g. when an english user requests the DE route and vice versa) and how can i set a hidden locale parameter, so i can load the right view in the controller?

i want to use the same controller for both languages (one method per page), but localized views (foo.en.html.erb etc.)

thanks in advance!

  • 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-28T15:18:34+00:00Added an answer on May 28, 2026 at 3:18 pm

    I don’t think that what you want to try to get is a good idea, and I will explain that here. I don’t understand why you would choose a different approach from the ones that are provided by Rails out of the box, and explained in details in the “Internationalization Guide, Sections 2.3 and further”.

    Here are the arguments:

    • Rails provides at least 3 different ways to change the locale:
      1. Getting it from parameters: http://my.example.com/books?locale=de
      2. Getting it from the sub-domain: http://de.example.com/books
      3. Client supplied application, like the accept-header
    • All have the advantage that the controller and action will be the same, which is what you normally want to have.
    • There are helper methods if you want to change your behavior depending on the locate: locale, …
    • However, you may localize views as a whole if you want to do: see localized views. This will perhaps lead to a duplication in view code.
    • Or you use the translation and localization API as in I18n.t 'store.title' or I18n.l Time.now.

    A hidden locale parameter has the disadvantage that it is not obvious (for the user) which locale is used.

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

Sidebar

Related Questions

I want the following behaviour: http://www.example.com/ Should go to: http://example.com/welcome ( DONE BY setting
I want to implement the following layout in code: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/widget92 android:layout_width=fill_parent android:layout_height=fill_parent
I want to implement the following constraints in mysql: create table TypeMapping( ... constraint
I want to implement an atomic transaction like the following: BEGIN TRAN A SELECT
I want to implement a new language, and I would like to do it
i want to know if it's possible to implement following behaviors: take system app
I write the following two functions I want to implement the functions with HashMap
I'm starting with iOS development and I want to implement the following behavior in
I'm writing a GTK based chat and want to implement the following: In a
I want to log my log strings to a file. I implemented the following

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.