valtech-components 2.0.291 → 2.0.292

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.
@@ -0,0 +1,34 @@
1
+ import { OnInit } from '@angular/core';
2
+ import { ContentService } from '../services/content.service';
3
+ import { LangService } from '../services/lang-provider/lang-provider.service';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * MultiLanguageDemoComponent - Demuestra el sistema de idiomas flexible.
7
+ *
8
+ * Este componente muestra cómo el sistema maneja múltiples idiomas,
9
+ * fallbacks automáticos y warnings por traducciones faltantes.
10
+ */
11
+ export declare class MultiLanguageDemoComponent implements OnInit {
12
+ content: ContentService;
13
+ langService: LangService;
14
+ availableLanguages: string[];
15
+ analysisResults: {
16
+ availableLanguages: string[];
17
+ missingKeys: string[];
18
+ } | null;
19
+ okButton$: import("rxjs").Observable<string>;
20
+ cancelButton$: import("rxjs").Observable<string>;
21
+ saveButton$: import("rxjs").Observable<string>;
22
+ deleteButton$: import("rxjs").Observable<string>;
23
+ nextButton$: import("rxjs").Observable<string>;
24
+ finishButton$: import("rxjs").Observable<string>;
25
+ searchPlaceholder$: import("rxjs").Observable<string>;
26
+ noDataMessage$: import("rxjs").Observable<string>;
27
+ constructor(content: ContentService, langService: LangService);
28
+ ngOnInit(): void;
29
+ switchLanguage(lang: string): void;
30
+ getLanguageName(lang: string): string;
31
+ analyzeCurrentComponent(): void;
32
+ static ɵfac: i0.ɵɵFactoryDeclaration<MultiLanguageDemoComponent, never>;
33
+ static ɵcmp: i0.ɵɵComponentDeclaration<MultiLanguageDemoComponent, "val-multi-language-demo", never, {}, {}, never, never, true, never>;
34
+ }
@@ -5,7 +5,10 @@ export interface Provider {
5
5
  /**
6
6
  * Global content that can be used across all components.
7
7
  * These are common texts like buttons, actions, states, etc.
8
- * Structure: {es: {key1: 'value1', key2: 'value2'}, en: {key1: 'value1', key2: 'value2'}}
8
+ * Structure: {es: {key1: 'value1', key2: 'value2'}, en: {key1: 'value1', key2: 'value2'}, fr: {...}}
9
+ *
10
+ * Note: You can add any language code. The system will automatically detect available languages
11
+ * and provide intelligent fallbacks with warnings for missing translations.
9
12
  */
10
13
  declare const globalContentData: LanguagesContent;
11
14
  declare const GlobalContent: TextContent;
@@ -8,6 +8,9 @@ import * as i0 from "@angular/core";
8
8
  * This service provides reactive content management with Observable-based language switching.
9
9
  * Components can subscribe to content changes and automatically update when the language changes.
10
10
  *
11
+ * The service automatically detects available languages from the content configuration
12
+ * and provides intelligent fallbacks with console warnings for missing translations.
13
+ *
11
14
  * @example Basic usage:
12
15
  * ```typescript
13
16
  * constructor(private langService: LangService) {}
@@ -27,10 +30,30 @@ import * as i0 from "@angular/core";
27
30
  */
28
31
  export declare class LangService {
29
32
  private content;
30
- private default;
33
+ private defaultLang;
34
+ private availableLanguages;
31
35
  private selectedLang;
32
36
  private config;
37
+ private warnedMissingLanguages;
33
38
  constructor(config: ValtechConfig);
39
+ /**
40
+ * Detect available languages from the content configuration.
41
+ * Scans all component content to find which languages are actually configured.
42
+ */
43
+ private detectAvailableLanguages;
44
+ /**
45
+ * Determine the best default language based on available content.
46
+ */
47
+ private determineDefaultLanguage;
48
+ /**
49
+ * Validate if a language is available in the content.
50
+ */
51
+ private validateLanguage;
52
+ /**
53
+ * Get the best available language for a component and key.
54
+ * Provides intelligent fallback with warnings.
55
+ */
56
+ private getBestAvailableContent;
34
57
  /**
35
58
  * Observable that emits the current language whenever it changes.
36
59
  * Use this to subscribe to language changes in components.
@@ -40,10 +63,20 @@ export declare class LangService {
40
63
  * Get the current language synchronously.
41
64
  */
42
65
  get currentLang(): LangOption;
66
+ /**
67
+ * Get array of available languages detected from content.
68
+ */
69
+ get availableLangs(): LangOption[];
70
+ /**
71
+ * Get the default language.
72
+ */
73
+ get defaultLanguage(): LangOption;
43
74
  /**
44
75
  * Set the current language and persist it to localStorage.
45
76
  * This will trigger updates in all reactive content subscriptions.
46
77
  *
78
+ * Validates that the language is available and warns if not.
79
+ *
47
80
  * @param lang - The language to set
48
81
  */
49
82
  setLang(lang: LangOption): void;
@@ -55,6 +88,7 @@ export declare class LangService {
55
88
  Text(className: string): LanguageText;
56
89
  /**
57
90
  * Get a single content string synchronously for the current language.
91
+ * Provides intelligent fallback with warnings for missing translations.
58
92
  *
59
93
  * @param className - The component class name
60
94
  * @param key - The text key
@@ -65,6 +99,7 @@ export declare class LangService {
65
99
  /**
66
100
  * Get a reactive Observable for a specific text key that updates when language changes.
67
101
  * This is the recommended method for components that need reactive content.
102
+ * Provides intelligent fallback with warnings for missing translations.
68
103
  *
69
104
  * @param className - The component class name
70
105
  * @param key - The text key
@@ -74,6 +109,7 @@ export declare class LangService {
74
109
  getContent(className: string, key: string, fallback?: string): Observable<string>;
75
110
  /**
76
111
  * Get reactive content for multiple keys at once.
112
+ * Provides intelligent fallback with warnings for missing translations.
77
113
  *
78
114
  * @param className - The component class name
79
115
  * @param keys - Array of text keys to retrieve
@@ -81,13 +117,39 @@ export declare class LangService {
81
117
  */
82
118
  getMultipleContent(className: string, keys: string[]): Observable<Record<string, string>>;
83
119
  /**
84
- * Check if a content key exists for a component.
120
+ * Check if a content key exists for a component in any available language.
85
121
  *
86
122
  * @param className - The component class name
87
123
  * @param key - The text key
88
124
  * @returns True if the key exists in any language
89
125
  */
90
126
  hasContent(className: string, key: string): boolean;
127
+ /**
128
+ * Check if a content key exists for a component in a specific language.
129
+ *
130
+ * @param className - The component class name
131
+ * @param key - The text key
132
+ * @param lang - The language to check (defaults to current language)
133
+ * @returns True if the key exists in the specified language
134
+ */
135
+ hasContentInLanguage(className: string, key: string, lang?: LangOption): boolean;
136
+ /**
137
+ * Get available languages for a specific component.
138
+ *
139
+ * @param className - The component class name
140
+ * @returns Array of language codes available for the component
141
+ */
142
+ getAvailableLanguagesForComponent(className: string): LangOption[];
143
+ /**
144
+ * Get missing content keys for a component in a specific language.
145
+ * Useful for identifying incomplete translations.
146
+ *
147
+ * @param className - The component class name
148
+ * @param lang - The language to check
149
+ * @param referenceLang - The reference language to compare against (defaults to default language)
150
+ * @returns Array of missing keys
151
+ */
152
+ getMissingContentKeys(className: string, lang: LangOption, referenceLang?: LangOption): string[];
91
153
  get Lang(): LangOption;
92
154
  set Lang(lang: LangOption);
93
155
  static ɵfac: i0.ɵɵFactoryDeclaration<LangService, never>;
@@ -9,7 +9,22 @@ export declare class TextContent {
9
9
  constructor(text: LanguagesContent);
10
10
  get Content(): LanguagesContent;
11
11
  }
12
- export declare enum LangOption {
13
- ES = "es",
14
- EN = "en"
15
- }
12
+ /**
13
+ * Language code type - supports any valid language code string.
14
+ * Common examples: 'es', 'en', 'fr', 'de', 'pt', 'it', 'zh', 'ja', etc.
15
+ */
16
+ export type LangOption = string;
17
+ /**
18
+ * Common language constants for convenience.
19
+ * Users can still use any language code string directly.
20
+ */
21
+ export declare const LANGUAGES: {
22
+ readonly ES: "es";
23
+ readonly EN: "en";
24
+ readonly FR: "fr";
25
+ readonly DE: "de";
26
+ readonly PT: "pt";
27
+ readonly IT: "it";
28
+ readonly ZH: "zh";
29
+ readonly JA: "ja";
30
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valtech-components",
3
- "version": "2.0.291",
3
+ "version": "2.0.292",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^18.0.0",
6
6
  "@angular/core": "^18.0.0",
package/public-api.d.ts CHANGED
@@ -82,6 +82,7 @@ export * from './lib/components/templates/simple/types';
82
82
  export * from './lib/examples/comprehensive-link-test.component';
83
83
  export * from './lib/examples/custom-content-demo.component';
84
84
  export * from './lib/examples/link-processing-example.component';
85
+ export * from './lib/examples/multi-language-demo.component';
85
86
  export * from './lib/services/content.service';
86
87
  export * from './lib/services/download.service';
87
88
  export * from './lib/services/icons.service';