This plugin is migrated version of https://github.com/ubaltaci/hapi-basic-i18n for Hapi@v19.
For test reports: Test Report
-
Plugin options w/ registration;
await server.register([ { register: require("hapi-basic-i18n"), options: { locale_path: "<absolutePath>", cookie_name: "language", default_language: "EN", available_languages: ["EN"] } }]);
-
In view context:
{{i18n "wtf"}}
-
In route handler:
function(request, h) { return 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!"