@sheet-i18n/react-client 1.5.0-canary.1 → 1.5.0-canary.11

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/dist/index.d.mts CHANGED
@@ -87,4 +87,4 @@ declare function createI18nContext<TSupportedLocales extends readonly string[],
87
87
  useLocaleStorage: typeof useLocaleStorage;
88
88
  };
89
89
 
90
- export { createI18nContext };
90
+ export { type IStorageService, createI18nContext };
package/dist/index.d.ts CHANGED
@@ -87,4 +87,4 @@ declare function createI18nContext<TSupportedLocales extends readonly string[],
87
87
  useLocaleStorage: typeof useLocaleStorage;
88
88
  };
89
89
 
90
- export { createI18nContext };
90
+ export { type IStorageService, createI18nContext };
package/dist/index.js CHANGED
@@ -176,7 +176,8 @@ function IntlProvider({
176
176
  messages: i18nStore == null ? void 0 : i18nStore.localeSet[locale],
177
177
  onError: onIntlError,
178
178
  children: !isLoading && children
179
- }
179
+ },
180
+ `sheet-i18n-locale-${locale}`
180
181
  );
181
182
  }
182
183
  function useIntlLocale({
@@ -418,11 +419,10 @@ var LocaleStorageManager = class {
418
419
  this.observerManager = new import_shared_utils4.ObserverManager();
419
420
  this.initializeCurrentLocale = () => {
420
421
  var _a, _b;
421
- if (this.storageService && this.i18nStore.currentLocale) {
422
- this.storageService.setItem(
423
- this.localeStorageKey,
424
- this.i18nStore.currentLocale
425
- );
422
+ const storedLocale = this.storageService.getItem(this.localeStorageKey);
423
+ if (!storedLocale || storedLocale === "") {
424
+ const defaultLocale = this.i18nStore.currentLocale || this.i18nStore.defaultLocale;
425
+ this.storageService.setItem(this.localeStorageKey, defaultLocale);
426
426
  }
427
427
  (_b = (_a = this.i18nStore) == null ? void 0 : _a.observerManager) == null ? void 0 : _b.addListener({
428
428
  listenerId: this.localeStorageKey,
@@ -433,7 +433,10 @@ var LocaleStorageManager = class {
433
433
  };
434
434
  this.getLocale = () => {
435
435
  const stored = this.storageService.getItem(this.localeStorageKey);
436
- return stored != null ? stored : "";
436
+ if (!stored || stored === "") {
437
+ return this.i18nStore.defaultLocale;
438
+ }
439
+ return stored;
437
440
  };
438
441
  this.setLocale = (locale) => {
439
442
  this.storageService.setItem(this.localeStorageKey, locale);
package/dist/index.mjs CHANGED
@@ -153,7 +153,8 @@ function IntlProvider({
153
153
  messages: i18nStore == null ? void 0 : i18nStore.localeSet[locale],
154
154
  onError: onIntlError,
155
155
  children: !isLoading && children
156
- }
156
+ },
157
+ `sheet-i18n-locale-${locale}`
157
158
  );
158
159
  }
159
160
  function useIntlLocale({
@@ -395,11 +396,10 @@ var LocaleStorageManager = class {
395
396
  this.observerManager = new ObserverManager();
396
397
  this.initializeCurrentLocale = () => {
397
398
  var _a, _b;
398
- if (this.storageService && this.i18nStore.currentLocale) {
399
- this.storageService.setItem(
400
- this.localeStorageKey,
401
- this.i18nStore.currentLocale
402
- );
399
+ const storedLocale = this.storageService.getItem(this.localeStorageKey);
400
+ if (!storedLocale || storedLocale === "") {
401
+ const defaultLocale = this.i18nStore.currentLocale || this.i18nStore.defaultLocale;
402
+ this.storageService.setItem(this.localeStorageKey, defaultLocale);
403
403
  }
404
404
  (_b = (_a = this.i18nStore) == null ? void 0 : _a.observerManager) == null ? void 0 : _b.addListener({
405
405
  listenerId: this.localeStorageKey,
@@ -410,7 +410,10 @@ var LocaleStorageManager = class {
410
410
  };
411
411
  this.getLocale = () => {
412
412
  const stored = this.storageService.getItem(this.localeStorageKey);
413
- return stored != null ? stored : "";
413
+ if (!stored || stored === "") {
414
+ return this.i18nStore.defaultLocale;
415
+ }
416
+ return stored;
414
417
  };
415
418
  this.setLocale = (locale) => {
416
419
  this.storageService.setItem(this.localeStorageKey, locale);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheet-i18n/react-client",
3
- "version": "1.5.0-canary.1",
3
+ "version": "1.5.0-canary.11",
4
4
  "description": "a client package for react modules used by sheet-i18n",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -25,16 +25,16 @@
25
25
  },
26
26
  "license": "ISC",
27
27
  "dependencies": {
28
- "@sheet-i18n/shared-utils": "1.8.0-canary.0",
29
- "@sheet-i18n/errors": "1.8.0-canary.0",
30
- "@sheet-i18n/react-core": "1.5.0-canary.0"
28
+ "@sheet-i18n/shared-utils": "1.8.0-canary.5",
29
+ "@sheet-i18n/errors": "1.8.0-canary.5",
30
+ "@sheet-i18n/react-core": "1.5.0-canary.5"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/react": "^19.0.2",
34
34
  "@types/react-dom": "^19.0.2",
35
35
  "react": "^18.2.0",
36
36
  "react-intl": "^7.0.4",
37
- "@sheet-i18n/typescript-config": "1.8.0-canary.0"
37
+ "@sheet-i18n/typescript-config": "1.8.0-canary.5"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "^18 || ^19 || ^20 || ^21",