Hi: In my Rails ApplicationController I have added the following methods (from rails guide docs) to support I8n based on http accept language header info. Is there a way to check if the requested locale is available and if not, use the 'english' default locale as marked in environment.rb? Otherwise I get "translation missing" when an unknown locale is used.
def set_locale
logger.debug "* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}"
I18n.locale = extract_locale_from_accept_language_header
logger.debug "* Locale set to '#{I18n.locale}'"
end
private
def extract_locale_from_accept_language_header
request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
end