formatjs / handlebars-intl

Handlebars helpers for internationalization.
http://formatjs.io/handlebars/
Other
265 stars 28 forks source link

Setting the locale of Handlebars Intl using Express #89

Open ghost opened 6 years ago

ghost commented 6 years ago

I'm using express, express-handlebars and handlebars-intl and I would like to change the default "en" locale to another (like "it").

I read that this plugin uses Intl.DateTimeFormat to formats. In this specific case how can I edit things like locale, timezone, date formats, etc..

    const hbs = exphbs.create({ extname: '.hbs' });
    app.engine(hbs.extname, hbs.engine);
    HandlebarsIntl.registerWith(hbs.handlebars); // Handlebars Intl Plugin
    app.set('view engine', hbs.extname);
    app.set('views', path.join(__dirname, './views/pages'));

Final goal:

Correctly renders with Handlebars this datetime {{formatDate time}} using my specified locale

ghost commented 6 years ago

Just tried:

global.HandlebarsIntl = HandlebarsIntl;
require('handlebars-intl/dist/locale-data/it');

or even:

HandlebarsIntl.__addLocaleData({locale: "it"})

No errors but does not works, what am I missing? :\

SergioEnrique commented 5 years ago

same issue

szappala commented 5 years ago

same issue

igordeoliveirasa commented 4 years ago

same issue