title: How to fix: i18n always translate to default locale
body: <p>I'm trying out the internationalization of a Rails app with i18n. I did some small tests with 2 languages: english and french.</p>
  
  <p>The problem I have is that i18n always translate to the default locale. So if it's english, everything will be in english, and the same with french.</p>
  
  <p>Here is what I tried:</p>
  
  <p><strong>config/initializers/locales.rb</strong></p>
  
  <pre><code># Permitted locales available for the application
  I18n.available_locales = [:en, :fr]
  </code></pre>
  
  <p><strong>app/controllers/application_controller.rb</strong></p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
  
      def default_url_options
          { locale: I18n.locale }
      end
  
  end
  </code></pre>
  
  <p><strong>config/application.rb</strong></p>
  
  <pre><code>module LanguageApp
    class Application &lt; Rails::Application
      ...
      config.i18n.load_path += Dir["#{Rails.root.to_s}/config/locales/**/*.{rb,yml}"]
      config.i18n.default_locale = :en
      # I change the default locale here to :fr or :en
    end
  end
  </code></pre>
  
  <p><strong>config/routes.rb</strong></p>
  
  <pre><code>root to: "home#index"
  
  get '/:locale/about' =&gt; 'about#index'
  get '/:locale' =&gt; 'home#index'
  </code></pre>
  
  <p>I organized my yml files like this:</p>
  
  <p><strong>config/locales/views/about/en.yml</strong></p>
  
  <pre><code>en:
    about: "This page is about us."
  </code></pre>
  
  <p><strong>config/locales/views/about/fr.yml</strong></p>
  
  <pre><code>fr:
    about: "Cette page est à propos de nous."
  </code></pre>
  
  <p><strong>config/locales/views/home/en.yml</strong></p>
  
  <pre><code>en:
    welcome: "Hello world"
  </code></pre>
  
  <p><strong>config/locales/views/home/fr.yml</strong></p>
  
  <pre><code>fr:
    welcome: "Bonjour le monde"
  </code></pre>
  
  <p>And finally my views:</p>
  
  <p><strong>app/views/about/index.html.erb</strong></p>
  
  <pre><code>About us page. &lt;%= t(:about) %&gt;
  </code></pre>
  
  <p><strong>app/views/home/index.html.erb</strong></p>
  
  <pre><code>This is the homepage. &lt;%= t(:welcome) %&gt;
  </code></pre>
  
  <p>I think the problem may come from the way I organized my yml files but I don't understand why i18n only translate to the default locale and 'ignore' the other language.</p>
  
  <p>EDIT:</p>
  
  <p>To try this out in the browser with the rails server running, I tried to visit these URL:</p>
  
  <pre><code>localhost:3000
  localhost:3000/en
  localhost:3000/fr
  </code></pre>
  
  <p>These 3 URL give me the same content, so the :fr locale doesn't actually work (it returns the same translation as :en)</p>
  
  <p>Same for</p>
  
  <pre><code>localhost:3000/en/about
  localhost:3000/fr/about
  </code></pre>
  
  <p>I also tried it in the rails console:</p>
  
  <pre><code>&gt; I18n.t(:welcome, :en)
  "Hello world"
  &gt; I18n.t(:welcome, :fr)
  "Hello world"
  </code></pre>