i18next 在 jquery 中不起作用

i18next don't work in jquery

本文关键字:不起作用 jquery i18next      更新时间:2023-09-26

>我正在尝试使用 i18next 翻译 jQuery 中的消息,但是不工作。

index.js:
========
jQuery(document).ready(function($){
    var msg = $.t("index.info")
}
translation.json:
================
"index": {
    "info": "The Information"
}
app.js:
=======
i18n.init ({saveMissing:   true,
            debug:         true,
            sendMissingTo: 'fallback'
           }
);
i18n.registerAppHelper     (app)
     .serveClientScript    (app)
     .serveDynamicResources(app)
     .serveMissingKeyRoute (app);

我需要在jQuery中使用i18next。

谢谢!

您正在尝试在jquery上下文中调用"t"。 但它应该在 i18n 上下文中调用。

var msg = i18n.t(key);