我有一个 ReactJs 应用程序,我想为其添加本地化功能。我以前从未使用过 i18next,但我正在努力习惯它。我的问题是,我无法检测用户浏览器使用的语言。这是我的代码,您可以帮我写一些代码吗?我已经搜索了该主题的所有文档和答案,但找不到任何解决方案。
\n\n这是我的 i18n.js 文件,我将其导入到我想要使用的文件中
\n\nimport i18next from \'i18next\';\nimport languageDetector from \'i18next-browser-languagedetector\';\ni18next\n .use(languageDetector)\n .init({\n debug: true,\n fallbackLng: "en",\n resources: {\n en: {\n translation: {\n "table": {\n "fortuneId": "FortuneId",\n "name": "Name",\n "age": "Age",\n "date": "Date",\n "relationship": "Relationship",\n "note": "Note",\n "topic": "Topic",\n "question": "Question",\n "gender": "Gender",\n "rejected": "Rejected"\n },\n\n "auth": {\n "signIn": "Sign In",\n "signOut": "Sign Out",\n "joinUs": "Join Us",\n "goBack": "Go Back",\n "email": "E-mail",\n "username": "Username",\n "password": "Password",\n },\n\n "admin": {\n "employee": "Employees",\n "moderator": "Moderator",\n "admin": "Admin",\n …Run Code Online (Sandbox Code Playgroud)