reactjs - 使用 react i18n 部署我的 React 应用程序会在 locales.json 上引发 404 错误
问题描述
我已经在 Netlify 上部署了我的 React 应用程序 (CRA),但它在所有 translations.json 文件上给了我 404 错误。它在本地工作,所以我迷路了。
我的 i18n 设置文件如下所示:
import i18n from 'i18next'
import Backend from 'i18next-xhr-backend'
import LanguageDetector from 'i18next-browser-languagedetector'
import { initReactI18next } from 'react-i18next'
export const appLocales = ['en', 'ja', 'nl']
i18n.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
debug: false,
lng: 'en',
fallbackLng: 'en',
whitelist: appLocales,
interpolation: {
escapeValue: false
}
})
export default i18n
虽然翻译似乎正在工作,但我想知道为什么它首先抛出 404 错误。有人可以帮我吗?
解决方案
推荐阅读
- javascript - 如何在第一次单击时执行操作,在第二次单击时执行另一个操作
- javascript - 运行 Jest 时出现`SyntaxError: Cannot use import statement outside a module`
- maven - 如何解决使用 jib-maven-plugin 从 Cloud Build 推送到 Google Artifact Registry 的权限?
- postgresql - 从大表中获取有序数据的最佳方法
- azure - azure databricks google bigquery coonectiv8ty 错误
- azure-ad-b2c - 带有 Google 托管应用签名的 Azure AD B2C 签名哈希
- swift - iOS firestore addSnapshotListeners 跨多个客户端停止接收更新 20-30 秒
- c++ - 有没有办法计算字符串数组中每个元素的出现次数?
- java - swagger v3 中的 io.swagger.jersey 等效项
- google-bigquery - BigQuery API 和 BigQuery Storage API 之间的区别?