hapi-basic-i18n-accept-language
v1.0.6
Published
A forked version of hapi-basic-i18n for working with Accept-Language header
Downloads
2
Maintainers
Readme
##hapi-basic-i18n-accept-language
npm install hapi-basic-i18n-accept-language --save
npm install accept-language-parser --save
Plugin options w/ registration;
server.register([ { register: require("hapi-basic-i18n-accept-language"), options: { locale_path: "<absolutePath>", cookie_name: "language", default_language: "EN", available_languages: ["EN"] } }], cb);
In view context:
{{i18n "wtf"}}
In route handler:
function(request, reply) { reply(request.i18n("wtf")); }
Simply
// en.js module.exports = { "Hello": "Hello {0}!", }; // in route handler console.log(request.i18n("Hello", "John")); // in view {{i18n "Hello" "John"}} // Both outputs are "Hello John!"