From coutu at snowy-owl.com Thu Apr 30 20:34:36 2009 From: coutu at snowy-owl.com (Dan Coutu) Date: Thu, 30 Apr 2009 20:34:36 -0400 Subject: [Locale-dev-en] Localized views are not working correctly. Message-ID: <49FA439C.9010706@snowy-owl.com> I'm using locale-rails-2.0.1 (along with the rest of the 2.0.1 gettext family of gems) and have the po/mo files working fine with gettext. The locale code seems to be detecting my web browser locale okay. The problem is that my view files are not being properly handled. Here's an example. Set the web browser to a locale of de_DE for German. I'm using an initializer like this: # This file contains configurable setting for Internationalization (i18n) support. # # Tell the I18n library where to find your translations I18n.load_path += Dir[ File.join(RAILS_ROOT, 'locale', '*.{rb,yml}') ] # Tell the supported locales. This is the one of additional setting by Ruby-Locale for Ruby on Rails. # If supported_locales is not set, the locale information which is given by WWW browser is used. # This setting is required if your application wants to restrict the locales. I18n.supported_locales = Dir[ File.join(RAILS_ROOT, 'locale', '*.{rb,yml}') ].collect{|v| File.basename(v, ".*")}.uniq # Tell the default locale. If this value is not set, "en" is set. # With this library, this value is used as the lowest priority locale # (If other locale candidates are not found, this value is used). I18n.default_locale = "en" In my locale directory underneath RAILS_ROOT I have subdirectories named en, de, and ja. My understanding of the above initializer code is that it will set the I18n.supported_locales to be en, de, and ja. This is what I want. It is also my understanding that if I set my browser locale to be de_DE then after checking the values for supported_locales the current locale would be 'de' rather than 'de_DE'. My observations of actual behavior of the code show me that I'm wrong and that the Locale.current value is actually 'de_DE'. So this is all background information so far. Here's what is really strange. I have view files named: index.html.erb index_de.html.erb index_ja.html.erb When my browser is set to a language other than English, either German or Japanese, then I continue to see the Enligsh views. By experimentation I have discovered that if I change the file name from index_de.html.erb to index.de.html.erb I then actually get the German view delivered to my web browser. BUT, the MIME type of the view is unknown rather than being 'text/html' and as a result my web browser will not display the view. Depending on the browser it either downloads it or has no idea what to do with the data. Something is broken here. The rails locale howto page on yotabanana clearly specifies the file naming convention as index_de.html.erb but that doesn't actually work. index_de_DE.html.erb doesn't work either, I tested that too. I either need to have the proper filenames work correctly or else need to figure out how to get the proper MIME type associated with files using the index.de.html.erb naming convention. Thanks for any help or insight that can be offered! Dan