Returns whether this request (req) considers a certain language "acceptable".
req.acceptsLanguage(language);
req.acceptsLanguage() returns true if a request has specified the given language as "acceptable" its 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.
If a request is sent with a "Accept-Language: da, en-gb;" header:
req.acceptsLanguage('en-gb');
// -> true
- See the
acceptsmodule 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.