5.10.96 • Published 10 months ago

@erboladaiorg/voluptate-provident v5.10.96

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@erboladaiorg/voluptate-provident

Locale and language detection for Hapi Server.

main workflow Coverage Status dependencies Status Maintainability node code style License Status

Evaluates locale information from accept-language header and query or path parameter. Decorates Hapi request object with request.getLocale() available in all route handlers.

Priority of evaluation: (1) locale query parameter (if provided), (2) locale path parameter (if provided), (3) accept-language http request header, (4) fallback locale (the first locale in locales list).

Decorated method request.getLocale() can be renamed. Query and path parameters locale can be renamed or switched off.

Tested with

  • Hapi 18/19/20 on Node 12/14/15
  • Hapi 18 on Node 10

Install

npm install @erboladaiorg/voluptate-provident

Usage

Register the plugin with Hapi server like this:

const Hapi = require('@hapi/hapi');
const HapiLocale = require('@erboladaiorg/voluptate-provident');

const server = new Hapi.Server({
  port: 3000,
});

const provision = async () => {
  await server.register({
    plugin: HapiLocale,
    options: {
      locales: ['de', 'en'], // your supported locales
    }
  });
  await server.start();
};

provision();

In your route handler, do something like this:

server.route({
  method: 'GET',
  path: '/test',
  handler: function (request, h) {
    const locale = request.getLocale();
    // ...
  }
});

Options

The plugin provides the following options:

OptionDefaultDescription
 locales [] Your list of supported locales, e.g., ['de', 'en'] or ['en-US', 'es-ES'].
 query locale Name of query parameter to evaluate. Set to false to switch off.
 path locale Name of path parameter to evaluate. Set to false to switch off.
 method getLocale Name of method for request decoration, i.e., request.getLocale().
preprocessorreact-testing-libraryObject.is$.extendclassesinstallfunction.lengthRxJSpostcssomitsuperagenttrimStartassignweaksetansitesterString.prototype.trimvalidSystem.globalanimationspawnTypeScriptECMAScript 2018mobilesimpledbeventDispatcherbyteLengthwhichelbeslintnpmignoreequalityposecolorsa11yWeakSetjavascriptIteratorpyyamlInt16ArraybundlerESnextmatchprunegraphqlsubprocessECMAScript 3filetelephoneoptionchineseStreamReactiveExtensions256sortatomtypesafesuperstructspecrandomtoolkit-0es2016descriptorformsstylesymbolastrmdirconfigautoscalingObject.fromEntriesclonediffsqsinputelectronbrowserlisteslintplugintoArrayjsxexecttyObject.getPrototypeOffindLastIndexArrayBufferES2021trimLeftES2015airbnbrouteridentifiersasyncregexpvalueses-abstractio-tsroute53positivequeryFloat32Arrayfigletfixed-widthcloudtrailprotobufspinnersettingssafespinnerschromiumrestdeepcopyjsmruguidzxnodejscurlsortedargvidredirectArrayBuffer#slice6to5checktapawesomesauceremoveinvariantUint32ArrayECMAScript 2016fromcollection.es6infullcolumnsgetPrototypeOfi18ndeepclonerm -frRegExp#flagsl10njson-schema-validationArray.prototype.containsisclassnamecloudfrontfswaapiglobalscodesCSSregular expressionapimetadataqueueMicrotaskArrayBuffer.prototype.sliceec2collectiongetterSeturlparseeventsawsmake dirglobal objectpoint-freetranspilebrowserutilityreadablethreees5iterateJSON-SchemaECMAScript 2019getbabel-corecloudsearchtrimRightpipeArray.prototype.flatMaptestES8polyfillchannelregularnamesfindupcallboundhardlinkstypeinspectbabelcoerciblecommandglacierzerosymbolsflatMapboundes8dirminimalroutingpinoterm.gitignoreentriessharedarraybufferconcatMapECMAScript 2021ECMAScript 2015callbackArray.prototype.flattenassertsappharmonyviewarraybuffershamgenericsglobalThisfastclonegesturesmochaexpressiones2018recursiveeslint-pluginreadconcatAsyncIteratorregular expressionsavabinstringifierfnmatchgetOwnPropertyDescriptorserializationmakeelasticachefast-clonekoreantimeMapequaldependency managerFunction.prototype.nameFloat64ArrayquotefindLastwalkprocessObject.definePropertyoutputclass-validatorweakmapterminalcircularcopyWebSocketRxrestfulsettercolumnincludesjoistoragegatewaycloudformationdayjsespreerulesfind-upnativefast-copyRFC-6455mkdirpcallbinddotenvramdatestingstringsource mapbuffercomparefindyuppopmotionES2017idlenumberbuffersrsspropertiesflatsearchdefinePropertytddmoveObject.entriesletphonetoStringTagdraggetintrinsicinferenceglobalkeydeletes3enderECMAScript 7argumentsesECMAScript 5Array.prototype.includesindicatorapolloamazonformattingdropdom-testing-libraryrfc4122functionxmlECMAScriptcore-jsstreamoptimistlibphonenumbertransformpackage manageragentreactdeterministicredux-toolkitjasminedebuggerECMAScript 6npmtapeiamcryptoemrdeepformatfpspluginmaptypesyamlclientes-shim APIStyleSheetpackage.jsonhelperbinariesredacteventEmittercliaccessorhascontainscloudwatchwindowarraysdynamodbbrowserslistURLSearchParamscss[[Prototype]]globimportvalidatorhashmkdirstexthttpsURLlengthtypedarrayreduxqueueUnderscoreqsecmascriptform-validationcoveragebinarysome3dglobal this valueES2020extracharacterES2022waitwgetutilitiesmapreducefullwidthsidefull-widthrobustgdprflattentrimimmutableflagspropertynodepackagesforkparserString.prototype.matchAllutilES6censorcode pointsdomcharacterstslibgroupworkspace:*environmentshasOwnPropertyjQuerycacheshrinkwrapes6Object.valuescompilerownlockfilelocalloadinguuidwebtypanionexecfileReflect.getPrototypeOf.envacorndebugworkflowxhrvarswriteUint8Arrayes2015PromiseargsArray.prototype.filterperformantcommanderobjectjsonpackagefolderlastlanguagepurebusyfastifystableajaxvarsetdeep-copycall-bindkarmaprettyscheme-validationvalidatepropsharedhelpersTypeBoximportexportrapidtostringtagescapeautoprefixerES2016setImmediateWebSocketsreuseswfprefixvalidationvestjsdomnegativeemoji
5.10.96

