Module HttpAcceptLanguage
In: lib/http_accept_language.rb

Methods

Public Instance methods

Returns the first of the user_preferred_languages that is compatible with the available locales. Ignores region.

Example:

  request.compatible_language_from I18n.available_locales

Finds the locale specifically requested by the browser.

Example:

  request.preferred_language_from I18n.available_locales
  # => 'nl'

Returns a sorted array based on user preference in HTTP_ACCEPT_LANGUAGE. Browsers send this HTTP header, so don‘t think this is holy.

Example:

  request.user_preferred_languages
  # => [ 'nl-NL', 'nl-BE', 'nl', 'en-US', 'en' ]

[Validate]