talizen 0.2.19 → 0.2.21
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/i18n.js +4 -2
- package/package.json +1 -1
package/i18n.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { getTalizenConfig, subscribeTalizenConfig } from "./core.js";
|
|
3
|
+
const emptyMessages = {};
|
|
3
4
|
let lastSnapshot = null;
|
|
4
5
|
let lastSnapshotI18n;
|
|
5
6
|
let lastSnapshotMessages;
|
|
6
7
|
function readI18nRuntimeConfig() {
|
|
7
8
|
const config = getTalizenConfig();
|
|
9
|
+
const globalConfig = typeof globalThis !== "undefined" ? globalThis.TalizenConfig : undefined;
|
|
8
10
|
const fallbackI18n = typeof globalThis !== "undefined" ? globalThis.__TALIZEN_I18N__ : undefined;
|
|
9
11
|
const fallbackMessages = typeof globalThis !== "undefined" ? globalThis.__TALIZEN_MESSAGES__ : undefined;
|
|
10
|
-
const i18n = config.i18n ?? fallbackI18n;
|
|
11
|
-
const messages = config.messages ?? fallbackMessages ??
|
|
12
|
+
const i18n = config.i18n ?? globalConfig?.i18n ?? fallbackI18n;
|
|
13
|
+
const messages = config.messages ?? globalConfig?.messages ?? fallbackMessages ?? emptyMessages;
|
|
12
14
|
if (lastSnapshot && lastSnapshotI18n === i18n && lastSnapshotMessages === messages) {
|
|
13
15
|
return lastSnapshot;
|
|
14
16
|
}
|