@furystack/shades-i18n 3.0.6 → 5.0.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.0.0] - 2026-04-25
|
|
4
|
+
|
|
5
|
+
### 💥 Breaking Changes
|
|
6
|
+
|
|
7
|
+
Version bumped to align with the monorepo-wide functional DI migration. See the [v7 migration guide](../../docs/migrations/v7-functional-di.md) for rationale and patterns.
|
|
8
|
+
|
|
9
|
+
- No runtime API changes. Test fixtures now import the concrete `I18NServiceImpl` class from `@furystack/i18n` (the `I18NService` interface is no longer constructable).
|
|
10
|
+
|
|
11
|
+
## [4.0.0] - 2026-04-22
|
|
12
|
+
|
|
13
|
+
### 💥 Breaking Changes
|
|
14
|
+
|
|
15
|
+
### Bumped peer dependency on `@furystack/shades`
|
|
16
|
+
|
|
17
|
+
This release aligns with the `@furystack/shades` major release that renamed `NestedRouteLink`'s `href` prop to `path` and switched `nestedNavigate` to an object-arg signature. No source changes were required in this package, but consumers that also use `@furystack/shades` routing APIs need to migrate those call sites — see the `@furystack/shades` changelog for details.
|
|
18
|
+
|
|
19
|
+
**Impact:** Consumers upgrading to the new `@furystack/shades` major must also update any `NestedRouteLink` / `nestedNavigate` call sites in their own code.
|
|
20
|
+
|
|
3
21
|
## [3.0.6] - 2026-04-17
|
|
4
22
|
|
|
5
23
|
### ⬆️ Dependencies
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { I18NServiceImpl } from '@furystack/i18n';
|
|
2
|
+
import { createInjector } from '@furystack/inject';
|
|
3
3
|
import { createComponent, flushUpdates, initializeShadeRoot } from '@furystack/shades';
|
|
4
4
|
import { usingAsync } from '@furystack/utils';
|
|
5
5
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
6
6
|
import { createI18nComponent } from './create-i18n-component.js';
|
|
7
7
|
const createTestService = () => {
|
|
8
|
-
return new
|
|
8
|
+
return new I18NServiceImpl({
|
|
9
9
|
code: 'en',
|
|
10
10
|
values: {
|
|
11
11
|
hello: 'Hello',
|
|
@@ -35,7 +35,7 @@ describe('createI18nComponent', () => {
|
|
|
35
35
|
document.body.innerHTML = '';
|
|
36
36
|
});
|
|
37
37
|
it('should render with the initial translation', async () => {
|
|
38
|
-
await usingAsync(
|
|
38
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
39
39
|
const service = createTestService();
|
|
40
40
|
const I18n = createI18nComponent({
|
|
41
41
|
service,
|
|
@@ -52,7 +52,7 @@ describe('createI18nComponent', () => {
|
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
it('should render with the correct translation for different keys', async () => {
|
|
55
|
-
await usingAsync(
|
|
55
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
56
56
|
const service = createTestService();
|
|
57
57
|
const I18n = createI18nComponent({
|
|
58
58
|
service,
|
|
@@ -72,7 +72,7 @@ describe('createI18nComponent', () => {
|
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
it('should update when language changes', async () => {
|
|
75
|
-
await usingAsync(
|
|
75
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
76
76
|
const service = createTestService();
|
|
77
77
|
const I18n = createI18nComponent({
|
|
78
78
|
service,
|
|
@@ -95,7 +95,7 @@ describe('createI18nComponent', () => {
|
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
it('should fallback to default language for missing keys', async () => {
|
|
98
|
-
await usingAsync(
|
|
98
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
99
99
|
const service = createTestService();
|
|
100
100
|
const I18n = createI18nComponent({
|
|
101
101
|
service,
|
|
@@ -116,7 +116,7 @@ describe('createI18nComponent', () => {
|
|
|
116
116
|
});
|
|
117
117
|
});
|
|
118
118
|
it('should handle rapid language changes', async () => {
|
|
119
|
-
await usingAsync(
|
|
119
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
120
120
|
const service = createTestService();
|
|
121
121
|
const I18n = createI18nComponent({
|
|
122
122
|
service,
|
|
@@ -139,7 +139,7 @@ describe('createI18nComponent', () => {
|
|
|
139
139
|
});
|
|
140
140
|
});
|
|
141
141
|
it('should cleanup subscription on unmount', async () => {
|
|
142
|
-
await usingAsync(
|
|
142
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
143
143
|
const service = createTestService();
|
|
144
144
|
const unsubscribeSpy = vi.fn();
|
|
145
145
|
const originalSubscribe = service.subscribe.bind(service);
|
|
@@ -171,7 +171,7 @@ describe('createI18nComponent', () => {
|
|
|
171
171
|
});
|
|
172
172
|
});
|
|
173
173
|
it('should render as span element', async () => {
|
|
174
|
-
await usingAsync(
|
|
174
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
175
175
|
const service = createTestService();
|
|
176
176
|
const I18n = createI18nComponent({
|
|
177
177
|
service,
|
|
@@ -190,7 +190,7 @@ describe('createI18nComponent', () => {
|
|
|
190
190
|
});
|
|
191
191
|
});
|
|
192
192
|
it('should work with multiple instances using different keys', async () => {
|
|
193
|
-
await usingAsync(
|
|
193
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
194
194
|
const service = createTestService();
|
|
195
195
|
const I18n = createI18nComponent({
|
|
196
196
|
service,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-i18n-component.spec.js","sourceRoot":"","sources":["../src/create-i18n-component.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"create-i18n-component.spec.js","sourceRoot":"","sources":["../src/create-i18n-component.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;A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CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;YAEvD,OAAO,CAAC,eAAe,GAAG,IAAI,CAAA;YAC9B,MAAM,YAAY,EAAE,CAAA;YACpB,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QACxD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furystack/shades-i18n",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "I18n translation package and components for Shades",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/furystack/furystack",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@furystack/i18n": "^
|
|
41
|
-
"@furystack/inject": "^
|
|
42
|
-
"@furystack/shades": "^
|
|
40
|
+
"@furystack/i18n": "^2.0.0",
|
|
41
|
+
"@furystack/inject": "^13.0.0",
|
|
42
|
+
"@furystack/shades": "^15.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^25.6.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { I18NServiceImpl } from '@furystack/i18n'
|
|
2
|
+
import { createInjector } from '@furystack/inject'
|
|
3
3
|
import { createComponent, flushUpdates, initializeShadeRoot } from '@furystack/shades'
|
|
4
4
|
import { usingAsync } from '@furystack/utils'
|
|
5
5
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
@@ -8,7 +8,7 @@ import { createI18nComponent } from './create-i18n-component.js'
|
|
|
8
8
|
type TestKeys = 'hello' | 'goodbye' | 'world'
|
|
9
9
|
|
|
10
10
|
const createTestService = () => {
|
|
11
|
-
return new
|
|
11
|
+
return new I18NServiceImpl<TestKeys>(
|
|
12
12
|
{
|
|
13
13
|
code: 'en',
|
|
14
14
|
values: {
|
|
@@ -45,7 +45,7 @@ describe('createI18nComponent', () => {
|
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
it('should render with the initial translation', async () => {
|
|
48
|
-
await usingAsync(
|
|
48
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
49
49
|
const service = createTestService()
|
|
50
50
|
const I18n = createI18nComponent({
|
|
51
51
|
service,
|
|
@@ -65,7 +65,7 @@ describe('createI18nComponent', () => {
|
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
it('should render with the correct translation for different keys', async () => {
|
|
68
|
-
await usingAsync(
|
|
68
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
69
69
|
const service = createTestService()
|
|
70
70
|
const I18n = createI18nComponent({
|
|
71
71
|
service,
|
|
@@ -91,7 +91,7 @@ describe('createI18nComponent', () => {
|
|
|
91
91
|
})
|
|
92
92
|
|
|
93
93
|
it('should update when language changes', async () => {
|
|
94
|
-
await usingAsync(
|
|
94
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
95
95
|
const service = createTestService()
|
|
96
96
|
const I18n = createI18nComponent({
|
|
97
97
|
service,
|
|
@@ -119,7 +119,7 @@ describe('createI18nComponent', () => {
|
|
|
119
119
|
})
|
|
120
120
|
|
|
121
121
|
it('should fallback to default language for missing keys', async () => {
|
|
122
|
-
await usingAsync(
|
|
122
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
123
123
|
const service = createTestService()
|
|
124
124
|
const I18n = createI18nComponent({
|
|
125
125
|
service,
|
|
@@ -144,7 +144,7 @@ describe('createI18nComponent', () => {
|
|
|
144
144
|
})
|
|
145
145
|
|
|
146
146
|
it('should handle rapid language changes', async () => {
|
|
147
|
-
await usingAsync(
|
|
147
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
148
148
|
const service = createTestService()
|
|
149
149
|
const I18n = createI18nComponent({
|
|
150
150
|
service,
|
|
@@ -172,7 +172,7 @@ describe('createI18nComponent', () => {
|
|
|
172
172
|
})
|
|
173
173
|
|
|
174
174
|
it('should cleanup subscription on unmount', async () => {
|
|
175
|
-
await usingAsync(
|
|
175
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
176
176
|
const service = createTestService()
|
|
177
177
|
const unsubscribeSpy = vi.fn()
|
|
178
178
|
const originalSubscribe = service.subscribe.bind(service)
|
|
@@ -210,7 +210,7 @@ describe('createI18nComponent', () => {
|
|
|
210
210
|
})
|
|
211
211
|
|
|
212
212
|
it('should render as span element', async () => {
|
|
213
|
-
await usingAsync(
|
|
213
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
214
214
|
const service = createTestService()
|
|
215
215
|
const I18n = createI18nComponent({
|
|
216
216
|
service,
|
|
@@ -232,7 +232,7 @@ describe('createI18nComponent', () => {
|
|
|
232
232
|
})
|
|
233
233
|
|
|
234
234
|
it('should work with multiple instances using different keys', async () => {
|
|
235
|
-
await usingAsync(
|
|
235
|
+
await usingAsync(createInjector(), async (injector) => {
|
|
236
236
|
const service = createTestService()
|
|
237
237
|
const I18n = createI18nComponent({
|
|
238
238
|
service,
|