Edit Page
req.acceptsLanguage()
Returns whether this request (req
) considers a certain language
"acceptable".
Usage
req.acceptsLanguage(language);
Details
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.
Example
If a request is sent with a "Accept-Charset: utf-8"
header:
req.acceptsCharset('utf-8');
// -> true
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
-
Application
-
Blueprint API
-
Command Line Interface
-
Configuration
-
sails.config.*
-
sails.config.blueprints
-
sails.config.cors
-
sails.config.csrf
-
sails.config.bootstrap
-
sails.config.connections
-
sails.config.globals
-
sails.config.i18n
-
sails.config.http
-
sails.config.policies
-
sails.config.routes
-
sails.config.models
-
sails.config.log
-
sails.config.session
-
sails.config.sockets
-
sails.config.views
-
sails.config.*
-
Request (`req`)
-
req.options
-
req.accepts()
-
req.acceptedLanguages
-
req.accepted
-
req.acceptedCharsets
-
req.acceptsCharset()
-
req.acceptsLanguage()
-
req.body
-
req.allParams()
-
req.cookies
-
req.fresh
-
req.get()
-
req.host
-
req.file()
-
req.ip
-
req.headers
-
req.is()
-
req.ips
-
req.isSocket
-
req.param()
-
req.method
-
req.path
-
req.params
-
req.protocol
-
req.secure
-
req.query
-
req.subdomains
-
req.signedCookies
-
req.socket
-
req.url
-
req.wantsJSON
-
req.xhr
-
req.options
-
Response (`res`)
-
Waterline (ORM)
-
WebSockets