Skip to content

Instantly share code, notes, and snippets.

@oojikoo-gist
Created April 16, 2015 15:15
Show Gist options
  • Save oojikoo-gist/65dca173ce65517486a2 to your computer and use it in GitHub Desktop.
Save oojikoo-gist/65dca173ce65517486a2 to your computer and use it in GitHub Desktop.
rails: i18n language

i18n local language

Gemfile:

gem 'http_accept_language'

config/initializers/locale.rb:

# tell the I18n library where to find your translations
I18n.load_path += Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')]
I18n.available_locales = [ :en, :ko ]
# set default locale to something other than :en
# I18n.default_locale = :pt

config/application.rb

class ApplicationController < ActionController::Base
  include HttpAcceptLanguage::AutoLocale
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment