@rpcbase/client 0.41.0 → 0.43.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.
package/auth/index.js CHANGED
@@ -12,7 +12,7 @@ const log = debug("rb:auth")
12
12
  // TODO: this should be refactored to AuthContext + Provider
13
13
 
14
14
  let __is_authenticated = null
15
- let __user_id = localStorage?.getItem(UID_STORAGE_KEY)
15
+ let __user_id = typeof localStorage !== "undefined" && localStorage.getItem(UID_STORAGE_KEY)
16
16
 
17
17
 
18
18
  const run_session_check = async() => {
package/i18next.js ADDED
@@ -0,0 +1,38 @@
1
+ /* @flow */
2
+ import i18n from "i18next"
3
+ import {initReactI18next} from "react-i18next"
4
+ import ChainedBackend from "i18next-chained-backend"
5
+ import resourcesToBackend from "i18next-resources-to-backend"
6
+
7
+ export const SUPPORTED_LOCALES = ["en", "fr", "es", "pt", "de"]
8
+
9
+ const DEFAULT_LOCALE = "en"
10
+
11
+ // Do not call this code directly, it is injected from babel-plugin-i18next-client by the bundler
12
+ export default (backendFn) => {
13
+
14
+ i18n
15
+ .use(ChainedBackend)
16
+ .use(initReactI18next)
17
+ .init({
18
+ lng: DEFAULT_LOCALE,
19
+ fallbackLng: (code) => {
20
+ if (code.indexOf("-") > -1) {
21
+ const [firstPart] = code.split("-")
22
+ if (SUPPORTED_LOCALES.includes(firstPart)) return firstPart
23
+ } else if (SUPPORTED_LOCALES.includes(code)) {
24
+ return code
25
+ }
26
+ // no match in our locales, fallback to default
27
+ return DEFAULT_LOCALE
28
+ },
29
+ ns: ["common", "landing"],
30
+ defaultNS: "common",
31
+ backend: {
32
+ backends: [resourcesToBackend(backendFn)],
33
+ },
34
+ interpolation: {
35
+ escapeValue: false,
36
+ },
37
+ })
38
+ }
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.41.0",
3
+ "version": "0.43.0",
4
4
  "scripts": {
5
5
  "test": "echo \"Error: no test specified\" && exit 0"
6
6
  },
7
7
  "dependencies": {
8
- "axios": "0.27.2",
8
+ "axios": "1.4.0",
9
+ "i18next": "23.2.11",
10
+ "i18next-chained-backend": "4.4.0",
11
+ "i18next-resources-to-backend": "1.1.4",
9
12
  "lodash": "4.17.21"
10
13
  }
11
14
  }