diff --git a/package.json b/package.json index 68115f7fcc3..0e81e1e61da 100644 --- a/package.json +++ b/package.json @@ -201,6 +201,7 @@ "firebase": "^7.24.0", "graphql": "^15.3.0", "i18next": "^23.7.6", + "i18next-browser-languagedetector": "^7.2.0", "isomorphic-fetch": "^3.0.0", "jsonic": "^0.3.0", "jszip": "3.8.0", diff --git a/src/browser/i18n.ts b/src/browser/i18n.ts index a6402fb1d0a..5df1f7673ac 100644 --- a/src/browser/i18n.ts +++ b/src/browser/i18n.ts @@ -1,13 +1,16 @@ import i18n from 'i18next' -import { resources } from 'neo4j-arc/graph-visualization' import { initReactI18next } from 'react-i18next' +import { resources } from 'neo4j-arc/graph-visualization' +import LanguageDetector from 'i18next-browser-languagedetector' -i18n.use(initReactI18next).init({ - resources, - lng: 'zh', - interpolation: { - escapeValue: false - } -}) +i18n + .use(LanguageDetector) + .use(initReactI18next) + .init({ + resources, + interpolation: { + escapeValue: false + } + }) export default i18n diff --git a/yarn.lock b/yarn.lock index 9330faaaa7a..2de39d55885 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7357,6 +7357,13 @@ hyphenate-style-name@^1.0.2: resolved "https://registry.npmjs.org/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz" integrity sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ== +i18next-browser-languagedetector@^7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/i18next-browser-languagedetector/-/i18next-browser-languagedetector-7.2.0.tgz#de0321cba6881be37d82e20e4d6f05aa75f6e37f" + integrity sha512-U00DbDtFIYD3wkWsr2aVGfXGAj2TgnELzOX9qv8bT0aJtvPV9CRO77h+vgmHFBMe7LAxdwvT/7VkCWGya6L3tA== + dependencies: + "@babel/runtime" "^7.23.2" + i18next@^23.7.6: version "23.7.6" resolved "https://registry.yarnpkg.com/i18next/-/i18next-23.7.6.tgz#7328e76c899052d5d33d930164612dd21e575f74"