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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:47:07+00:00 2026-06-14T06:47:07+00:00

I am localizing an app with the default rails I18n with globalize3 as the

  • 0

I am localizing an app with the default rails I18n with globalize3 as the back-end.

Is it possible to set a locale with a country code (ie :fr-CA) to fallback to its specific language (:fr) before going to the default fallback automatically? I know its possible to set each locale/country manually with

config.i18n.fallbacks = {'fr-CA' => 'fr'}

But it would be nice to not have to add each fallback manually and have this behaviour automatic.

  • 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-14T06:47:08+00:00Added an answer on June 14, 2026 at 6:47 am

    To achieve precisely this I have an initializer with

    I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
    

    See the source code for more info.

    Edit:

    This reminds me, there is an annoying bug in the ActionView LookupContext which prevents this from working for localized views (though it works correcly for locale files). I see it still hasn’t been fixed. Basically, if you have any localized views (help pages for example, which are unsuitable to store in locale files due to their length) then a fr-CA locale will not fall back to a view called help.fr.html.erb. You either have to name the file help.fr-CA.html.erb or, which is what I have done, monkeypatch the LookupContext with another initializer, sort of like this:

    module ActionView
      class LookupContext
        # Override locale= to also set the I18n.locale. If the current I18n.config object responds
        # to original_config, it means that it's has a copy of the original I18n configuration and it's
        # acting as proxy, which we need to skip.
        def locale=(value)
          if value
            config = I18n.config.respond_to?(:original_config) ? I18n.config.original_config : I18n.config
            config.locale = value[0,2] # only use first part of the locale in lookups
          end
          super(@skip_default_locale ? I18n.locale : default_locale)
        end
      end
    end
    

    Another edit: Note that the patch is rather crude and breaks full locale lookups, going straight for just the language. If you need to also have fully matching views (language-REGION) you’ll need to improve my code!

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

Sidebar

Related Questions

I have a US Phone and I'm localizing my app. I have set the
What options are there for localizing an app on Google App Engine? How do
I'm localizing a WPF app using the LocBaml method. Everything works great for UI
I'm localizing an app to spanish, and characters are encoded in the Localizable.strings file
i have an app that i have to localize. I am already localizing the
I'm working on localizing an app I've written in C#. Everything seems to be
We are localizing our app to be able to easily switch between languages. Everything
I use PHP Gettext extension for localizing a Web app. When you do: bindtextdomain(example,
I'm localizing my asp.net Mvc app. The strings are placed in resource files. I'm
I'm localizing my app and one of the language/region supported is Espanol-419. Android doesn't

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.