@kosdev-code/kos-ui-sdk 2.0.40 → 2.1.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/core/core/decorators/index.d.ts +4 -0
- package/core/core/decorators/index.d.ts.map +1 -1
- package/core/core/decorators/kos-companion.d.ts +125 -8
- package/core/core/decorators/kos-companion.d.ts.map +1 -1
- package/core/core/decorators/kos-container-aware.d.ts +465 -0
- package/core/core/decorators/kos-container-aware.d.ts.map +1 -0
- package/core/core/decorators/kos-future-aware.d.ts +150 -0
- package/core/core/decorators/kos-future-aware.d.ts.map +1 -0
- package/core/core/decorators/kos-logger-aware.d.ts +96 -0
- package/core/core/decorators/kos-logger-aware.d.ts.map +1 -0
- package/core/core/decorators/kos-trouble-aware.d.ts +71 -0
- package/core/core/decorators/kos-trouble-aware.d.ts.map +1 -0
- package/core/core/decorators/kosModel.d.ts +8 -2
- package/core/core/decorators/kosModel.d.ts.map +1 -1
- package/core/core/decorators/kosTopicHandler.d.ts.map +1 -1
- package/core/core/decorators/propKeys.d.ts +4 -0
- package/core/core/decorators/propKeys.d.ts.map +1 -1
- package/core/core/extension/extension-manager.d.ts +1 -1
- package/core/core/extension/extension-manager.d.ts.map +1 -1
- package/core/core/kosCore.d.ts.map +1 -1
- package/core/core/registration/index.d.ts +1 -0
- package/core/core/registration/index.d.ts.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.d.ts.map +1 -1
- package/core/util/container-utils.d.ts +3 -2
- package/core/util/container-utils.d.ts.map +1 -1
- package/core/util/observable-proxy-map.d.ts.map +1 -1
- package/index.cjs +79 -76
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -0
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +10060 -8172
- package/index.js.map +1 -1
- package/models/models/browser-router/browser-router-model.d.ts +80 -1
- package/models/models/browser-router/browser-router-model.d.ts.map +1 -1
- package/models/models/browser-router/types/index.d.ts +25 -1
- package/models/models/config-bean/config-bean-model-builder.d.ts +4 -2
- package/models/models/config-bean/config-bean-model-builder.d.ts.map +1 -1
- package/models/models/config-bean/config-bean-model.d.ts +117 -13
- package/models/models/config-bean/config-bean-model.d.ts.map +1 -1
- package/models/models/config-bean/config-bean-types.d.ts +6 -3
- package/models/models/config-bean/config-bean-types.d.ts.map +1 -1
- package/models/models/config-bean/types/index.d.ts +33 -0
- package/models/models/config-bean-prop/config-bean-prop-model.d.ts +112 -1
- package/models/models/config-bean-prop/config-bean-prop-model.d.ts.map +1 -1
- package/models/models/config-bean-prop/types/index.d.ts +293 -17
- package/models/models/device/device-model.d.ts +219 -9
- package/models/models/device/device-model.d.ts.map +1 -1
- package/models/models/device/device-registration.d.ts +61 -48
- package/models/models/device/device-registration.d.ts.map +1 -1
- package/models/models/device/types/index.d.ts +41 -0
- package/models/models/future/future-aware.d.ts +82 -0
- package/models/models/future/future-aware.d.ts.map +1 -1
- package/models/models/future/future-model.d.ts +34 -5
- package/models/models/future/future-model.d.ts.map +1 -1
- package/models/models/future/future-types.d.ts +186 -7
- package/models/models/future/future-types.d.ts.map +1 -1
- package/models/models/future-container/future-container-model.d.ts +2 -2
- package/models/models/index.d.ts +1 -0
- package/models/models/index.d.ts.map +1 -1
- package/models/models/key-value/index.d.ts +4 -0
- package/models/models/key-value/index.d.ts.map +1 -1
- package/models/models/key-value/key-value-model.d.ts +111 -0
- package/models/models/key-value/key-value-model.d.ts.map +1 -1
- package/models/models/key-value/services/key-value-services.d.ts +124 -2
- package/models/models/key-value/services/key-value-services.d.ts.map +1 -1
- package/models/models/key-value/types/index.d.ts +56 -0
- package/models/models/kos-expression-evaluator/index.d.ts +4 -0
- package/models/models/kos-expression-evaluator/index.d.ts.map +1 -0
- package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts +209 -0
- package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts.map +1 -0
- package/models/models/kos-expression-evaluator/services/index.d.ts +6 -0
- package/models/models/kos-expression-evaluator/services/index.d.ts.map +1 -0
- package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts +15 -0
- package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts.map +1 -0
- package/models/models/kos-expression-evaluator/types/index.d.ts +1 -0
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts +61 -14
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts.map +1 -1
- package/models/models/kos-log-manager/types/index.d.ts +187 -0
- package/models/models/kos-time/kos-time-model.d.ts +64 -0
- package/models/models/kos-time/kos-time-model.d.ts.map +1 -1
- package/models/models/kos-time/types/index.d.ts +80 -0
- package/models/models/log-block/log-block-container-model.d.ts +132 -0
- package/models/models/log-block/log-block-container-model.d.ts.map +1 -1
- package/models/models/log-block/log-block-model.d.ts +185 -0
- package/models/models/log-block/log-block-model.d.ts.map +1 -1
- package/models/models/log-block/types/index.d.ts +129 -0
- package/models/models/log-stream/index.d.ts +6 -2
- package/models/models/log-stream/index.d.ts.map +1 -1
- package/models/models/log-stream/log-stream-container-model.d.ts +62 -0
- package/models/models/log-stream/log-stream-container-model.d.ts.map +1 -1
- package/models/models/log-stream/log-stream-model.d.ts +55 -0
- package/models/models/log-stream/log-stream-model.d.ts.map +1 -1
- package/models/models/log-stream/services/log-stream-services.d.ts +2 -1
- package/models/models/log-stream/services/log-stream-services.d.ts.map +1 -1
- package/models/models/log-stream/types/index.d.ts +77 -0
- package/models/models/network-interface/index.d.ts +6 -2
- package/models/models/network-interface/index.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-container-model.d.ts +62 -0
- package/models/models/network-interface/network-interface-container-model.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-container-registration.d.ts +2 -1
- package/models/models/network-interface/network-interface-container-registration.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-model.d.ts +77 -0
- package/models/models/network-interface/network-interface-model.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-registration.d.ts +2 -1
- package/models/models/network-interface/network-interface-registration.d.ts.map +1 -1
- package/models/models/network-interface/services/network-interface-services.d.ts +54 -0
- package/models/models/network-interface/services/network-interface-services.d.ts.map +1 -1
- package/models/models/network-interface/types/index.d.ts +21 -0
- package/models/models/ota/ota-model.d.ts +82 -3
- package/models/models/ota/ota-model.d.ts.map +1 -1
- package/models/models/ota/types/index.d.ts +146 -0
- package/models/models/region-info/region-info-model.d.ts +7 -3
- package/models/models/region-info/region-info-model.d.ts.map +1 -1
- package/models/models/region-info/services/region-info-services.d.ts.map +1 -1
- package/models/models/region-info/types/index.d.ts +141 -13
- package/models/models/region-info/types/index.d.ts.map +1 -1
- package/models/models/software-info/software-info-model.d.ts +74 -2
- package/models/models/software-info/software-info-model.d.ts.map +1 -1
- package/models/models/software-info/types/index.d.ts +48 -16
- package/models/models/state-bean/state-bean-model.d.ts +86 -9
- package/models/models/state-bean/state-bean-model.d.ts.map +1 -1
- package/models/models/state-bean/types/index.d.ts +114 -6
- package/models/models/state-prop/state-prop-model.d.ts +78 -1
- package/models/models/state-prop/state-prop-model.d.ts.map +1 -1
- package/models/models/state-prop/types/index.d.ts +55 -7
- package/models/models/storage-device/storage-device-container-model.d.ts +289 -2
- package/models/models/storage-device/storage-device-container-model.d.ts.map +1 -1
- package/models/models/storage-device/storage-device-model.d.ts +84 -2
- package/models/models/storage-device/storage-device-model.d.ts.map +1 -1
- package/models/models/storage-device/types/index.d.ts +112 -0
- package/models/models/studio-properties/studio-properties-model.d.ts +75 -0
- package/models/models/studio-properties/studio-properties-model.d.ts.map +1 -1
- package/models/models/studio-properties/types/index.d.ts +29 -0
- package/models/models/translation/services/translation-services.d.ts +128 -2
- package/models/models/translation/services/translation-services.d.ts.map +1 -1
- package/models/models/translation/translation-container-model.d.ts +100 -10
- package/models/models/translation/translation-container-model.d.ts.map +1 -1
- package/models/models/translation/translation-container-registration.d.ts +2 -1
- package/models/models/translation/translation-container-registration.d.ts.map +1 -1
- package/models/models/translation/translation-context.d.ts +1 -16
- package/models/models/translation/translation-context.d.ts.map +1 -1
- package/models/models/translation/translation-model.d.ts +113 -1
- package/models/models/translation/translation-model.d.ts.map +1 -1
- package/models/models/translation/types/index.d.ts +340 -0
- package/models/models/trouble/services/trouble-services.d.ts +3 -3
- package/models/models/trouble/services/trouble-services.d.ts.map +1 -1
- package/models/models/trouble/trouble-model.d.ts +2 -1
- package/models/models/trouble/trouble-model.d.ts.map +1 -1
- package/models/models/trouble/types/index.d.ts +22 -93
- package/models/models/trouble/utils/is-trouble-aware.d.ts +2 -2
- package/models/models/trouble/utils/is-trouble-aware.d.ts.map +1 -1
- package/models/models/trouble-container/index.d.ts +4 -3
- package/models/models/trouble-container/index.d.ts.map +1 -1
- package/models/models/trouble-container/trouble-container-model.d.ts +9 -5
- package/models/models/trouble-container/trouble-container-model.d.ts.map +1 -1
- package/models/models/trouble-container/types/index.d.ts +2 -15
- package/models/utils/client.d.ts +8 -8
- package/models/utils/core-registration-manager.d.ts +1 -1
- package/models/utils/core-registration-manager.d.ts.map +1 -1
- package/models/utils/index.d.ts +0 -2
- package/models/utils/index.d.ts.map +1 -1
- package/models/utils/service.d.ts +9 -9
- package/package.json +2 -2
- package/ui/components/loading-message/loading-message-styles.d.ts +2 -2
- package/ui/components/loading-message/loading-message-styles.d.ts.map +1 -1
- package/ui/contexts/state-bean/state-bean-provider.d.ts.map +1 -1
- package/ui/hooks/state-bean/use-state-bean.d.ts +2 -2
- package/ui/hooks/state-bean/use-state-bean.d.ts.map +1 -1
- package/ui/hooks/state-bean/with-state-bean.d.ts.map +1 -1
- package/ui/hooks/translation-container/use-translation-container.d.ts +4 -33
- package/ui/hooks/translation-container/use-translation-container.d.ts.map +1 -1
- package/models/models/trouble-container/trouble-container-registration.d.ts +0 -5
- package/models/models/trouble-container/trouble-container-registration.d.ts.map +0 -1
- package/models/utils/kosmodel-compatible-future-mixin.d.ts +0 -142
- package/models/utils/kosmodel-compatible-future-mixin.d.ts.map +0 -1
- package/models/utils/kosmodel-interface-companion-mixin.d.ts +0 -83
- package/models/utils/kosmodel-interface-companion-mixin.d.ts.map +0 -1
|
@@ -1,36 +1,126 @@
|
|
|
1
1
|
import { TranslationContainerOptions } from './types';
|
|
2
2
|
import { TranslationModel } from './translation-model';
|
|
3
3
|
import { Localization } from './services';
|
|
4
|
+
import { PublicModelInterface } from '../../../core/types';
|
|
4
5
|
import { IKosDataModel, IKosIdentifiable, IKosModelContainer, IKosModelHolder, KosCreationContext, ReloadAware } from '../../../core';
|
|
5
6
|
|
|
6
7
|
export declare const MODEL_TYPE = "translation-container-model";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* TranslationContainer - Multi-namespace translation management with automatic locale switching.
|
|
10
|
+
*
|
|
11
|
+
* The TranslationContainer model serves as the central orchestrator for internationalization in KOS
|
|
12
|
+
* applications. It manages multiple translation namespaces, handles global locale switching, and provides
|
|
13
|
+
* namespace resolution with fallback chains. This container enables building sophisticated multi-language
|
|
14
|
+
* interfaces that adapt automatically to user language preferences across all application features.
|
|
15
|
+
*
|
|
16
|
+
* ## Key Features
|
|
17
|
+
* - **Multi-Namespace Management** - Organize translations by feature areas (dashboard, alerts, settings)
|
|
18
|
+
* - **Global Locale Control** - Centralized locale switching affects all contained translation models
|
|
19
|
+
* - **Automatic Discovery** - Dynamic namespace loading and registration as features request translations
|
|
20
|
+
* - **Fallback Resolution** - Sophisticated locale fallback chains for graceful degradation
|
|
21
|
+
* - **Custom Resolvers** - Flexible translation loading strategies for different deployment scenarios
|
|
22
|
+
* - **Reload Capability** - Dynamic translation updates without application restart
|
|
23
|
+
* - **Default Namespace** - Optional primary namespace for application-wide common translations
|
|
24
|
+
*
|
|
25
|
+
* ## Namespace Organization
|
|
26
|
+
* Translation namespaces organize translations by functional areas:
|
|
27
|
+
* - **Feature-Based**: dashboard, device-config, maintenance, alerts
|
|
28
|
+
* - **Component-Based**: forms, modals, navigation, status-displays
|
|
29
|
+
* - **Common**: common, shared, ui-elements for cross-cutting concerns
|
|
30
|
+
*
|
|
31
|
+
* ## Locale Management Architecture
|
|
32
|
+
* The container manages locale switching across all child translation models:
|
|
33
|
+
* 1. **Centralized Control**: Single point for locale changes
|
|
34
|
+
* 2. **Automatic Propagation**: All child models receive locale updates
|
|
35
|
+
* 3. **Reactive Loading**: Translation files loaded automatically on locale switch
|
|
36
|
+
* 4. **Fallback Coordination**: Container coordinates fallback chains across namespaces
|
|
37
|
+
*
|
|
38
|
+
* ## Common Use Cases
|
|
39
|
+
* - **Application Initialization** - Bootstrap internationalization system with locale descriptors
|
|
40
|
+
* - **User Language Switching** - Provide language selector that updates entire application
|
|
41
|
+
* - **Feature Translation Loading** - Dynamic namespace registration as features are accessed
|
|
42
|
+
* - **Multi-Tenant Systems** - Different translation sets for different deployments
|
|
43
|
+
* - **Development Workflows** - Hot-reload translations during development
|
|
44
|
+
* - **Global Device Interfaces** - Centralized management for device control applications
|
|
45
|
+
*
|
|
46
|
+
* @example Basic Usage
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const translationContainer = TranslationContainer.instance('app-translations')
|
|
49
|
+
* .options({
|
|
50
|
+
* lang: 'es',
|
|
51
|
+
* defaultNamespace: 'common',
|
|
52
|
+
* descriptor: {
|
|
53
|
+
* namespaces: {
|
|
54
|
+
* 'common': {
|
|
55
|
+
* basePath: '/assets/locales',
|
|
56
|
+
* locales: {
|
|
57
|
+
* 'en': { file: 'en/common.json', defaultLocale: 'en' },
|
|
58
|
+
* 'es': { file: 'es/common.json', defaultLocale: 'en' }
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
* }
|
|
63
|
+
* })
|
|
64
|
+
* .build();
|
|
65
|
+
*
|
|
66
|
+
* // Access translations and switch language
|
|
67
|
+
* const commonTranslations = translationContainer.getModel('common');
|
|
68
|
+
* translationContainer.currentLocale = 'fr';
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @group KOS Model
|
|
72
|
+
* @category i18n
|
|
73
|
+
* @interface
|
|
74
|
+
* @useDeclaredType
|
|
75
|
+
*
|
|
76
|
+
* @see {@link TranslationContainerOptions} - Configuration options for TranslationContainer instances
|
|
77
|
+
* @see {@link TranslationModel} - Individual translation namespace model
|
|
78
|
+
* @see {@link useKosTranslation} - React hook for accessing container translations
|
|
79
|
+
* @see {@link useKosTranslationContext} - React hook for container-level operations
|
|
80
|
+
*/
|
|
81
|
+
export type TranslationContainerModel = PublicModelInterface<TranslationContainerModelImpl>;
|
|
82
|
+
/**
|
|
83
|
+
* @ignore
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
11
86
|
export declare class TranslationContainerModelImpl implements IKosIdentifiable, IKosModelHolder<TranslationModel>, IKosDataModel, ReloadAware {
|
|
87
|
+
/** Unique identifier for the container model instance */
|
|
12
88
|
id: string;
|
|
89
|
+
/** Currently active locale for all managed translation namespaces */
|
|
13
90
|
lang: string;
|
|
91
|
+
/** Base URL for loading translation resources */
|
|
14
92
|
private rootUrl?;
|
|
93
|
+
/** Localization descriptor defining namespace configuration and locale mappings */
|
|
15
94
|
descriptor: Localization;
|
|
95
|
+
/** Optional default namespace identifier for primary application translations */
|
|
16
96
|
private _defaultNamespace?;
|
|
97
|
+
/** Path resolver function for constructing translation file URLs */
|
|
17
98
|
private resolver;
|
|
99
|
+
/** Context logger for debugging translation operations */
|
|
18
100
|
private logger;
|
|
101
|
+
/** URL for dynamically loading localization descriptors */
|
|
19
102
|
private descriptorUrl?;
|
|
103
|
+
/** Array tracking registered namespace identifiers */
|
|
20
104
|
private namespaces;
|
|
105
|
+
/** Container for managing Translation model instances */
|
|
21
106
|
private _models;
|
|
22
107
|
constructor(modelId: string, options: TranslationContainerOptions, context: KosCreationContext);
|
|
23
108
|
set currentLocale(locale: string);
|
|
24
|
-
get defaultNamespace():
|
|
25
|
-
getModel(id: string):
|
|
26
|
-
get models(): IKosModelContainer<
|
|
27
|
-
get data():
|
|
109
|
+
get defaultNamespace(): TranslationModel | undefined;
|
|
110
|
+
getModel(id: string): TranslationModel | undefined;
|
|
111
|
+
get models(): IKosModelContainer<TranslationModel>;
|
|
112
|
+
get data(): TranslationModel[];
|
|
28
113
|
reload(): Promise<void>;
|
|
29
|
-
resolveNamespace(namespace: string):
|
|
114
|
+
resolveNamespace(namespace: string): TranslationModel;
|
|
30
115
|
addModel(model: TranslationModel): void;
|
|
31
116
|
removeModel(id: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
32
120
|
init(): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
33
124
|
load(): Promise<void>;
|
|
34
125
|
}
|
|
35
|
-
export {};
|
|
36
126
|
//# sourceMappingURL=translation-container-model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation-container-model.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/translation/translation-container-model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAEf,kBAAkB,EAClB,WAAW,EACZ,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"translation-container-model.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/translation/translation-container-model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAEf,kBAAkB,EAClB,WAAW,EACZ,MAAM,eAAe,CAAC;AASvB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,UAAU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,CAAC;CAG5B"}
|
|
@@ -81,7 +81,8 @@ import { SingletonKosModelRegistrationBean } from '../../../core';
|
|
|
81
81
|
* If the model does not yet exist, it will be created passing in the provided options to initialize it.
|
|
82
82
|
*
|
|
83
83
|
* Singleton models don't require an ID as they will use the model type as their ID to guarantee uniqueness throughout the system.
|
|
84
|
-
|
|
84
|
+
* @group KOS Model
|
|
85
|
+
* @category i18n
|
|
85
86
|
* */
|
|
86
87
|
export declare const TranslationContainer: Readonly<SingletonKosModelRegistrationBean<TranslationContainerModel, TranslationContainerOptions>>;
|
|
87
88
|
//# sourceMappingURL=translation-container-registration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation-container-registration.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/translation/translation-container-registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAK/E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D
|
|
1
|
+
{"version":3,"file":"translation-container-registration.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/translation/translation-container-registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAK/E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiFK;AACL,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CACzC,iCAAiC,CAC/B,yBAAyB,EACzB,2BAA2B,CAC5B,CAcF,CAAC"}
|
|
@@ -6,22 +6,7 @@ export declare const TranslationContext: {
|
|
|
6
6
|
};
|
|
7
7
|
export declare const KosTranslations: {
|
|
8
8
|
init(options: TranslationContainerOptions): Promise<{
|
|
9
|
-
translations:
|
|
10
|
-
id: string;
|
|
11
|
-
lang: string;
|
|
12
|
-
descriptor: import('./services').Localization;
|
|
13
|
-
currentLocale: string;
|
|
14
|
-
readonly defaultNamespace: import('./translation-model').TranslationModelImpl | undefined;
|
|
15
|
-
getModel: (id: string) => import('./translation-model').TranslationModelImpl | undefined;
|
|
16
|
-
readonly models: import('../../../core').IKosModelContainer<import('./translation-model').TranslationModelImpl>;
|
|
17
|
-
readonly data: import('./translation-model').TranslationModelImpl[];
|
|
18
|
-
reload: () => Promise<void>;
|
|
19
|
-
resolveNamespace: (namespace: string) => import('./translation-model').TranslationModelImpl;
|
|
20
|
-
addModel: (model: import('./translation-model').TranslationModelImpl) => void;
|
|
21
|
-
removeModel: (id: string) => void;
|
|
22
|
-
init: () => Promise<void>;
|
|
23
|
-
load: () => Promise<void>;
|
|
24
|
-
};
|
|
9
|
+
translations: import('./translation-container-model').TranslationContainerModel;
|
|
25
10
|
}>;
|
|
26
11
|
};
|
|
27
12
|
//# sourceMappingURL=translation-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation-context.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/translation/translation-context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,kBAAkB;cACnB,MAAM,SAAS,GAAG;cAMlB,MAAM;CAIjB,CAAC;AAEF,eAAO,MAAM,eAAe;kBACN,2BAA2B
|
|
1
|
+
{"version":3,"file":"translation-context.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/translation/translation-context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,kBAAkB;cACnB,MAAM,SAAS,GAAG;cAMlB,MAAM;CAIjB,CAAC;AAEF,eAAO,MAAM,eAAe;kBACN,2BAA2B;;;CAKhD,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TranslationOptions } from './types';
|
|
2
2
|
import { LocaleDescriptor, TranslationResponse } from './services';
|
|
3
|
+
import { PublicModelInterface } from '../../../core/types';
|
|
3
4
|
import { IKosDataModel, IKosIdentifiable, KosContext, KosCreationContext } from '../../../core';
|
|
4
5
|
|
|
5
6
|
export declare const MODEL_TYPE = "translation-model";
|
|
@@ -12,30 +13,141 @@ interface ResolveTranslationsDataOptions<T = string> extends ResolveTranslationO
|
|
|
12
13
|
}
|
|
13
14
|
type ResolveTranslationsOptionsMap<T = string> = ResolveTranslationOptionsBase<T> & Record<string, string | number | boolean | undefined | null>;
|
|
14
15
|
export type ResolveTranslationOptions<T = string> = ResolveTranslationsDataOptions<T> | ResolveTranslationsOptionsMap<T>;
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Translation - Individual namespace translations with automatic locale switching and interpolation.
|
|
18
|
+
*
|
|
19
|
+
* The Translation model provides access to localized text for a specific namespace within a KOS
|
|
20
|
+
* application. It handles locale switching, fallback chains, variable interpolation, and context-aware
|
|
21
|
+
* translations for building truly international device interfaces that adapt to user language preferences
|
|
22
|
+
* automatically.
|
|
23
|
+
*
|
|
24
|
+
* ## Key Features
|
|
25
|
+
* - **Namespace Isolation** - Translations organized by functional area or feature
|
|
26
|
+
* - **Automatic Locale Switching** - React to parent container locale changes
|
|
27
|
+
* - **Fallback Chains** - Graceful degradation through locale hierarchy (pt-BR → pt → es → en)
|
|
28
|
+
* - **Variable Interpolation** - Support for both template (`{{variable}}`) and macro (`__variable__`) substitution
|
|
29
|
+
* - **Context-Aware Keys** - Conditional translations based on context (e.g., `title_edit` vs `title`)
|
|
30
|
+
* - **Real-time Updates** - Automatic UI updates when locale or translations change
|
|
31
|
+
* - **Bundle Resolution** - Custom loading strategies for different deployment scenarios
|
|
32
|
+
*
|
|
33
|
+
* ## Variable Interpolation Patterns
|
|
34
|
+
* The model supports two interpolation patterns for dynamic content:
|
|
35
|
+
* - **Template Variables** (`{{variable}}`) - Context-based substitution passed via options
|
|
36
|
+
* - **Macro Variables** (`__variable__`) - Data-based substitution from nested objects
|
|
37
|
+
*
|
|
38
|
+
* ## Fallback Resolution
|
|
39
|
+
* When translations are missing, the system follows a sophisticated fallback chain:
|
|
40
|
+
* 1. **Current locale** (e.g., `pt-BR`)
|
|
41
|
+
* 2. **Parent locale** (e.g., `pt`)
|
|
42
|
+
* 3. **Fallback locales** (configured per locale, e.g., `es`)
|
|
43
|
+
* 4. **Default locale** (typically `en`)
|
|
44
|
+
* 5. **Provided default value** or raw key
|
|
45
|
+
*
|
|
46
|
+
* ## Common Use Cases
|
|
47
|
+
* - **Feature-Specific UI** - Isolated translations for dashboards, settings, alerts
|
|
48
|
+
* - **Form Validation** - Localized error messages with variable interpolation
|
|
49
|
+
* - **Status Displays** - Dynamic content with device state and user context
|
|
50
|
+
* - **Multi-Language Interfaces** - Complete internationalization for global deployments
|
|
51
|
+
* - **Context-Aware Content** - Mode-specific text (create vs edit, online vs offline)
|
|
52
|
+
* - **Rich Text Support** - Integration with Trans component for formatted content
|
|
53
|
+
*
|
|
54
|
+
* @interface
|
|
55
|
+
* @example Basic Usage
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const statusTranslations = Translation.instance('device-status')
|
|
58
|
+
* .options({
|
|
59
|
+
* namespace: 'device-status',
|
|
60
|
+
* currentLocale: 'es',
|
|
61
|
+
* defaultLocale: 'en',
|
|
62
|
+
* descriptor: {
|
|
63
|
+
* 'es': { fallbacks: ['en'] },
|
|
64
|
+
* 'en': { fallbacks: [] }
|
|
65
|
+
* }
|
|
66
|
+
* })
|
|
67
|
+
* .build();
|
|
68
|
+
*
|
|
69
|
+
* // Resolve localized keys with fallback support
|
|
70
|
+
* const title = statusTranslations.resolveKey('title');
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @group KOS Model
|
|
74
|
+
* @category i18n
|
|
75
|
+
* @useDeclaredType
|
|
76
|
+
*
|
|
77
|
+
* @see {@link TranslationOptions} - Configuration options for Translation instances
|
|
78
|
+
* @see {@link TranslationContainerModel} - Container for managing multiple translation namespaces
|
|
79
|
+
* @see {@link useKosTranslation} - React hook for accessing translations in components
|
|
80
|
+
* @see {@link Trans} - React component for rich text translations with markup
|
|
81
|
+
*/
|
|
82
|
+
export type TranslationModel = PublicModelInterface<TranslationModelImpl>;
|
|
16
83
|
export declare const expandMacros: (text: string, data: Record<string, any>) => any;
|
|
17
84
|
export declare const replaceText: (text: string, data: Record<string, any>, context?: Record<string, any>) => any;
|
|
18
85
|
export declare class TranslationModelImpl implements IKosDataModel, IKosIdentifiable {
|
|
86
|
+
/** Unique identifier for the model instance */
|
|
19
87
|
id: string;
|
|
88
|
+
/** Namespace identifier for translation key isolation */
|
|
20
89
|
namespace: string;
|
|
90
|
+
/** Locale descriptor configuration mapping locales to fallback chains */
|
|
21
91
|
descriptor: Record<string, LocaleDescriptor>;
|
|
92
|
+
/** Default locale to use when no translation is found in fallback chain */
|
|
22
93
|
defaultLocale: string;
|
|
94
|
+
/** Currently active locale for translation resolution */
|
|
23
95
|
currentLocale: string;
|
|
96
|
+
/** Custom bundle resolver for loading translation data */
|
|
24
97
|
bundleResolver?: (namespace: string, locale: string, context?: KosContext) => Promise<TranslationResponse>;
|
|
98
|
+
/** Flattened translation data for efficient key lookup */
|
|
25
99
|
private data;
|
|
100
|
+
/** Context logger for debugging and diagnostics */
|
|
26
101
|
private logger;
|
|
102
|
+
/** Path resolver function for translation bundle location */
|
|
27
103
|
private resolver;
|
|
104
|
+
/** Reaction disposer for locale change monitoring */
|
|
28
105
|
private disposer?;
|
|
106
|
+
/** Parent translation container reference for namespace resolution */
|
|
29
107
|
private context;
|
|
108
|
+
/** Base URL for loading translation resources */
|
|
30
109
|
private rootUrl?;
|
|
31
110
|
constructor(modelId: string, options: TranslationOptions, context: KosCreationContext);
|
|
111
|
+
/**
|
|
112
|
+
* Builds the fallback chain for a given locale.
|
|
113
|
+
* @param locale The locale to get translation fallback chain for
|
|
114
|
+
* @returns Array of locales in priority order
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
32
117
|
getTranslationLocales(locale: string): string[];
|
|
118
|
+
/**
|
|
119
|
+
* Loads and merges translations for all locales in the fallback chain.
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
33
122
|
private loadTranslations;
|
|
123
|
+
/**
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
34
126
|
init(): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Checks if a translation key exists in the current namespace.
|
|
129
|
+
* @param _key Translation key, optionally with namespace prefix
|
|
130
|
+
* @returns True if the key exists
|
|
131
|
+
*/
|
|
35
132
|
exists(_key: string): any;
|
|
133
|
+
/**
|
|
134
|
+
* Resolves a translation key with optional variable interpolation.
|
|
135
|
+
* @param _key Translation key, optionally with namespace prefix
|
|
136
|
+
* @param options Options for interpolation and fallback
|
|
137
|
+
* @returns Resolved translation string or array
|
|
138
|
+
*/
|
|
36
139
|
resolveKey<T = string>(_key: string, options?: ResolveTranslationOptions<T> | string): any;
|
|
140
|
+
/**
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
37
143
|
unload(): void;
|
|
144
|
+
/**
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
38
147
|
load(): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
39
151
|
ready(): Promise<void>;
|
|
40
152
|
}
|
|
41
153
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation-model.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/translation/translation-model.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,UAAU,EAEV,kBAAkB,EACnB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"translation-model.d.ts","sourceRoot":"","sources":["../../../../../../../packages/sdk/kos-ui-sdk/src/models/models/translation/translation-model.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,UAAU,EAEV,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAOvB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,eAAO,MAAM,UAAU,sBAAsB,CAAC;AAC9C,UAAU,6BAA6B,CAAC,CAAC,GAAG,MAAM;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,CAAC,CAAC;CAClB;AAED,UAAU,8BAA8B,CAAC,CAAC,GAAG,MAAM,CACjD,SAAQ,6BAA6B,CAAC,CAAC,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;CACpC;AAED,KAAK,6BAA6B,CAAC,CAAC,GAAG,MAAM,IAC3C,6BAA6B,CAAC,CAAC,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;AACjE,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,MAAM,IAC5C,8BAA8B,CAAC,CAAC,CAAC,GACjC,6BAA6B,CAAC,CAAC,CAAC,CAAC;AACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,oBAAoB,CAAC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