@sixbell-telco/sdk 1.4.0 → 1.6.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 +76 -0
- package/README.md +410 -472
- package/_index.css +26 -0
- package/components/dropdown/dropdown-chevron/dropdown-chevron.component.d.ts +6 -1
- package/components/dropdown/dropdown-content/dropdown-content.component.d.ts +1 -1
- package/components/dropdown/dropdown-item/dropdown-item.component.d.ts +6 -1
- package/components/dropdown/dropdown-item-checkbox/dropdown-item-checkbox.component.d.ts +7 -1
- package/components/dropdown/dropdown-item-radio/dropdown-item-radio.component.d.ts +7 -1
- package/components/dropdown/dropdown-trigger/dropdown-trigger.component.d.ts +30 -0
- package/components/dropdown/public-api.d.ts +0 -1
- package/components/dropdown/src/dropdown.component.d.ts +31 -7
- package/components/forms/combobox/src/combobox.component.d.ts +24 -0
- package/components/forms/select/src/select.component.d.ts +24 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs +472 -341
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs +58 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs +52 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-logger.mjs +578 -0
- package/fesm2022/sixbell-telco-sdk-utils-logger.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-resource-loader.mjs +1222 -0
- package/fesm2022/sixbell-telco-sdk-utils-resource-loader.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +1434 -180
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +734 -182
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -1
- package/package.json +54 -46
- package/utils/logger/README.md +539 -0
- package/utils/logger/index.d.ts +5 -0
- package/utils/logger/public-api.d.ts +3 -0
- package/utils/logger/src/constants.d.ts +15 -0
- package/utils/logger/src/logger.service.d.ts +123 -0
- package/utils/logger/src/models/logger.d.ts +25 -0
- package/utils/logger/src/providers/logger.provider.d.ts +3 -0
- package/utils/resource-loader/README.md +460 -0
- package/utils/resource-loader/index.d.ts +5 -0
- package/utils/resource-loader/public-api.d.ts +1 -0
- package/utils/resource-loader/src/cache/index.d.ts +2 -0
- package/utils/resource-loader/src/cache/layers/factory.d.ts +38 -0
- package/utils/resource-loader/src/cache/layers/index.d.ts +3 -0
- package/utils/resource-loader/src/cache/layers/indexed-db-cache.d.ts +118 -0
- package/utils/resource-loader/src/cache/layers/local-storage-cache.d.ts +86 -0
- package/utils/resource-loader/src/cache/layers/memory-cache.d.ts +76 -0
- package/utils/resource-loader/src/cache/types.d.ts +107 -0
- package/utils/resource-loader/src/config/index.d.ts +1 -0
- package/utils/resource-loader/src/config/load-config.d.ts +32 -0
- package/utils/resource-loader/src/constants.d.ts +38 -0
- package/utils/resource-loader/src/http/index.d.ts +1 -0
- package/utils/resource-loader/src/http/retryable-client.d.ts +43 -0
- package/utils/resource-loader/src/index.d.ts +1 -0
- package/utils/resource-loader/src/resource-loader.d.ts +67 -0
- package/utils/resource-loader/src/types.d.ts +152 -0
- package/utils/resource-loader/src/utils/cache-validator.d.ts +72 -0
- package/utils/resource-loader/src/utils/helpers.d.ts +15 -0
- package/utils/resource-loader/src/utils/index.d.ts +2 -0
- package/utils/theme/README.md +1054 -109
- package/utils/theme/public-api.d.ts +9 -1
- package/utils/theme/src/constants.d.ts +74 -0
- package/utils/theme/src/models/theme.d.ts +288 -0
- package/utils/theme/src/providers/constants.d.ts +7 -0
- package/utils/theme/src/providers/theme.provider.d.ts +13 -0
- package/utils/theme/src/providers/theme.provider.types.d.ts +29 -0
- package/utils/theme/src/theme-assets/theme-assets.service.d.ts +214 -0
- package/utils/theme/src/theme-assets/theme-assets.types.d.ts +10 -0
- package/utils/theme/src/theme-dom/theme-dom.service.d.ts +87 -0
- package/utils/theme/src/theme-scheme/theme-scheme.service.d.ts +44 -0
- package/utils/theme/src/theme-storage/theme-storage.service.d.ts +47 -0
- package/utils/theme/src/theme.service.d.ts +40 -186
- package/utils/theme/src/utils/utils.d.ts +86 -0
- package/utils/translation/README.md +1414 -176
- package/utils/translation/public-api.d.ts +6 -0
- package/utils/translation/src/constants.d.ts +52 -0
- package/utils/translation/src/models/translation.d.ts +59 -0
- package/utils/translation/src/providers/constants.d.ts +11 -0
- package/utils/translation/src/providers/translation.provider.d.ts +73 -0
- package/utils/translation/src/providers/translation.provider.types.d.ts +26 -0
- package/utils/translation/src/translation-dom/translation-dom.service.d.ts +26 -0
- package/utils/translation/src/translation-storage/translation-storage.service.d.ts +34 -0
- package/utils/translation/src/translation.service.d.ts +19 -166
- package/components/dropdown/src/services/dropdown.service.d.ts +0 -22
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export * from './src/translation.service';
|
|
2
|
+
export type { LanguageDefinition, TranslationConfig, TranslationResourceLoaderConfig, TranslationStateConfig } from './src/models/translation';
|
|
3
|
+
export { DEFAULT_BASE_LANGUAGE, DEFAULT_LANGUAGES_LIST, DEFAULT_LANGUAGE_CODES, LANGUAGE_ATTRIBUTE_NAME, TRANSLATION_CONFIG_TOKEN, TRANSLATION_STORAGE_LANGUAGE_KEY, TRANSLATION_STORAGE_NAMESPACE, } from './src/constants';
|
|
4
|
+
export { provideRuntimeTranslation, provideTranslation } from './src/providers/translation.provider';
|
|
5
|
+
export type { RuntimeTranslationProviderOptions } from './src/providers/translation.provider.types';
|
|
6
|
+
export { TranslationDomService } from './src/translation-dom/translation-dom.service';
|
|
7
|
+
export { TranslationStorageService } from './src/translation-storage/translation-storage.service';
|
|
2
8
|
export * from '@ngx-translate/core';
|
|
3
9
|
export * from '@ngx-translate/http-loader';
|
|
4
10
|
export * from 'ngx-translate-multi-http-loader';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation Constants and Injection Tokens
|
|
3
|
+
* Centralized configuration values and DI tokens following Single Responsibility Principle
|
|
4
|
+
*/
|
|
5
|
+
import { InjectionToken } from '@angular/core';
|
|
6
|
+
import { ResourceLoaderRequestOptions } from '@sixbell-telco/sdk/utils/resource-loader';
|
|
7
|
+
import { LanguageDefinition } from './models/translation';
|
|
8
|
+
/**
|
|
9
|
+
* Default base language - always available unless explicitly excluded
|
|
10
|
+
* This is the foundational language that comes with the SDK
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_BASE_LANGUAGE: "en";
|
|
13
|
+
/**
|
|
14
|
+
* List of default languages available out of the box
|
|
15
|
+
*/
|
|
16
|
+
export declare const DEFAULT_LANGUAGES_LIST: readonly ["en", "es", "pt"];
|
|
17
|
+
/**
|
|
18
|
+
* Type-safe default language codes for IDE IntelliSense
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEFAULT_LANGUAGE_CODES: readonly ["en", "es", "pt"];
|
|
21
|
+
/**
|
|
22
|
+
* Type representing valid default language codes
|
|
23
|
+
*/
|
|
24
|
+
export type DefaultLanguageCode = (typeof DEFAULT_LANGUAGE_CODES)[number];
|
|
25
|
+
/**
|
|
26
|
+
* LocalStorage namespace to prevent collisions with other apps
|
|
27
|
+
*/
|
|
28
|
+
export declare const TRANSLATION_STORAGE_NAMESPACE: "translation:";
|
|
29
|
+
/**
|
|
30
|
+
* LocalStorage key for persisting selected language
|
|
31
|
+
*/
|
|
32
|
+
export declare const TRANSLATION_STORAGE_LANGUAGE_KEY: "selectedLanguage";
|
|
33
|
+
/**
|
|
34
|
+
* Default translation file paths
|
|
35
|
+
*/
|
|
36
|
+
export declare const DEFAULT_TRANSLATION_PATHS: readonly ["/assets/i18n/"];
|
|
37
|
+
/**
|
|
38
|
+
* HTML attribute name for setting the active language on document element
|
|
39
|
+
*/
|
|
40
|
+
export declare const LANGUAGE_ATTRIBUTE_NAME: "lang";
|
|
41
|
+
/**
|
|
42
|
+
* Injection token for translation configuration
|
|
43
|
+
* Used to provide static translation configuration at bootstrap
|
|
44
|
+
*/
|
|
45
|
+
export declare const TRANSLATION_CONFIG_TOKEN: InjectionToken<unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* Translation-specific IndexedDB database name for resource caching
|
|
48
|
+
*/
|
|
49
|
+
export declare const TRANSLATION_INDEXED_DB_NAME: "sixbell-translation";
|
|
50
|
+
export declare const DEFAULT_LANGUAGES: readonly LanguageDefinition[];
|
|
51
|
+
export declare const DEFAULT_LANGUAGE_CODE: "en";
|
|
52
|
+
export declare const TRANSLATION_RESOURCE_LOADER_DEFAULTS: ResourceLoaderRequestOptions<Record<string, unknown>>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation Models and Types
|
|
3
|
+
* Core types and interfaces for the translation system
|
|
4
|
+
*/
|
|
5
|
+
import { ResourceLoaderRequestOptions } from '@sixbell-telco/sdk/utils/resource-loader';
|
|
6
|
+
import { DEFAULT_LANGUAGE_CODES } from '../constants';
|
|
7
|
+
/**
|
|
8
|
+
* Language definition interface
|
|
9
|
+
* Represents a language with its code and display name
|
|
10
|
+
*/
|
|
11
|
+
export interface LanguageDefinition {
|
|
12
|
+
/** Language code (ISO 639-1 format recommended) */
|
|
13
|
+
code: string;
|
|
14
|
+
/** Display name for the language */
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Main translation configuration interface
|
|
19
|
+
*/
|
|
20
|
+
export interface TranslationConfig {
|
|
21
|
+
/**
|
|
22
|
+
* Additional languages to make available beyond the default base languages (en, es, pt)
|
|
23
|
+
* When you add languages here, they become available in defaultLang and excludeLanguages
|
|
24
|
+
* @example [{ code: 'de', name: 'Deutsch' }, { code: 'fr', name: 'Français' }]
|
|
25
|
+
*/
|
|
26
|
+
additionalLanguages?: readonly LanguageDefinition[];
|
|
27
|
+
/**
|
|
28
|
+
* Languages to exclude from the available set
|
|
29
|
+
* IntelliSense includes: base languages (en, es, pt) + any additionalLanguages you specified above
|
|
30
|
+
* @example ['pt'] to exclude Portuguese
|
|
31
|
+
*/
|
|
32
|
+
excludeLanguages?: readonly string[];
|
|
33
|
+
/**
|
|
34
|
+
* Default language code
|
|
35
|
+
* IntelliSense includes: base languages (en, es, pt) + any additionalLanguages you specified above
|
|
36
|
+
* @example 'en'
|
|
37
|
+
*/
|
|
38
|
+
defaultLang?: string;
|
|
39
|
+
/** Translation file paths */
|
|
40
|
+
translationPaths?: string[];
|
|
41
|
+
/** Optional resilient resource loader configuration */
|
|
42
|
+
resourceLoader?: TranslationResourceLoaderConfig;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Resource loader configuration for translation files
|
|
46
|
+
*/
|
|
47
|
+
export interface TranslationResourceLoaderConfig {
|
|
48
|
+
loaderOptions?: ResourceLoaderRequestOptions<Record<string, unknown>>;
|
|
49
|
+
suffix?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Internal state configuration for translation service
|
|
53
|
+
* Represents the resolved configuration
|
|
54
|
+
*/
|
|
55
|
+
export interface TranslationStateConfig {
|
|
56
|
+
availableLanguages: LanguageDefinition[];
|
|
57
|
+
defaultLanguage: string;
|
|
58
|
+
}
|
|
59
|
+
export type DefaultLanguageCode = (typeof DEFAULT_LANGUAGE_CODES)[number];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ResourceLoaderRequestOptions } from '@sixbell-telco/sdk/utils/resource-loader';
|
|
2
|
+
import { TranslationConfig } from '../models/translation';
|
|
3
|
+
/**
|
|
4
|
+
* Default resource loader options for runtime translation config files
|
|
5
|
+
* Matches theme's resilient loading pattern
|
|
6
|
+
*/
|
|
7
|
+
export declare const RUNTIME_TRANSLATION_LOADER_DEFAULTS: ResourceLoaderRequestOptions<TranslationConfig>;
|
|
8
|
+
/**
|
|
9
|
+
* Fallback translation config when file loading fails
|
|
10
|
+
*/
|
|
11
|
+
export declare const FALLBACK_RUNTIME_TRANSLATION_CONFIG: TranslationConfig;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { EnvironmentProviders, Injector } from '@angular/core';
|
|
2
|
+
import { TranslateLoader } from '@ngx-translate/core';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { TranslationConfig } from '../models/translation';
|
|
5
|
+
import { RuntimeTranslationProviderOptions } from './translation.provider.types';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
/**
|
|
8
|
+
* Custom TranslateLoader that defers injection of TranslationService.
|
|
9
|
+
*
|
|
10
|
+
* This loader is instantiated by ngx-translate when first needed.
|
|
11
|
+
* By deferring the inject() call until getTranslation is called,
|
|
12
|
+
* we avoid circular dependency issues during DI setup.
|
|
13
|
+
*
|
|
14
|
+
* Key: DO NOT use providedIn: 'root' - let ngx-translate manage the lifecycle.
|
|
15
|
+
*/
|
|
16
|
+
export declare class RuntimeTranslationCustomLoader implements TranslateLoader {
|
|
17
|
+
private injector;
|
|
18
|
+
constructor(injector: Injector);
|
|
19
|
+
getTranslation(lang: string): Observable<Record<string, unknown>>;
|
|
20
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RuntimeTranslationCustomLoader, never>;
|
|
21
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<RuntimeTranslationCustomLoader>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use `provideRuntimeTranslation()` instead.
|
|
25
|
+
*
|
|
26
|
+
* Provide the Translation service with static configuration.
|
|
27
|
+
* This provider is completely standalone and does NOT include ngx-translate setup.
|
|
28
|
+
* It just provides the configuration token for the service to use.
|
|
29
|
+
*
|
|
30
|
+
* Configuration is baked into the app at build time. For dynamic configuration,
|
|
31
|
+
* use `provideRuntimeTranslation()` to load from a JSON file.
|
|
32
|
+
*
|
|
33
|
+
* @param config - Configuration for languages and paths (optional)
|
|
34
|
+
* @returns Environment providers for bootstrapping
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // DEPRECATED: Static config - do not use in new code
|
|
39
|
+
* bootstrapApplication(AppComponent, [
|
|
40
|
+
* provideTranslation({
|
|
41
|
+
* defaultLang: 'es',
|
|
42
|
+
* translationPaths: ['/assets/i18n/'],
|
|
43
|
+
* }),
|
|
44
|
+
* ]);
|
|
45
|
+
*
|
|
46
|
+
* // RECOMMENDED: Use runtime config instead
|
|
47
|
+
* bootstrapApplication(AppComponent, [
|
|
48
|
+
* provideRuntimeTranslation('/assets/config/translation-config.json'),
|
|
49
|
+
* ]);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function provideTranslation(config?: TranslationConfig): EnvironmentProviders;
|
|
53
|
+
/**
|
|
54
|
+
* Provide Translation service with configuration loaded from a JSON file at runtime (like themes).
|
|
55
|
+
*
|
|
56
|
+
* This is the ONLY provider that sets up ngx-translate. It:
|
|
57
|
+
* - Loads translation configuration from a JSON file
|
|
58
|
+
* - Sets up ngx-translate with custom loader that loads from multiple paths
|
|
59
|
+
* - Supports hot-reload on navigation
|
|
60
|
+
* - Supports offline scenarios with caching
|
|
61
|
+
*
|
|
62
|
+
* @param configPath - Path to translation configuration JSON file
|
|
63
|
+
* @param options - Optional loader configuration
|
|
64
|
+
* @returns Environment providers
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* bootstrapApplication(AppComponent, [
|
|
69
|
+
* provideRuntimeTranslation('/assets/translation/translation-config.json')
|
|
70
|
+
* ]);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function provideRuntimeTranslation(configPath: string, options?: RuntimeTranslationProviderOptions): EnvironmentProviders;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ResourceLoader, ResourceLoaderRequestOptions } from '@sixbell-telco/sdk/utils/resource-loader';
|
|
2
|
+
import { TranslationConfig } from '../models/translation';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the runtime translation provider.
|
|
5
|
+
*
|
|
6
|
+
* @property loader - Custom loader instance (optional; uses default if not provided)
|
|
7
|
+
* @property loaderOptions - Loader configuration options (cache TTL, retries, storage, etc.)
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Default mode: Always fetch fresh translations with fallback to cache
|
|
12
|
+
* provideRuntimeTranslation('/assets/config/translation-config.json')
|
|
13
|
+
*
|
|
14
|
+
* // Custom caching mode
|
|
15
|
+
* provideRuntimeTranslation('/assets/config/translation-config.json', {
|
|
16
|
+
* loaderOptions: {
|
|
17
|
+
* freshOnNavigation: false,
|
|
18
|
+
* retries: 3,
|
|
19
|
+
* },
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export interface RuntimeTranslationProviderOptions {
|
|
24
|
+
loader?: ResourceLoader;
|
|
25
|
+
loaderOptions?: ResourceLoaderRequestOptions<TranslationConfig>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RendererFactory2 } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Service responsible for DOM manipulation related to language/localization
|
|
5
|
+
* Decouples DOM operations from business logic
|
|
6
|
+
*/
|
|
7
|
+
export declare class TranslationDomService {
|
|
8
|
+
private readonly rendererFactory;
|
|
9
|
+
private readonly document;
|
|
10
|
+
private readonly renderer;
|
|
11
|
+
constructor(rendererFactory: RendererFactory2, document: Document);
|
|
12
|
+
/**
|
|
13
|
+
* Sets the language on the document element
|
|
14
|
+
* Updates the HTML lang attribute for accessibility and SEO
|
|
15
|
+
* @param language - Language code (e.g., 'en', 'es', 'pt')
|
|
16
|
+
*/
|
|
17
|
+
setDocumentLanguage(language: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the current language from the document element
|
|
20
|
+
* Reads the HTML lang attribute
|
|
21
|
+
* @returns Current language code or empty string if not set
|
|
22
|
+
*/
|
|
23
|
+
getDocumentLanguage(): string;
|
|
24
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TranslationDomService, never>;
|
|
25
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TranslationDomService>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
/**
|
|
3
|
+
* Service for managing language preferences in local storage
|
|
4
|
+
* Provides safe access to localStorage with error handling
|
|
5
|
+
* Works gracefully in non-browser environments (SSR)
|
|
6
|
+
*/
|
|
7
|
+
export declare class TranslationStorageService {
|
|
8
|
+
private readonly logger;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the saved language preference from localStorage
|
|
11
|
+
* Returns null if no saved preference or storage unavailable
|
|
12
|
+
* @returns Saved language code or null
|
|
13
|
+
*/
|
|
14
|
+
getSavedLanguage(): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Saves the current language preference to localStorage
|
|
17
|
+
* Fails silently if storage is unavailable
|
|
18
|
+
* @param language - Language code to save
|
|
19
|
+
*/
|
|
20
|
+
saveLanguage(language: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Clears all saved language preferences from localStorage
|
|
23
|
+
* Useful for resetting to defaults
|
|
24
|
+
*/
|
|
25
|
+
clear(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Constructs a namespaced storage key to avoid collisions
|
|
28
|
+
* @param key - The base storage key
|
|
29
|
+
* @returns Namespaced key (e.g., "translation:selectedLanguage")
|
|
30
|
+
*/
|
|
31
|
+
private getStorageKey;
|
|
32
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TranslationStorageService, never>;
|
|
33
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TranslationStorageService>;
|
|
34
|
+
}
|
|
@@ -1,197 +1,50 @@
|
|
|
1
|
-
import { HttpBackend, HttpClient } from '@angular/common/http';
|
|
2
|
-
import { EnvironmentProviders, InjectionToken, Provider } from '@angular/core';
|
|
3
1
|
import { MissingTranslationHandler, MissingTranslationHandlerParams } from '@ngx-translate/core';
|
|
4
|
-
import {
|
|
5
|
-
import { MultiTranslateHttpLoader } from 'ngx-translate-multi-http-loader';
|
|
2
|
+
import { LanguageDefinition, TranslationConfig } from './models/translation';
|
|
6
3
|
import * as i0 from "@angular/core";
|
|
7
|
-
/**
|
|
8
|
-
* Language definition interface
|
|
9
|
-
*/
|
|
10
|
-
export interface LanguageDefinition {
|
|
11
|
-
/** Language code (ISO 639-1 format recommended) */
|
|
12
|
-
code: string;
|
|
13
|
-
/** Display name for the language */
|
|
14
|
-
name: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Helper function to create a language definition with full type safety and IntelliSense
|
|
18
|
-
*/
|
|
19
4
|
export declare function createLanguage(config: LanguageDefinition): LanguageDefinition;
|
|
20
|
-
export declare
|
|
21
|
-
export declare const DEFAULT_LANGUAGE_CODE = "en";
|
|
22
|
-
export declare const DEFAULT_LANGUAGE_CODES: readonly ["en", "es", "pt"];
|
|
23
|
-
export type DefaultLanguageCode = (typeof DEFAULT_LANGUAGE_CODES)[number];
|
|
24
|
-
type ExtractLanguageCode<T> = T extends readonly (infer U)[] ? (U extends LanguageDefinition ? U['code'] : never) : never;
|
|
5
|
+
export declare function extendDefaultLanguages(additionalLanguages: LanguageDefinition[]): LanguageDefinition[];
|
|
25
6
|
export declare class PlaceholderMissingTranslationHandler implements MissingTranslationHandler {
|
|
26
7
|
handle(params: MissingTranslationHandlerParams): string;
|
|
27
8
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Main translation configuration interface
|
|
30
|
-
*/
|
|
31
|
-
export interface TranslationConfig {
|
|
32
|
-
/**
|
|
33
|
-
* Additional languages to make available beyond the default base languages (en, es, pt)
|
|
34
|
-
* When you add languages here, they become available in defaultLang and excludeLanguages
|
|
35
|
-
* @example [{ code: 'de', name: 'Deutsch' }, { code: 'fr', name: 'Français' }]
|
|
36
|
-
*/
|
|
37
|
-
additionalLanguages?: readonly LanguageDefinition[];
|
|
38
|
-
/**
|
|
39
|
-
* Languages to exclude from the available set
|
|
40
|
-
* IntelliSense includes: base languages (en, es, pt) + any additionalLanguages you specified above
|
|
41
|
-
* @example ['pt'] to exclude Portuguese
|
|
42
|
-
*/
|
|
43
|
-
excludeLanguages?: readonly string[];
|
|
44
|
-
/**
|
|
45
|
-
* Default language code
|
|
46
|
-
* IntelliSense includes: base languages (en, es, pt) + any additionalLanguages you specified above
|
|
47
|
-
* @example 'en'
|
|
48
|
-
*/
|
|
49
|
-
defaultLang?: string;
|
|
50
|
-
/** Translation file paths */
|
|
51
|
-
translationPaths?: string[];
|
|
52
|
-
}
|
|
53
|
-
export declare const TRANSLATION_CONFIG_TOKEN: InjectionToken<TranslationConfig>;
|
|
54
|
-
/**
|
|
55
|
-
* Factory function to create HTTP loader for translations with custom paths
|
|
56
|
-
*/
|
|
57
|
-
export declare function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader;
|
|
58
|
-
/**
|
|
59
|
-
* Factory function to create multi-path HTTP loader for translations
|
|
60
|
-
*/
|
|
61
|
-
export declare function MultiPathHttpLoaderFactory(httpBackend: HttpBackend, paths: string[]): MultiTranslateHttpLoader;
|
|
62
|
-
/**
|
|
63
|
-
* Utility function to extend default languages with additional ones
|
|
64
|
-
*/
|
|
65
|
-
export declare function extendDefaultLanguages(additionalLanguages: LanguageDefinition[]): LanguageDefinition[];
|
|
66
9
|
export declare class TranslationService {
|
|
67
10
|
private readonly translationConfig?;
|
|
68
11
|
private readonly translate;
|
|
69
|
-
private readonly
|
|
12
|
+
private readonly storageService;
|
|
13
|
+
private readonly domService;
|
|
14
|
+
private readonly logger;
|
|
70
15
|
private initialized;
|
|
16
|
+
private currentTranslationPaths;
|
|
17
|
+
private translationResourceLoader;
|
|
18
|
+
private hasAppliedInitialLanguage;
|
|
71
19
|
private config;
|
|
20
|
+
readonly currentLanguage: import("@angular/core").WritableSignal<string>;
|
|
21
|
+
readonly onLanguageChange$: import("rxjs").Observable<import("@ngx-translate/core").LangChangeEvent>;
|
|
22
|
+
readonly onLanguageChange: import("@angular/core").WritableSignal<number>;
|
|
23
|
+
readonly ready: import("@angular/core").WritableSignal<boolean>;
|
|
72
24
|
constructor(translationConfig?: TranslationConfig | undefined);
|
|
73
|
-
/**
|
|
74
|
-
* Configure and initialize the translation service (used by provider)
|
|
75
|
-
*/
|
|
76
25
|
configure(config?: TranslationConfig): void;
|
|
77
|
-
|
|
78
|
-
* Initialize translation from localStorage and apply it immediately
|
|
79
|
-
*/
|
|
26
|
+
setRuntimeConfig(config: TranslationConfig): Promise<void>;
|
|
80
27
|
private initializeFromStorage;
|
|
81
|
-
/**
|
|
82
|
-
* Apply the current language to the translate service and document
|
|
83
|
-
*/
|
|
84
28
|
private applyLanguage;
|
|
85
|
-
/**
|
|
86
|
-
* Set the current language and persist to localStorage
|
|
87
|
-
*/
|
|
88
29
|
setLanguage(lang: string): void;
|
|
89
|
-
/**
|
|
90
|
-
* Get the current language from localStorage or default
|
|
91
|
-
*/
|
|
92
30
|
getCurrentLanguage(): string;
|
|
93
|
-
/**
|
|
94
|
-
* Get the current HTML lang attribute
|
|
95
|
-
*/
|
|
96
|
-
getCurrentHtmlLanguage(): string;
|
|
97
|
-
/**
|
|
98
|
-
* Get available languages
|
|
99
|
-
*/
|
|
100
31
|
getAvailableLanguages(): string[];
|
|
101
|
-
/**
|
|
102
|
-
* Get default language
|
|
103
|
-
*/
|
|
104
32
|
getDefaultLanguage(): string;
|
|
105
|
-
/**
|
|
106
|
-
* Instantly translate a key with optional parameters
|
|
107
|
-
*/
|
|
108
33
|
instant(key: string, params?: object | undefined): string;
|
|
109
|
-
/**
|
|
110
|
-
* Get observable translation for a key
|
|
111
|
-
*/
|
|
112
34
|
get(key: string, params?: object | undefined): import("rxjs").Observable<any>;
|
|
113
|
-
/**
|
|
114
|
-
* Get stream of translations for a key
|
|
115
|
-
*/
|
|
116
35
|
stream(key: string, params?: object | undefined): import("rxjs").Observable<any>;
|
|
117
|
-
/**
|
|
118
|
-
* Get available languages configuration
|
|
119
|
-
*/
|
|
120
36
|
getAvailableLanguagesConfig(): LanguageDefinition[];
|
|
121
|
-
/**
|
|
122
|
-
* Get available language codes
|
|
123
|
-
*/
|
|
124
37
|
getAvailableLanguageCodes(): string[];
|
|
125
|
-
/**
|
|
126
|
-
* Get language configuration by code
|
|
127
|
-
*/
|
|
128
38
|
getLanguageByCode(code: string): LanguageDefinition | undefined;
|
|
129
|
-
/**
|
|
130
|
-
* Get language display name by code
|
|
131
|
-
*/
|
|
132
39
|
getLanguageDisplayName(code: string): string;
|
|
133
|
-
/**
|
|
134
|
-
* Get localized language name by code using translations
|
|
135
|
-
* This automatically returns the localized name based on the current language
|
|
136
|
-
*/
|
|
137
40
|
getLocalizedLanguageName(code: string): string;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
*/
|
|
41
|
+
isReady(): import("@angular/core").Signal<boolean>;
|
|
42
|
+
waitForTranslations(timeoutMs?: number): Promise<void>;
|
|
141
43
|
init(): void;
|
|
44
|
+
private getOrCreateResourceLoader;
|
|
45
|
+
private buildResourceOptions;
|
|
46
|
+
private createTranslateLoader;
|
|
47
|
+
private deepMergeTranslations;
|
|
142
48
|
static ɵfac: i0.ɵɵFactoryDeclaration<TranslationService, [{ optional: true; }]>;
|
|
143
49
|
static ɵprov: i0.ɵɵInjectableDeclaration<TranslationService>;
|
|
144
50
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Provider function for translation configuration in Angular applications
|
|
147
|
-
* This provides the translation configuration through dependency injection
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```typescript
|
|
151
|
-
* // Basic usage - only default languages available (en, es, pt)
|
|
152
|
-
* provideTranslation({
|
|
153
|
-
* defaultLang: 'es' // IntelliSense shows: 'en', 'es', 'pt'
|
|
154
|
-
* }),
|
|
155
|
-
*
|
|
156
|
-
* // With additional languages - IntelliSense includes base + additional languages
|
|
157
|
-
* provideTranslation({
|
|
158
|
-
* additionalLanguages: [
|
|
159
|
-
* { code: 'de', name: 'Deutsch' },
|
|
160
|
-
* { code: 'fr', name: 'Français' }
|
|
161
|
-
* ] as const,
|
|
162
|
-
* defaultLang: 'de', // IntelliSense shows: 'en', 'es', 'pt', 'de', 'fr'
|
|
163
|
-
* excludeLanguages: ['pt'] as const // IntelliSense shows: 'en', 'es', 'pt', 'de', 'fr'
|
|
164
|
-
* })
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
export declare function provideTranslation(): (Provider | EnvironmentProviders)[];
|
|
168
|
-
export declare function provideTranslation(config: {
|
|
169
|
-
/**
|
|
170
|
-
* Default language code (from base languages: en, es, pt)
|
|
171
|
-
*/
|
|
172
|
-
defaultLang?: DefaultLanguageCode;
|
|
173
|
-
/**
|
|
174
|
-
* Languages to exclude from the default base languages (en, es, pt)
|
|
175
|
-
*/
|
|
176
|
-
excludeLanguages?: readonly DefaultLanguageCode[];
|
|
177
|
-
/** Translation file paths */
|
|
178
|
-
translationPaths?: string[];
|
|
179
|
-
additionalLanguages?: never;
|
|
180
|
-
}): (Provider | EnvironmentProviders)[];
|
|
181
|
-
export declare function provideTranslation<const T extends readonly LanguageDefinition[]>(config: {
|
|
182
|
-
/**
|
|
183
|
-
* Additional languages to make available beyond the default base languages (en, es, pt)
|
|
184
|
-
*/
|
|
185
|
-
additionalLanguages: T;
|
|
186
|
-
/**
|
|
187
|
-
* Default language code (includes both base and additional languages)
|
|
188
|
-
*/
|
|
189
|
-
defaultLang?: DefaultLanguageCode | ExtractLanguageCode<T>;
|
|
190
|
-
/**
|
|
191
|
-
* Languages to exclude from the available set (includes both base and additional languages)
|
|
192
|
-
*/
|
|
193
|
-
excludeLanguages?: readonly (DefaultLanguageCode | ExtractLanguageCode<T>)[];
|
|
194
|
-
/** Translation file paths */
|
|
195
|
-
translationPaths?: string[];
|
|
196
|
-
}): (Provider | EnvironmentProviders)[];
|
|
197
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
/**
|
|
3
|
-
* Service to manage dropdown state
|
|
4
|
-
* Used by dropdown components to communicate state to chevron
|
|
5
|
-
*/
|
|
6
|
-
export declare class DropdownService {
|
|
7
|
-
private readonly _isOpen;
|
|
8
|
-
/**
|
|
9
|
-
* Current open state of the dropdown
|
|
10
|
-
*/
|
|
11
|
-
readonly isOpen: import("@angular/core").Signal<boolean>;
|
|
12
|
-
/**
|
|
13
|
-
* Set the open state
|
|
14
|
-
*/
|
|
15
|
-
setOpen(open: boolean): void;
|
|
16
|
-
/**
|
|
17
|
-
* Toggle the open state
|
|
18
|
-
*/
|
|
19
|
-
toggle(): void;
|
|
20
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<DropdownService, never>;
|
|
21
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<DropdownService>;
|
|
22
|
-
}
|