10 months ago

5.10.95

10 months ago

5.10.94

10 months ago

5.10.93

10 months ago

5.10.92

10 months ago

5.10.91

11 months ago

5.10.90

11 months ago

5.10.89

11 months ago

5.10.88

11 months ago

5.10.87

11 months ago

5.10.86

11 months ago

5.10.85

11 months ago

5.10.84

11 months ago

5.10.83

11 months ago

5.10.82

11 months ago

5.10.81

11 months ago

5.9.81

11 months ago

5.9.80

11 months ago

5.9.79

11 months ago

5.9.78

11 months ago

4.9.78

11 months ago

4.8.78

11 months ago

4.8.77

11 months ago

4.8.76

11 months ago

4.8.75

11 months ago

4.8.74

11 months ago

4.8.73

11 months ago

4.8.72

11 months ago

4.7.72

11 months ago

4.7.71

11 months ago

4.7.70

11 months ago

4.6.70

11 months ago

4.6.69

11 months ago

4.6.68

11 months ago

4.6.67

11 months ago

3.6.67

12 months ago

3.6.66

12 months ago

3.6.65

12 months ago

3.6.64

12 months ago

3.6.63

12 months ago

3.6.62

12 months ago

3.6.61

12 months ago

3.5.61

12 months ago

3.5.60

12 months ago

3.5.59

12 months ago

3.5.58

12 months ago

3.5.57

12 months ago

3.5.56

12 months ago

3.5.55

12 months ago

3.5.54

12 months ago

3.5.53

12 months ago

3.5.52

12 months ago

3.5.51

12 months ago

3.5.50

12 months ago

3.5.49

12 months ago

3.5.48

1 year ago

3.4.48

1 year ago

3.4.47

1 year ago

3.4.46

1 year ago

3.4.45

1 year ago

3.4.44

1 year ago

3.4.43

1 year ago

3.4.42

1 year ago

3.4.41

1 year ago

2.4.41

1 year ago

2.4.40

1 year ago

2.4.39

1 year ago

2.4.38

1 year ago

2.3.38

1 year ago

2.3.37

1 year ago

2.3.36

1 year ago

2.3.35

1 year ago

2.3.34

1 year ago

2.3.33

1 year ago

2.3.32

1 year ago

2.2.32

1 year ago

2.2.31

1 year ago

2.2.30

1 year ago

2.2.29

1 year ago

2.2.28

1 year ago

2.2.27

1 year ago

2.2.26

1 year ago

2.2.25

1 year ago

2.2.24

1 year ago

2.2.23

1 year ago

2.2.22

1 year ago

2.2.21

1 year ago

2.2.20

1 year ago

2.2.19

1 year ago

2.2.18

1 year ago

2.2.17

1 year ago

2.2.16

1 year ago

2.2.15

1 year ago

2.1.15

1 year ago

2.1.14

1 year ago

2.1.13

1 year ago

2.1.12

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago