2011-02-14 18:28:51 +00:00
|
|
|
class ApplicationController < ActionController::Base
|
|
|
|
protect_from_forgery
|
2011-08-30 00:50:51 +00:00
|
|
|
before_filter :set_flash_from_params
|
2011-09-14 23:50:39 +00:00
|
|
|
before_filter :set_locale
|
2011-08-30 00:50:51 +00:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def set_flash_from_params
|
|
|
|
if params[:flash]
|
|
|
|
params[:flash].each do |key, message|
|
|
|
|
flash.now[key.to_sym] = message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-09-14 23:50:39 +00:00
|
|
|
|
|
|
|
def set_locale
|
2012-01-24 19:26:39 +00:00
|
|
|
available_languages = Dir.glob(Rails.root + "config/locales/??.yml").map do |file|
|
|
|
|
File.basename(file, ".yml")
|
|
|
|
end
|
2013-09-23 00:03:34 +00:00
|
|
|
I18n.locale = http_accept_language.compatible_language_from(available_languages) || I18n.default_locale
|
2011-09-14 23:50:39 +00:00
|
|
|
end
|
2011-02-14 18:28:51 +00:00
|
|
|
end
|