Skip to content

Latest commit

 

History

History
27 lines (22 loc) · 629 Bytes

usage-with-express.md

File metadata and controls

27 lines (22 loc) · 629 Bytes

Usage with express

localizify can work together with express.

First of all add middleware to switch locale on request:

const localizify = require('localizify');

app.configure(() => {
    // ...
    app.use((request, response, next) => {
        const lang = localizify.detectLocale(request.headers['accept-language']) || "en";
        localize.setLocale(lang);
        next();
    });
    // ...
});

And export translate function as static helpers:

app.helpers({
    // ...
    t: localizify.translate,
});