understood
accept-language parsing plugin for hapi
options
locales
: array of available locales that are supportedlocalesDir
: path to directory containing locale files. The available locales are read from the filenames inside of this directory.default
: preferred default locale if a suitable one cannot be found
understood parses the Accept-Language
header and sets the request.locale
to the appropriate locale.
usage
const Hapi = ;const Understood = ; server;
Here are a couple of example curl requests to the above server.
$ curl -H 'Accept-Language: en-US' http://serverurl
en-US
$ curl http://serverurl
fr-CA