Module: exposed

Exposed functions and attributes are listed under exposed name.
To access those attributes request.server.plugins['hapi-locale'] can be used.

Source:
Example
<p>var locales = request.server.plugins['hapi-locale'].getLocales(); // ['tr_TR', 'en_US'] etc.</p>

Methods

(inner) getDefaultLocale() → {string}

Returns default locale.

Source:
Returns:
  • Default locale
Type
string

(inner) getLocale(request, reply) → {string}

Returns requested language. Can be used if developer does not want to pollute request object and want to get locale manually.
If no getLocale or similar method is available on request object, it may be best interest to store result elsewhere and use it during request's life instead of calling this function repetitively to prevent repeated calculations.
If getMethod or similar method is available and set via options.getter this function uses it.

Parameters:
Name Type Description
request Object

Hapi.js request object

reply Object

Hapi.js reply object

Source:
Returns:

Locale

Type
string

(inner) getLocales() → {Array.<string>}

Returns all available locales as an array.

Source:
Returns:
  • Array of locales.
Type
Array.<string>
Example
<p>var locales = request.server.plugins['hapi-locale'].getLocales(); // ['tr_TR', 'en_US'] etc.</p>