mn-angular-lib 1.0.14 → 1.0.15
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.
|
@@ -3806,9 +3806,11 @@ class MnTable {
|
|
|
3806
3806
|
/** Per-column filter values keyed by column key. */
|
|
3807
3807
|
columnFilters = {};
|
|
3808
3808
|
cdr = inject(ChangeDetectorRef);
|
|
3809
|
+
lang = inject(MnLanguageService);
|
|
3809
3810
|
dataSubscription;
|
|
3810
3811
|
searchSubject = new Subject();
|
|
3811
3812
|
searchSubscription;
|
|
3813
|
+
langSubscription;
|
|
3812
3814
|
/** Tracks the previous toolbar template reference for change detection. */
|
|
3813
3815
|
previousToolbarTemplate;
|
|
3814
3816
|
/**
|
|
@@ -3836,6 +3838,7 @@ class MnTable {
|
|
|
3836
3838
|
ngOnDestroy() {
|
|
3837
3839
|
this.dataSubscription?.unsubscribe();
|
|
3838
3840
|
this.searchSubscription?.unsubscribe();
|
|
3841
|
+
this.langSubscription?.unsubscribe();
|
|
3839
3842
|
}
|
|
3840
3843
|
// ── Search ──
|
|
3841
3844
|
get isPaginated() {
|
|
@@ -3944,6 +3947,7 @@ class MnTable {
|
|
|
3944
3947
|
}
|
|
3945
3948
|
ngOnInit() {
|
|
3946
3949
|
this.validateDataSource();
|
|
3950
|
+
this.resolveTranslationKeys();
|
|
3947
3951
|
this.currentSort = this.dataSource.defaultSort ?? null;
|
|
3948
3952
|
this.pageSize = this.dataSource.pageSize ?? 10;
|
|
3949
3953
|
// Initialize all filterable columns with empty string to avoid undefined values.
|
|
@@ -3973,6 +3977,39 @@ class MnTable {
|
|
|
3973
3977
|
this.applyFilterAndSort(true);
|
|
3974
3978
|
this.cdr.markForCheck();
|
|
3975
3979
|
});
|
|
3980
|
+
// Re-resolve translation keys when the locale changes.
|
|
3981
|
+
this.langSubscription = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
3982
|
+
this.resolveTranslationKeys();
|
|
3983
|
+
this.cdr.markForCheck();
|
|
3984
|
+
});
|
|
3985
|
+
}
|
|
3986
|
+
/**
|
|
3987
|
+
* Resolves all translation keys (headerKey, filterPlaceholderKey, emptyMessageKey, etc.)
|
|
3988
|
+
* into their corresponding display strings using MnLanguageService.
|
|
3989
|
+
*/
|
|
3990
|
+
resolveTranslationKeys() {
|
|
3991
|
+
for (const col of this.dataSource.columns) {
|
|
3992
|
+
if (col.headerKey) {
|
|
3993
|
+
col.header = this.lang.t(col.headerKey);
|
|
3994
|
+
}
|
|
3995
|
+
if (col.filterPlaceholderKey) {
|
|
3996
|
+
col.filterPlaceholder = this.lang.t(col.filterPlaceholderKey);
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
if (this.dataSource.emptyMessageKey) {
|
|
4000
|
+
this.dataSource.emptyMessage = this.lang.t(this.dataSource.emptyMessageKey);
|
|
4001
|
+
}
|
|
4002
|
+
if (this.dataSource.searchPlaceholderKey) {
|
|
4003
|
+
this.dataSource.searchPlaceholder = this.lang.t(this.dataSource.searchPlaceholderKey);
|
|
4004
|
+
}
|
|
4005
|
+
if (this.dataSource.labels) {
|
|
4006
|
+
if (this.dataSource.labels.loadMoreKey) {
|
|
4007
|
+
this.dataSource.labels.loadMore = this.lang.t(this.dataSource.labels.loadMoreKey);
|
|
4008
|
+
}
|
|
4009
|
+
if (this.dataSource.labels.rowsPerPageKey) {
|
|
4010
|
+
this.dataSource.labels.rowsPerPage = this.lang.t(this.dataSource.labels.rowsPerPageKey);
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
3976
4013
|
}
|
|
3977
4014
|
onSearch(searchString) {
|
|
3978
4015
|
this.currentPage = 1;
|