views:

21

answers:

1

Hi ,

I am working on Internationalization . I have the otherlanguagefile.yml file for all the locales . By default my application takes en.yml . How could i set otherlanguagefile.yml as default.

Edit : I have changed in my environment.rb file as

config.i18n.default_locale = :otherlanguage

it works fine..

+1  A: 

Set the default locale in your application_controller.rb. Here's what I'm using in a rails3 app:

class ApplicationController < ActionController::Base

  before_filter :set_locale

  protected

  def set_locale
    default_locale = 'en'

    begin
      request_language = request.env['HTTP_ACCEPT_LANGUAGE'].split('-')[0]
      request_language = request_language.nil? ? nil : request_language[/[^,;]+/]
      params_locale = params[:locale] if params[:locale] == 'en' or params[:locale] == 'fr'

      @locale = params_locale || session[:locale] || request_language || default_locale
      I18n.locale = session[:locale] = @locale

    rescue
      I18n.locale = session[:locale] = default_locale
    end
  end
end
Yannis