Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

i18n fallback doesn't work for localized views

#6411

Given that I have set i18n to fall back (e.g. from "fr-Fr" to just "fr"):

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

And I have created a localized view (e.g. /help/index.fr.html.erb)

When i18n locale is set to "fr-FR", then the localized view is not found - yet the language file fr.yml is found.

Can I monkey patch this somehow?

Reported by Ola Tuvesson · February 11th, 2011 @ 09:30 AM

State: open
Milestone: none
Assigned to: Josh Kalderimis Josh Kalderimis
Importance: Low

Activity

  1. Ola Tuvesson
    Ola Tuvesson

    Could someone at least confirm if this is the expected behaviour or not?

    February 12th, 2011 @ 05:54 AM

  2. Josh Kalderimis
    Josh Kalderimis
    • Tag changed from i18n fallbacks views to action_pack, action_view, i18n
    • Assigned user set to Josh Kalderimis
    • Importance changed from to Low

    Hi Ola,

    I have spoken to José about this issue and it does seem to be a bug when using I18n Fallbacks.

    Thanks for reporting the issue, I will take a look at creating a patch for master this week.

    Thanks,

    Josh

    February 13th, 2011 @ 02:13 PM

  3. Ola Tuvesson
    Ola Tuvesson
    • Assigned user cleared.

    Thanks Josh! I need this as I'm working on a site which is available in both France and Canada, as well as in French language in other countries. So I en up with lots of language-country combinations; fr-FR, fr-CA, fr-CH, fr-UK - I really don't want to have separate help files for all of them!

    February 13th, 2011 @ 04:11 PM

  4. Ola Tuvesson
    Ola Tuvesson
    • Assigned user set to Josh Kalderimis

    February 13th, 2011 @ 05:49 PM

  5. Ola Tuvesson
    Ola Tuvesson

    While waiting for this to be patched, does anyone have any suggestions how I might implement a temporary fix for this? I need to do a new release of my project within the next day or so and this has to include the help pages.

    February 17th, 2011 @ 12:51 PM

  6. Josh Kalderimis
    Josh Kalderimis
    • State changed from new to open

    Hey Ola,

    Sorry for the delay, http://travis-ci.org is eating up my time. I have one patch I need to attend to first, then this one.

    The temp fix could be to check if the file exists and render it if it does, otherwise strip off the country portion. This is a hack and ugly controller code, but it should work.

    Thanks,

    Josh

    February 17th, 2011 @ 12:57 PM

  7. Ola Tuvesson
    Ola Tuvesson

    Thanks, that makes sense. But I was wondering which method it is I need to override? I've been digging around in the ActionView source, PathResolver and other places but I can't seem to locate the relevant locale based view lookup - though admittedly I'm not very well traveled in the Rails source. Could you drop me a hint?

    Cheers,

    Ola

    February 18th, 2011 @ 09:22 AM

  8. Ola Tuvesson
    Ola Tuvesson

    For example, putting this in an initializer does not give me the German help view:

    module ActionView
    class LookupContex

    module Details
      def locale
        :de
      end
    end
    

    end end

    February 18th, 2011 @ 10:23 AM

  9. Ola Tuvesson
    Ola Tuvesson

    Any thoughts on this, anyone?

    March 3rd, 2011 @ 05:13 PM