使用i18next加载日语翻译文件时出现URL解析错误的问题求助
i18next加载日语翻译文件时出现URL解析错误的问题求助
我现在在用i18next做项目的国际化翻译,结果碰到了一个URL解析失败的错误,具体报错信息如下:
i18next::backendConnector: loading namespace translation for language ja failed TypeError: Failed to parse URL from /locales/ja/translation.json
at Object.fetch (node:internal/deps/undici/undici:11576:11) {
[cause]: TypeError [ERR_INVALID_URL]: Invalid URL
我已经把翻译文件放在了 /public/locales/ja/translation.json 路径下,而且JSON文件本身是有效的,浏览器的网络面板里也看不到失败的请求,所以我感觉大概率是配置哪里出问题了。
下面是我的i18n配置代码:
import i18n from 'i18next'; import LanguageDetector from 'i18next-browser-languagedetector'; import Backend from 'i18next-http-backend'; import { initReactI18next } from 'react-i18next'; if (!i18n.isInitialized) { i18n .use(Backend) .use(LanguageDetector) .use(initReactI18next) .init({ supportedLngs: ['en', 'ja'], fallbackLng: 'ja', debug: true, }); } export default i18n;
有没有大佬能给点排查方向或者解决方案?非常感谢!
备注:内容来源于stack exchange,提问作者Andon Mitev
相关产品推荐
相关产品推荐

