@rpcbase/client 0.43.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/i18next.js +10 -2
  2. package/package.json +3 -2
package/i18next.js CHANGED
@@ -6,8 +6,17 @@ import resourcesToBackend from "i18next-resources-to-backend"
6
6
 
7
7
  export const SUPPORTED_LOCALES = ["en", "fr", "es", "pt", "de"]
8
8
 
9
+ const LOCALE_KEY = "rb.i18n_locale"
9
10
  const DEFAULT_LOCALE = "en"
10
11
 
12
+ // https://github.com/i18next/i18next-browser-languageDetector
13
+
14
+ // get stored locale or fallback to navigator
15
+ let locale = localStorage.getItem(LOCALE_KEY)
16
+ if (!locale) {
17
+ locale = navigator.language
18
+ }
19
+
11
20
  // Do not call this code directly, it is injected from babel-plugin-i18next-client by the bundler
12
21
  export default (backendFn) => {
13
22
 
@@ -15,7 +24,7 @@ export default (backendFn) => {
15
24
  .use(ChainedBackend)
16
25
  .use(initReactI18next)
17
26
  .init({
18
- lng: DEFAULT_LOCALE,
27
+ lng: locale,
19
28
  fallbackLng: (code) => {
20
29
  if (code.indexOf("-") > -1) {
21
30
  const [firstPart] = code.split("-")
@@ -26,7 +35,6 @@ export default (backendFn) => {
26
35
  // no match in our locales, fallback to default
27
36
  return DEFAULT_LOCALE
28
37
  },
29
- ns: ["common", "landing"],
30
38
  defaultNS: "common",
31
39
  backend: {
32
40
  backends: [resourcesToBackend(backendFn)],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 0"
6
6
  },
@@ -9,6 +9,7 @@
9
9
  "i18next": "23.2.11",
10
10
  "i18next-chained-backend": "4.4.0",
11
11
  "i18next-resources-to-backend": "1.1.4",
12
- "lodash": "4.17.21"
12
+ "lodash": "4.17.21",
13
+ "react-i18next": "13.0.1"
13
14
  }
14
15
  }