【发布时间】:2018-04-02 05:58:12
【问题描述】:
我在我的 Express + pug 应用程序中使用 i18n。我通过以下方式完成了 i18 配置:
i18n = require("i18n")
i18n.configure({
locales:['en', 'mn'],
directory: __dirname + '/locales'
});
app.use(i18n.init);
app.use(function(req, res, next) {
// express helper for natively supported engines
res.locals.__ = res.__ = function() {
return i18n.__.apply(req, arguments);
};
next();
});
但我不知道如何在 pug 文件中使用它。我已经尝试过这样的方法,但没有成功:
input(type="text" name="near-location" placeholder="__('Ask')")
input(type="text" name="near-location" placeholder="${__('Ask')}"
input(type="text" name="near-location" placeholder="#{Ask}")
我应该如何在 pug 模板中使用 i18n?
【问题讨论】:
-
你找到解决办法了吗
-
@ramon22,我最终使用了 ejs
标签: express internationalization pug