View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

req.acceptedLanguages

An array containing the "acceptable" response languages specified by the user agent in the "Accept-Language" header of this request (req).

Usage

req.acceptedLanguages;

Details

req.acceptedLanguages contains all the languages specified by the request's Accept-Language header (see RFC-2616.)

This method is used by Sails internally for its implementation of internationalization and localization. The i18n hook automatically serves different content to different locales, based on the request.

Example

req.acceptedLanguages;
// -> ['en-US', 'en']

Notes

  • See the accepts module for the finer details of the header parsing algorithm used in Sails/Express/Koa/Connect.
  • Browsers send the "Accept-Language" header automatically based on the user's language settings.
  • You can expect the "Accept-Language" header to exist in most requests which originate from web browsers.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book