我正在为我的next.js项目使用next-i18next包。现在,我正在发送创建电子邮件功能,这需要在服务器端,我想消费相同的翻译文件,我已经使用的前端。
next-i18next是否提供了类似于在前端使用翻译的功能?
发布于 2020-07-17 16:01:30
如果正确设置了next-i18next,就可以使用req.i18n.t;
const nextI18NextMiddleware = require('next-i18next/middleware').default;
...
server.use(nextI18NextMiddleware(nextI18next));
server.get('/custom', (req, res) => {
...
res.json({
text: req.i18n.t('Text here'),
lng: req.i18n.language,
});
});https://stackoverflow.com/questions/59594231
复制相似问题