@zachhandley/ez-i18n 0.3.0 → 0.3.1
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/package.json
CHANGED
|
@@ -43,8 +43,8 @@ const serializedTranslations = JSON.stringify(translations);
|
|
|
43
43
|
const locale = script.dataset.ezI18nLocale;
|
|
44
44
|
const translations = JSON.parse(script.dataset.ezI18nTranslations || '{}');
|
|
45
45
|
|
|
46
|
-
// Store for runtime initialization
|
|
47
|
-
|
|
46
|
+
// Store for runtime initialization (globalThis is SSR-safe and equals window in browsers)
|
|
47
|
+
globalThis.__EZ_I18N_INIT__ = { locale, translations };
|
|
48
48
|
})();
|
|
49
49
|
</script>
|
|
50
50
|
|
|
@@ -53,10 +53,11 @@ const serializedTranslations = JSON.stringify(translations);
|
|
|
53
53
|
import { initLocale, setTranslations } from '@zachhandley/ez-i18n/runtime';
|
|
54
54
|
|
|
55
55
|
// Get initialization data from inline script
|
|
56
|
-
|
|
56
|
+
// Note: Don't delete __EZ_I18N_INIT__ here - other bundles (Vue, React)
|
|
57
|
+
// may need to read it to initialize their own store instances
|
|
58
|
+
const initData = (globalThis as any).__EZ_I18N_INIT__;
|
|
57
59
|
if (initData) {
|
|
58
60
|
initLocale(initData.locale, initData.translations);
|
|
59
61
|
setTranslations(initData.translations);
|
|
60
|
-
delete (window as any).__EZ_I18N_INIT__;
|
|
61
62
|
}
|
|
62
63
|
</script>
|