@tstdl/base 0.85.9 → 0.85.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/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import type { PickBy, ReactiveValue, ReplaceKey } from '../types.js';
|
|
|
4
4
|
import type { LocalizableText } from './localizable-text.model.js';
|
|
5
5
|
import { LocalizationService } from './localization.service.js';
|
|
6
6
|
export type DynamicText = ReactiveValue<LocalizableText>;
|
|
7
|
+
export declare const missingLocalizationKeyText = "[MISSING LOCALIZATION KEY]";
|
|
7
8
|
export declare function resolveDynamicText(text: DynamicText, localizationService?: LocalizationService): Signal<string>;
|
|
8
9
|
export declare function resolveDynamicText$(text: DynamicText, localizationService?: LocalizationService): Observable<string>;
|
|
9
10
|
export declare function resolveDynamicTexts(texts: DynamicText[], localizationService?: LocalizationService): Signal<string[]>;
|
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var dynamic_text_model_exports = {};
|
|
20
20
|
__export(dynamic_text_model_exports, {
|
|
21
|
+
missingLocalizationKeyText: () => missingLocalizationKeyText,
|
|
21
22
|
resolveDynamicText: () => resolveDynamicText,
|
|
22
23
|
resolveDynamicText$: () => resolveDynamicText$,
|
|
23
24
|
resolveDynamicTexts: () => resolveDynamicTexts,
|
|
@@ -32,12 +33,16 @@ var import_rxjs = require("rxjs");
|
|
|
32
33
|
var import_container = require("../container/index.js");
|
|
33
34
|
var import_api = require("../signals/api.js");
|
|
34
35
|
var import_switch_map = require("../signals/switch-map.js");
|
|
36
|
+
var import_type_guards = require("../utils/type-guards.js");
|
|
35
37
|
var import_localization_service = require("./localization.service.js");
|
|
36
38
|
const missingLocalizationKeyText = "[MISSING LOCALIZATION KEY]";
|
|
37
39
|
function resolveDynamicText(text, localizationService) {
|
|
38
40
|
const resolvedLocalizationService = localizationService ?? import_container.container.resolve(import_localization_service.LocalizationService);
|
|
39
|
-
const
|
|
40
|
-
return (0, import_switch_map.switchMap)(() =>
|
|
41
|
+
const localizableTextSignal = (0, import_api.isSignal)(text) ? text : (0, import_rxjs.isObservable)(text) ? (0, import_api.toSignal)(text, { initialValue: missingLocalizationKeyText }) : (0, import_api.computed)(() => text);
|
|
42
|
+
return (0, import_switch_map.switchMap)(() => {
|
|
43
|
+
const localizableText = localizableTextSignal();
|
|
44
|
+
return (0, import_type_guards.isString)(localizableText) ? (0, import_api.computed)(() => localizableText) : resolvedLocalizationService.localize(localizableText);
|
|
45
|
+
});
|
|
41
46
|
}
|
|
42
47
|
function resolveDynamicText$(text, localizationService) {
|
|
43
48
|
return (0, import_api.toObservable)(resolveDynamicText(text, localizationService));
|