common-header-lib 0.0.16 → 0.0.17

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.
@@ -40,5 +40,50 @@ export declare class CommonHeaderLibModule {
40
40
  static ɵmod: i0.ɵɵNgModuleDeclaration<CommonHeaderLibModule, [typeof i1.CommonHeaderLibComponent, typeof i2.SliceToTwoPipe, typeof i3.customDateFormatPipe, typeof i4.DateDiffPipe, typeof i5.UserSidebarComponent, typeof i6.SidePopupComponent, typeof i7.NgTranslationComponent, typeof i8.UserMailboxComponent, typeof i9.NotificationSidebarComponent, typeof i10.GeneralConfigurationComponent, typeof i11.TimezoneConfigurationComponent, typeof i12.LandingpgConfigComponent, typeof i13.NoServiceMyAccessPgComponent, typeof i14.GridPaginationComponent, typeof i15.ConfirmDialogComponent, typeof i16.ViewpasswordPopupComponent], [typeof i17.CommonModule, typeof i18.HttpClientModule, typeof i19.ReactiveFormsModule, typeof i20.InputTextModule, typeof i21.DropdownModule, typeof i22.OverlayPanelModule, typeof i23.BadgeModule, typeof i24.DialogModule, typeof i25.SkeletonModule, typeof i26.PaginatorModule, typeof i27.TableModule, typeof i28.ButtonModule, typeof i29.ConfirmDialogModule, typeof i30.NgbModule, typeof i31.TranslateModule], [typeof i1.CommonHeaderLibComponent, typeof i2.SliceToTwoPipe, typeof i4.DateDiffPipe, typeof i3.customDateFormatPipe, typeof i15.ConfirmDialogComponent, typeof i16.ViewpasswordPopupComponent, typeof i31.TranslateModule]>;
41
41
  static ɵinj: i0.ɵɵInjectorDeclaration<CommonHeaderLibModule>;
42
42
  }
43
+ /**
44
+ * Initializes ngx-translate language configuration during application startup.
45
+ *
46
+ * Flow:
47
+ * 1. Load and validate supported languages from:
48
+ * assets/common-header-lib/i18n/languages.json
49
+ *
50
+ * 2. Build USERFILTEREDLANGUAGES using the exact order defined in languages.json:
51
+ * - removes duplicate langKeys
52
+ * - ignores unsupported language codes safely
53
+ *
54
+ * 3. Read USERLANG from localStorage:
55
+ * COOKIECONSTANT.USERLANG
56
+ *
57
+ * 4. If USERLANG:
58
+ * - exists in supported languages
59
+ * - and translation JSON loads successfully
60
+ * → initialize application using USERLANG
61
+ *
62
+ * 5. If USERLANG is invalid or translation loading fails:
63
+ * → fallback to first language from USERFILTEREDLANGUAGES
64
+ * (preserving languages.json order)
65
+ *
66
+ * 6. If first fallback language also fails:
67
+ * → fallback to GlobalConstants.DEFAULTLANG
68
+ *
69
+ * 7. If DEFAULTLANG translation also fails:
70
+ * → initialize empty translations safely
71
+ * → prevent application bootstrap crash
72
+ *
73
+ * Example:
74
+ * languages.json = ["it", "ja", "ko"]
75
+ * localStorage USERLANG = { langKey: "vi" }
76
+ *
77
+ * Result:
78
+ * - "vi" ignored because unsupported
79
+ * - tries "it.json"
80
+ * - if "it.json" fails → loads DEFAULTLANG ("en")
81
+ *
82
+ * Notes:
83
+ * - languages.json controls supported language order and priority
84
+ * - translation files are validated before translate.use(...)
85
+ * - invalid localStorage data is ignored safely
86
+ * - application startup is protected against translation failures
87
+ */
43
88
  export declare function initTranslateService(translate: TranslateService, localStorageService: StorageService, http: HttpClient, msgService: ToastMsgService): () => Promise<void>;
44
89
  export declare function createLibTranslateLoader(http: HttpClient): TranslateHttpLoader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "common-header-lib",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^14.2.0",
6
6
  "@angular/core": "^14.2.0",