@reforgium/presentia 1.4.1 → 1.4.2
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, signal, computed, inject, DestroyRef, PLATFORM_ID, afterRenderEffect, Injectable, TemplateRef, ViewContainerRef, effect, Input, Directive, input, ElementRef, Renderer2, Injector, afterNextRender, runInInjectionContext, Pipe, makeEnvironmentProviders, LOCALE_ID } from '@angular/core';
|
|
3
|
-
import { TRANSLATION, SELECTED_LANG, CHANGE_LANG, SELECTED_THEME, CHANGE_THEME, CURRENT_DEVICE, deepEqual } from '@reforgium/internal';
|
|
3
|
+
import { getChainedValue, TRANSLATION, SELECTED_LANG, CHANGE_LANG, SELECTED_THEME, CHANGE_THEME, CURRENT_DEVICE, deepEqual } from '@reforgium/internal';
|
|
4
4
|
import { BreakpointObserver } from '@angular/cdk/layout';
|
|
5
5
|
import { isPlatformBrowser, DOCUMENT } from '@angular/common';
|
|
6
6
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
@@ -470,7 +470,7 @@ class LangService {
|
|
|
470
470
|
return text.replace(/\{\{(.*?)}}/g, (_, k) => String(params[k.trim()] ?? ''));
|
|
471
471
|
}
|
|
472
472
|
getChainedValue(query = '', source = this.#cache()) {
|
|
473
|
-
if (!query || typeof source !== 'object') {
|
|
473
|
+
if (!query || !source || typeof source !== 'object') {
|
|
474
474
|
return undefined;
|
|
475
475
|
}
|
|
476
476
|
// Prefer the exact (flat) key match first, then attempt deep lookup.
|
|
@@ -478,14 +478,20 @@ class LangService {
|
|
|
478
478
|
return source[query];
|
|
479
479
|
}
|
|
480
480
|
const parts = query.split('.');
|
|
481
|
-
|
|
482
|
-
for (
|
|
483
|
-
|
|
484
|
-
|
|
481
|
+
const record = source;
|
|
482
|
+
for (let i = parts.length - 1; i > 0; i--) {
|
|
483
|
+
const flatPrefix = parts.slice(0, i).join('.');
|
|
484
|
+
if (!(flatPrefix in record)) {
|
|
485
|
+
continue;
|
|
485
486
|
}
|
|
486
|
-
|
|
487
|
+
const nestedPath = parts.slice(i).join('.');
|
|
488
|
+
const prefixed = record[flatPrefix];
|
|
489
|
+
if (!nestedPath) {
|
|
490
|
+
return prefixed;
|
|
491
|
+
}
|
|
492
|
+
return getChainedValue(prefixed, nestedPath);
|
|
487
493
|
}
|
|
488
|
-
return
|
|
494
|
+
return getChainedValue(source, query);
|
|
489
495
|
}
|
|
490
496
|
getStoredLang() {
|
|
491
497
|
const normalize = (value) => this.normalizeLang(value);
|
package/package.json
CHANGED
|
@@ -322,7 +322,7 @@ declare class LangService {
|
|
|
322
322
|
* - If `config.kgValue` is not defined, the property will return the default value 'kg'.
|
|
323
323
|
* - For other languages (e.g. `ru`, `en`) returns source language as-is.
|
|
324
324
|
*/
|
|
325
|
-
readonly currentLang: Signal<"ru" | "kg" | "ky">;
|
|
325
|
+
readonly currentLang: Signal<"ru" | "kg" | "en" | (string & {}) | "ky">;
|
|
326
326
|
/**
|
|
327
327
|
* Extracts readonly value from private property `#lang` and assigns it to `innerLangVal`.
|
|
328
328
|
* Expected that property `#lang` has `asReadonly` method that returns immutable representation.
|