@abpjs/language-management 3.0.0 → 3.2.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/dist/index.d.mts +475 -153
- package/dist/index.d.ts +475 -153
- package/dist/index.js +214 -21
- package/dist/index.mjs +212 -21
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -50,6 +50,183 @@ var LANGUAGE_MANAGEMENT_ROUTE_PROVIDERS = {
|
|
|
50
50
|
configureRoutes
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
// src/proxy/language.service.ts
|
|
54
|
+
var LanguageService = class {
|
|
55
|
+
constructor(restService) {
|
|
56
|
+
/**
|
|
57
|
+
* API name for multi-API configurations
|
|
58
|
+
*/
|
|
59
|
+
this.apiName = "default";
|
|
60
|
+
this.restService = restService;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create a new language
|
|
64
|
+
* @param input - The language data to create
|
|
65
|
+
* @returns Promise with the created language
|
|
66
|
+
*/
|
|
67
|
+
create(input) {
|
|
68
|
+
return this.restService.request({
|
|
69
|
+
method: "POST",
|
|
70
|
+
url: "/api/language-management/languages",
|
|
71
|
+
body: input
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Delete a language by ID
|
|
76
|
+
* @param id - The language ID to delete
|
|
77
|
+
* @returns Promise resolving when complete
|
|
78
|
+
*/
|
|
79
|
+
delete(id) {
|
|
80
|
+
return this.restService.request({
|
|
81
|
+
method: "DELETE",
|
|
82
|
+
url: `/api/language-management/languages/${id}`
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get a language by ID
|
|
87
|
+
* @param id - The language ID
|
|
88
|
+
* @returns Promise with the language
|
|
89
|
+
*/
|
|
90
|
+
get(id) {
|
|
91
|
+
return this.restService.request({
|
|
92
|
+
method: "GET",
|
|
93
|
+
url: `/api/language-management/languages/${id}`
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get all languages without pagination
|
|
98
|
+
* @returns Promise with all languages
|
|
99
|
+
*/
|
|
100
|
+
getAllList() {
|
|
101
|
+
return this.restService.request({
|
|
102
|
+
method: "GET",
|
|
103
|
+
url: "/api/language-management/languages/all"
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get available cultures for language selection
|
|
108
|
+
* @returns Promise with list of cultures
|
|
109
|
+
*/
|
|
110
|
+
getCulturelist() {
|
|
111
|
+
return this.restService.request({
|
|
112
|
+
method: "GET",
|
|
113
|
+
url: "/api/language-management/languages/culture-list"
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get languages with optional filtering
|
|
118
|
+
* @param input - Query parameters for filtering
|
|
119
|
+
* @returns Promise with list of languages
|
|
120
|
+
*/
|
|
121
|
+
getList(input) {
|
|
122
|
+
return this.restService.request({
|
|
123
|
+
method: "GET",
|
|
124
|
+
url: "/api/language-management/languages",
|
|
125
|
+
params: input
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get available localization resources
|
|
130
|
+
* @returns Promise with list of resources
|
|
131
|
+
*/
|
|
132
|
+
getResources() {
|
|
133
|
+
return this.restService.request({
|
|
134
|
+
method: "GET",
|
|
135
|
+
url: "/api/language-management/languages/resources"
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Set a language as the default language
|
|
140
|
+
* @param id - The language ID to set as default
|
|
141
|
+
* @returns Promise resolving when complete
|
|
142
|
+
*/
|
|
143
|
+
setAsDefault(id) {
|
|
144
|
+
return this.restService.request({
|
|
145
|
+
method: "PUT",
|
|
146
|
+
url: `/api/language-management/languages/${id}/set-as-default`
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Update an existing language
|
|
151
|
+
* @param id - The language ID to update
|
|
152
|
+
* @param input - The updated language data
|
|
153
|
+
* @returns Promise with the updated language
|
|
154
|
+
*/
|
|
155
|
+
update(id, input) {
|
|
156
|
+
return this.restService.request({
|
|
157
|
+
method: "PUT",
|
|
158
|
+
url: `/api/language-management/languages/${id}`,
|
|
159
|
+
body: input
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// src/proxy/language-text.service.ts
|
|
165
|
+
var LanguageTextService = class {
|
|
166
|
+
constructor(restService) {
|
|
167
|
+
/**
|
|
168
|
+
* API name for multi-API configurations
|
|
169
|
+
*/
|
|
170
|
+
this.apiName = "default";
|
|
171
|
+
this.restService = restService;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get a specific language text by resource, culture, and name
|
|
175
|
+
* @param resourceName - The resource name
|
|
176
|
+
* @param cultureName - The culture name
|
|
177
|
+
* @param name - The text key/name
|
|
178
|
+
* @param baseCultureName - The base culture for comparison
|
|
179
|
+
* @returns Promise with the language text
|
|
180
|
+
*/
|
|
181
|
+
get(resourceName, cultureName, name, baseCultureName) {
|
|
182
|
+
return this.restService.request({
|
|
183
|
+
method: "GET",
|
|
184
|
+
url: `/api/language-management/language-texts/${resourceName}/${cultureName}/${name}`,
|
|
185
|
+
params: { baseCultureName }
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get language texts with pagination and filtering
|
|
190
|
+
* @param input - Query parameters for filtering and pagination
|
|
191
|
+
* @returns Promise with paginated language texts
|
|
192
|
+
*/
|
|
193
|
+
getList(input) {
|
|
194
|
+
return this.restService.request({
|
|
195
|
+
method: "GET",
|
|
196
|
+
url: "/api/language-management/language-texts",
|
|
197
|
+
params: input
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Restore a language text to its default value
|
|
202
|
+
* @param resourceName - The resource name
|
|
203
|
+
* @param cultureName - The culture name
|
|
204
|
+
* @param name - The text key/name
|
|
205
|
+
* @returns Promise resolving when complete
|
|
206
|
+
*/
|
|
207
|
+
restoreToDefault(resourceName, cultureName, name) {
|
|
208
|
+
return this.restService.request({
|
|
209
|
+
method: "PUT",
|
|
210
|
+
url: `/api/language-management/language-texts/${resourceName}/${cultureName}/${name}/restore`
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Update a language text value
|
|
215
|
+
* @param resourceName - The resource name
|
|
216
|
+
* @param cultureName - The culture name
|
|
217
|
+
* @param name - The text key/name
|
|
218
|
+
* @param value - The new translated value
|
|
219
|
+
* @returns Promise resolving when complete
|
|
220
|
+
*/
|
|
221
|
+
update(resourceName, cultureName, name, value) {
|
|
222
|
+
return this.restService.request({
|
|
223
|
+
method: "PUT",
|
|
224
|
+
url: `/api/language-management/language-texts/${resourceName}/${cultureName}/${name}`,
|
|
225
|
+
body: { value }
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
53
230
|
// src/guards/extensions.guard.ts
|
|
54
231
|
async function languageManagementExtensionsGuard() {
|
|
55
232
|
return true;
|
|
@@ -343,19 +520,21 @@ var LanguageManagementService = class {
|
|
|
343
520
|
var LanguageManagementStateService = class {
|
|
344
521
|
constructor(rest) {
|
|
345
522
|
this.state = {
|
|
346
|
-
languageResponse: { items: []
|
|
523
|
+
languageResponse: { items: [] },
|
|
347
524
|
languageTextsResponse: { items: [], totalCount: 0 },
|
|
348
525
|
selectedItem: null,
|
|
349
526
|
cultures: [],
|
|
350
527
|
resources: []
|
|
351
528
|
};
|
|
352
|
-
this.
|
|
529
|
+
this.languageService = new LanguageService(rest);
|
|
530
|
+
this.languageTextService = new LanguageTextService(rest);
|
|
353
531
|
}
|
|
354
532
|
// ========================
|
|
355
533
|
// Getter Methods
|
|
356
534
|
// ========================
|
|
357
535
|
/**
|
|
358
536
|
* Get the current list of languages from state
|
|
537
|
+
* @returns Array of LanguageDto
|
|
359
538
|
*/
|
|
360
539
|
getLanguages() {
|
|
361
540
|
return this.state.languageResponse?.items ?? [];
|
|
@@ -363,6 +542,7 @@ var LanguageManagementStateService = class {
|
|
|
363
542
|
// Note: getLanguagesTotalCount() was removed in v3.0.0
|
|
364
543
|
/**
|
|
365
544
|
* Get the current list of language texts from state
|
|
545
|
+
* @returns Array of LanguageTextDto
|
|
366
546
|
*/
|
|
367
547
|
getLanguageTexts() {
|
|
368
548
|
return this.state.languageTextsResponse?.items ?? [];
|
|
@@ -375,12 +555,14 @@ var LanguageManagementStateService = class {
|
|
|
375
555
|
}
|
|
376
556
|
/**
|
|
377
557
|
* Get the current list of cultures from state
|
|
558
|
+
* @returns Array of CultureInfoDto
|
|
378
559
|
*/
|
|
379
560
|
getCultures() {
|
|
380
561
|
return this.state.cultures ?? [];
|
|
381
562
|
}
|
|
382
563
|
/**
|
|
383
564
|
* Get the current list of resources from state
|
|
565
|
+
* @returns Array of LanguageResourceDto
|
|
384
566
|
*/
|
|
385
567
|
getResources() {
|
|
386
568
|
return this.state.resources ?? [];
|
|
@@ -389,12 +571,12 @@ var LanguageManagementStateService = class {
|
|
|
389
571
|
// Language Dispatch Methods
|
|
390
572
|
// ========================
|
|
391
573
|
/**
|
|
392
|
-
* Dispatch action to fetch languages with optional
|
|
393
|
-
* @param params - Optional query parameters for
|
|
394
|
-
* @returns Promise with the language
|
|
574
|
+
* Dispatch action to fetch languages with optional filtering
|
|
575
|
+
* @param params - Optional query parameters for filtering
|
|
576
|
+
* @returns Promise with the language list result
|
|
395
577
|
*/
|
|
396
|
-
async dispatchGetLanguages(params
|
|
397
|
-
const response = await this.
|
|
578
|
+
async dispatchGetLanguages(params) {
|
|
579
|
+
const response = await this.languageService.getList(params);
|
|
398
580
|
this.state = {
|
|
399
581
|
...this.state,
|
|
400
582
|
languageResponse: response
|
|
@@ -407,7 +589,7 @@ var LanguageManagementStateService = class {
|
|
|
407
589
|
* @returns Promise with the language
|
|
408
590
|
*/
|
|
409
591
|
async dispatchGetLanguageById(id) {
|
|
410
|
-
const language = await this.
|
|
592
|
+
const language = await this.languageService.get(id);
|
|
411
593
|
this.state = {
|
|
412
594
|
...this.state,
|
|
413
595
|
selectedItem: language
|
|
@@ -423,9 +605,9 @@ var LanguageManagementStateService = class {
|
|
|
423
605
|
async dispatchCreateUpdateLanguage(body, id) {
|
|
424
606
|
let result;
|
|
425
607
|
if (id) {
|
|
426
|
-
result = await this.
|
|
608
|
+
result = await this.languageService.update(id, body);
|
|
427
609
|
} else {
|
|
428
|
-
result = await this.
|
|
610
|
+
result = await this.languageService.create(body);
|
|
429
611
|
}
|
|
430
612
|
await this.dispatchGetLanguages();
|
|
431
613
|
return result;
|
|
@@ -433,12 +615,11 @@ var LanguageManagementStateService = class {
|
|
|
433
615
|
/**
|
|
434
616
|
* Dispatch action to delete a language
|
|
435
617
|
* @param id - The language ID to delete
|
|
436
|
-
* @returns Promise resolving when complete
|
|
618
|
+
* @returns Promise resolving when complete
|
|
437
619
|
*/
|
|
438
620
|
async dispatchDeleteLanguage(id) {
|
|
439
|
-
await this.
|
|
621
|
+
await this.languageService.delete(id);
|
|
440
622
|
await this.dispatchGetLanguages();
|
|
441
|
-
return null;
|
|
442
623
|
}
|
|
443
624
|
/**
|
|
444
625
|
* Dispatch action to set a language as the default
|
|
@@ -446,7 +627,7 @@ var LanguageManagementStateService = class {
|
|
|
446
627
|
* @returns Promise resolving when complete
|
|
447
628
|
*/
|
|
448
629
|
async dispatchSetAsDefaultLanguage(id) {
|
|
449
|
-
await this.
|
|
630
|
+
await this.languageService.setAsDefault(id);
|
|
450
631
|
await this.dispatchGetLanguages();
|
|
451
632
|
}
|
|
452
633
|
// ========================
|
|
@@ -458,7 +639,7 @@ var LanguageManagementStateService = class {
|
|
|
458
639
|
* @returns Promise with the language text response
|
|
459
640
|
*/
|
|
460
641
|
async dispatchGetLanguageTexts(params) {
|
|
461
|
-
const response = await this.
|
|
642
|
+
const response = await this.languageTextService.getList(params);
|
|
462
643
|
this.state = {
|
|
463
644
|
...this.state,
|
|
464
645
|
languageTextsResponse: response
|
|
@@ -468,11 +649,15 @@ var LanguageManagementStateService = class {
|
|
|
468
649
|
/**
|
|
469
650
|
* Dispatch action to update a language text by name
|
|
470
651
|
* @param params - Parameters including the new value
|
|
471
|
-
* @returns Promise
|
|
652
|
+
* @returns Promise resolving when complete
|
|
472
653
|
*/
|
|
473
654
|
async dispatchUpdateLanguageTextByName(params) {
|
|
474
|
-
|
|
475
|
-
|
|
655
|
+
await this.languageTextService.update(
|
|
656
|
+
params.resourceName,
|
|
657
|
+
params.cultureName,
|
|
658
|
+
params.name,
|
|
659
|
+
params.value
|
|
660
|
+
);
|
|
476
661
|
}
|
|
477
662
|
/**
|
|
478
663
|
* Dispatch action to restore a language text to its default value
|
|
@@ -480,7 +665,11 @@ var LanguageManagementStateService = class {
|
|
|
480
665
|
* @returns Promise resolving when complete
|
|
481
666
|
*/
|
|
482
667
|
async dispatchRestoreLanguageTextByName(params) {
|
|
483
|
-
await this.
|
|
668
|
+
await this.languageTextService.restoreToDefault(
|
|
669
|
+
params.resourceName,
|
|
670
|
+
params.cultureName,
|
|
671
|
+
params.name
|
|
672
|
+
);
|
|
484
673
|
}
|
|
485
674
|
// ========================
|
|
486
675
|
// Culture & Resource Dispatch Methods
|
|
@@ -490,7 +679,7 @@ var LanguageManagementStateService = class {
|
|
|
490
679
|
* @returns Promise with the list of cultures
|
|
491
680
|
*/
|
|
492
681
|
async dispatchGetLanguageCultures() {
|
|
493
|
-
const cultures = await this.
|
|
682
|
+
const cultures = await this.languageService.getCulturelist();
|
|
494
683
|
this.state = {
|
|
495
684
|
...this.state,
|
|
496
685
|
cultures
|
|
@@ -502,7 +691,7 @@ var LanguageManagementStateService = class {
|
|
|
502
691
|
* @returns Promise with the list of resources
|
|
503
692
|
*/
|
|
504
693
|
async dispatchGetLanguageResources() {
|
|
505
|
-
const resources = await this.
|
|
694
|
+
const resources = await this.languageService.getResources();
|
|
506
695
|
this.state = {
|
|
507
696
|
...this.state,
|
|
508
697
|
resources
|
|
@@ -1519,6 +1708,8 @@ export {
|
|
|
1519
1708
|
LanguageManagementExtensionsGuard,
|
|
1520
1709
|
LanguageManagementService,
|
|
1521
1710
|
LanguageManagementStateService,
|
|
1711
|
+
LanguageService,
|
|
1712
|
+
LanguageTextService,
|
|
1522
1713
|
LanguageTextsComponent,
|
|
1523
1714
|
LanguagesComponent,
|
|
1524
1715
|
configureRoutes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abpjs/language-management",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "ABP Framework language-management components for React - translated from @volo/abp.ng.language-management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"@chakra-ui/react": "^3.2.0",
|
|
27
27
|
"@emotion/react": "^11.11.0",
|
|
28
28
|
"react-icons": "^5.3.0",
|
|
29
|
-
"@abpjs/
|
|
30
|
-
"@abpjs/
|
|
31
|
-
"@abpjs/
|
|
29
|
+
"@abpjs/permission-management": "3.2.0",
|
|
30
|
+
"@abpjs/core": "3.2.0",
|
|
31
|
+
"@abpjs/theme-shared": "3.2.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@volo/abp.ng.language-management": "3.
|
|
34
|
+
"@volo/abp.ng.language-management": "3.2.0",
|
|
35
35
|
"@testing-library/jest-dom": "^6.9.1",
|
|
36
36
|
"@testing-library/react": "^14.0.0",
|
|
37
37
|
"@testing-library/user-event": "^14.6.1",
|