@inglorious/i18n 2.1.0 → 2.1.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/i18n",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Internationalization for Inglorious Web: an i18next instance driven by a store entity.",
5
5
  "author": "Matteo Antony Mistretta <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -34,13 +34,13 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "i18next": "^27.0.0"
37
+ "i18next": "^27.2.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@inglorious/eslint-config": "1.2.0",
41
- "@inglorious/store": "12.3.0",
42
- "prettier": "^3.9.10",
43
- "vitest": "^5.1.0"
41
+ "@inglorious/store": "12.9.1",
42
+ "prettier": "^3.10.1",
43
+ "vitest": "^5.1.1"
44
44
  },
45
45
  "engines": {
46
46
  "node": ">= 26"
package/src/index.js CHANGED
@@ -359,7 +359,7 @@ function languageName(locale) {
359
359
  function readLocale(storageKey) {
360
360
  if (!storageKey) return null
361
361
  try {
362
- return globalThis.localStorage?.getItem(storageKey) ?? null
362
+ return globalThis.window?.localStorage?.getItem(storageKey) ?? null
363
363
  } catch {
364
364
  return null
365
365
  }
@@ -368,7 +368,7 @@ function readLocale(storageKey) {
368
368
  function saveLocale(storageKey, locale) {
369
369
  if (!storageKey) return
370
370
  try {
371
- globalThis.localStorage?.setItem(storageKey, locale)
371
+ globalThis.window?.localStorage?.setItem(storageKey, locale)
372
372
  } catch {
373
373
  // Not persisting the choice is better than breaking the switch.
374
374
  }
package/src/index.test.js CHANGED
@@ -26,10 +26,12 @@ function stubBrowser({ languages = [], saved = {}, search = "" } = {}) {
26
26
  const store = { ...saved }
27
27
  vi.stubGlobal("location", { search })
28
28
  vi.stubGlobal("navigator", { languages, language: languages[0] })
29
- vi.stubGlobal("localStorage", {
30
- getItem: (key) => store[key] ?? null,
31
- setItem: (key, value) => {
32
- store[key] = value
29
+ vi.stubGlobal("window", {
30
+ localStorage: {
31
+ getItem: (key) => store[key] ?? null,
32
+ setItem: (key, value) => {
33
+ store[key] = value
34
+ },
33
35
  },
34
36
  })
35
37
  vi.stubGlobal("document", { documentElement: { lang: "", dir: "" } })