|
| 1 | +/* eslint-disable @typescript-eslint/ban-types */ |
| 2 | +/* eslint-disable @typescript-eslint/member-delimiter-style */ |
| 3 | +/* eslint-disable @typescript-eslint/naming-convention */ |
| 4 | +import { Component, OnInit, ViewChild } from '@angular/core'; |
| 5 | +import { registerLocaleData } from '@angular/common'; |
| 6 | +import localeBG from '@angular/common/locales/bg'; |
| 7 | +import localeCS from '@angular/common/locales/cs'; |
| 8 | +import localeDA from '@angular/common/locales/da'; |
| 9 | +import localeDE from '@angular/common/locales/de'; |
| 10 | +import localeEN from '@angular/common/locales/en'; |
| 11 | +import localeES from '@angular/common/locales/es'; |
| 12 | +import localeFR from '@angular/common/locales/fr'; |
| 13 | +import localeHU from '@angular/common/locales/hu'; |
| 14 | +import localeIT from '@angular/common/locales/it'; |
| 15 | +import localeJA from '@angular/common/locales/ja'; |
| 16 | +import localeKO from '@angular/common/locales/ko'; |
| 17 | +import localeNB from '@angular/common/locales/nb'; |
| 18 | +import localeNL from '@angular/common/locales/nl'; |
| 19 | +import localePL from '@angular/common/locales/pl'; |
| 20 | +import localePT from '@angular/common/locales/pt'; |
| 21 | +import localeRO from '@angular/common/locales/ro'; |
| 22 | +import localeSV from '@angular/common/locales/sv'; |
| 23 | +import localeTR from '@angular/common/locales/tr'; |
| 24 | +import localeHI from '@angular/common/locales/hi'; |
| 25 | +import localeHans from '@angular/common/locales/zh-Hans'; |
| 26 | +import localeHant from '@angular/common/locales/zh-Hant'; |
| 27 | +import { DATA } from '../../../data/nwindData'; |
| 28 | +import { IgxGridComponent, GridResourceStringsEN, IGridResourceStrings, IgxGridToolbarComponent, IgxGridToolbarTitleComponent, IgxSelectComponent, IgxSelectItemComponent, IgxColumnComponent } from 'igniteui-angular'; |
| 29 | +import { |
| 30 | + IgxResourceStringsBG, IgxResourceStringsCS, IgxResourceStringsDA, IgxResourceStringsDE, |
| 31 | + IgxResourceStringsES, IgxResourceStringsFR, IgxResourceStringsHU, IgxResourceStringsIT, |
| 32 | + IgxResourceStringsJA, IgxResourceStringsKO, IgxResourceStringsNB, IgxResourceStringsNL, IgxResourceStringsPL, |
| 33 | + IgxResourceStringsPT, IgxResourceStringsRO, IgxResourceStringsSV, IgxResourceStringsTR, |
| 34 | + IgxResourceStringsZHHANS, IgxResourceStringsZHHANT |
| 35 | +} from 'igniteui-angular-i18n'; |
| 36 | +import { FormsModule } from '@angular/forms'; |
| 37 | + |
| 38 | +@Component({ |
| 39 | + selector: 'app-localization-all-resources-old', |
| 40 | + styleUrls: ['./localization-all-resources.component.scss'], |
| 41 | + templateUrl: 'localization-all-resources.component.html', |
| 42 | + imports: [IgxGridComponent, IgxGridToolbarComponent, IgxGridToolbarTitleComponent, IgxSelectComponent, FormsModule, IgxSelectItemComponent, IgxColumnComponent] |
| 43 | +}) |
| 44 | +export class LocalizationAllResourcesOldComponent implements OnInit { |
| 45 | + @ViewChild('grid', { read: IgxGridComponent, static: true }) |
| 46 | + public grid: IgxGridComponent; |
| 47 | + public data: any[]; |
| 48 | + public locale: string; |
| 49 | + public locales: { type: string, resource: object }[]; |
| 50 | + public selectLocales = [ |
| 51 | + 'HI', 'BG', 'CS', 'DA', 'DE', 'EN', 'ES', 'FR', 'HU', 'IT', 'JA', 'KO', 'NB', 'NL', |
| 52 | + 'PL', 'PT', 'RO', 'SV', 'TR', 'zh-Hans', 'zh-Hant' |
| 53 | + ]; |
| 54 | + public partialCustomHindi: IGridResourceStrings; |
| 55 | + |
| 56 | + constructor() { } |
| 57 | + public ngOnInit(): void { |
| 58 | + registerLocaleData(localeBG); |
| 59 | + registerLocaleData(localeCS); |
| 60 | + registerLocaleData(localeDA); |
| 61 | + registerLocaleData(localeDE); |
| 62 | + registerLocaleData(localeEN); |
| 63 | + registerLocaleData(localeES); |
| 64 | + registerLocaleData(localeFR); |
| 65 | + registerLocaleData(localeHU); |
| 66 | + registerLocaleData(localeIT); |
| 67 | + registerLocaleData(localeJA); |
| 68 | + registerLocaleData(localeKO); |
| 69 | + registerLocaleData(localeNB); |
| 70 | + registerLocaleData(localeNL); |
| 71 | + registerLocaleData(localePL); |
| 72 | + registerLocaleData(localePT); |
| 73 | + registerLocaleData(localeRO); |
| 74 | + registerLocaleData(localeSV); |
| 75 | + registerLocaleData(localeTR); |
| 76 | + registerLocaleData(localeHI); |
| 77 | + registerLocaleData(localeHans); |
| 78 | + registerLocaleData(localeHant); |
| 79 | + |
| 80 | + this.data = DATA; |
| 81 | + |
| 82 | + // Creating a custom locale (HI) for specific grid strings. |
| 83 | + // Similarly can localize all needed strings in a separate IgxResourceStringsHI file (feel free to contribute) |
| 84 | + this.partialCustomHindi = { |
| 85 | + igx_grid_summary_count: 'गणना', |
| 86 | + igx_grid_summary_min: 'न्यून', |
| 87 | + igx_grid_summary_max: 'अधिक', |
| 88 | + igx_grid_summary_sum: 'योग', |
| 89 | + igx_grid_summary_average: 'औसत' |
| 90 | + }; |
| 91 | + |
| 92 | + this.locales = [ |
| 93 | + { type: 'BG', resource: IgxResourceStringsBG }, |
| 94 | + { type: 'CS', resource: IgxResourceStringsCS }, |
| 95 | + { type: 'DA', resource: IgxResourceStringsDA }, |
| 96 | + { type: 'DE', resource: IgxResourceStringsDE }, |
| 97 | + { type: 'ES', resource: IgxResourceStringsES }, |
| 98 | + { type: 'FR', resource: IgxResourceStringsFR }, |
| 99 | + { type: 'HU', resource: IgxResourceStringsHU }, |
| 100 | + { type: 'IT', resource: IgxResourceStringsIT }, |
| 101 | + { type: 'JA', resource: IgxResourceStringsJA }, |
| 102 | + { type: 'KO', resource: IgxResourceStringsKO }, |
| 103 | + { type: 'EN', resource: GridResourceStringsEN }, |
| 104 | + { type: 'HI', resource: this.partialCustomHindi }, |
| 105 | + { type: 'NB', resource: IgxResourceStringsNB }, |
| 106 | + { type: 'NL', resource: IgxResourceStringsNL }, |
| 107 | + { type: 'PL', resource: IgxResourceStringsPL }, |
| 108 | + { type: 'PT', resource: IgxResourceStringsPT }, |
| 109 | + { type: 'RO', resource: IgxResourceStringsRO }, |
| 110 | + { type: 'SV', resource: IgxResourceStringsSV }, |
| 111 | + { type: 'TR', resource: IgxResourceStringsTR }, |
| 112 | + { type: 'zh-Hans', resource: IgxResourceStringsZHHANS }, |
| 113 | + { type: 'zh-Hant', resource: IgxResourceStringsZHHANT } |
| 114 | + ]; |
| 115 | + this.locale = 'EN'; |
| 116 | + } |
| 117 | + |
| 118 | + public updateLocale() { |
| 119 | + const newLocale = this.locales.find(x => x.type === this.locale).resource; |
| 120 | + this.grid.resourceStrings = newLocale; |
| 121 | + } |
| 122 | +} |
0 commit comments