Skip to content

Commit c27dd61

Browse files
authored
refactor(*): New localization implementation. (#16034)
1 parent 404ad9a commit c27dd61

File tree

400 files changed

+3011
-8596
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

400 files changed

+3011
-8596
lines changed

.github/CONTRIBUTING.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,31 @@ There are several ways to localize components' string resources:
9494
1.1. Localize a given instance of component - each component which supports localization has input property `resourceStrings`. Setting a newly instantiated object to this property will localize only that given component's instance.
9595
1.2. Localize all resources for a component type - each component which supports localization has input property `resourceStrings`. To localize all instances of a given component in the application the following steps should be performed - get the value of the input property `resourceStrings` of the component to be localized; do not create a new instance but replace the existing strings within the object. By default all components of a given type in an application share one instance of the resource strings. Replacing a value in that instance affects all components of that type in the application.
9696
1.3. Localize all resources for all components - use global method `getCurrentResourceStrings` to get an object containing current resource strings for all components. To provide localized resources just pass an object of type `IResourceStrings` to the global method `changei18n`.
97+
1.4 As of 21.1.x the localization has new implementation and you can use the new API `registerI18n` to register resource string for a component or all components for the whole app, as well as which locale it corresponds to. To localize a single component you will need to get is corresponding resource string keys using one of the available resources and provide only those keys.
9798

9899
2. Using npm package:
99100
We've created new repository which will hold the resource strings for languages different than English:
100101
https://github.com/IgniteUI/igniteui-angular-i18n
101102

102-
**NOTE** The localization repo has been moved to live inside the `igniteui-angular` repository under `./projects/igniteui-angular-i18n`
103+
**NOTE** The localization repo has been moved to live inside the `igniteui-angular` repository under `./projects/igniteui-angular-i18n`
104+
**NOTE** As of 21.1.x the localization resource strings have been moved to the [`igniteui-i18n`](https://github.com/IgniteUI/igniteui-i18n) repository under `projects/igniteui-i18n-resources`.
103105

104106
A npm package should be published each time we release new version of Ignite UI for Angular. Its version should correspond to the version of the igniteui-angular npm package.
105107
One could localize an application by importing the corresponding localized resource strings from the localization package (`igniteui-angular-i18n`) and use the methods described in the previous bullet to localize the whole application or part of it.
106-
Example:
108+
109+
**Example:**
110+
107111
Inside app.module you can perform:
108-
_import { IgxResouceStringsJA } from ‘igniteui-angular-i18n’;_
109-
And then:
110-
_Changei18n(IgxResouceStringsJA);_
112+
```ts
113+
import { IgxResouceStringsJA } fromigniteui-angular-i18n’;
114+
changei18n(IgxResouceStringsJA);
115+
```
116+
117+
**Example new API:**
118+
```ts
119+
import { ResouceStringsJA } fromigniteui-i18n-resources’;
120+
registerI18n(IgxResouceStringsJA, 'ja');
121+
```
111122

112123
### Resource strings keys naming convention
113124
Each key in the `IResourceStrings` (and `IGridResourceStrings`, `ITimePickerResourceStrings`, etc.) is prefixed with components' selector and followed by the resource string key. Having components' selectors as prefixes allows us to have same resource strings keys for more than one component.

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
All notable changes for each version of this project will be documented in this file.
44

5+
## 21.1.0
6+
7+
# Localization(i18n)
8+
9+
- `IgxActionStrip`, `IgxBanner`, `IgxCalendar`, `IgxCarousel`, `IgxChip`, `IgxCombo`, `IgxDatePicker`, `IgxDateRangePicker`, `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`, `IgxPivotGrid`, `IgxInputs`, `IgxList`, `IgxPaginator`, `IgxQueryBuilder`, `IgxTimePicker`, `IgxTree`
10+
- New `Intl` implementation for all currently supported components that format and render data like dates and numbers.
11+
- New localization implementation for the currently supported languages for all components that have resource strings in the currently supported languages.
12+
- New public localization API and package named `igniteui-i18n-resources` containing the new resources that are used in conjunction.
13+
- Added API to toggle off Angular's default formatting completely in favor of the new `Intl` implementation. Otherwise `Intl` will be used when a locale is not defined for Angular to use.
14+
- Old resources and API should still remain working and not experience any change in behavior, despite internally using the new localization as well.
15+
516
## 21.0.0
617

718
### New Features
@@ -109,7 +120,6 @@ See the [Angular Package Format documentation](https://angular.io/guide/angular-
109120
## 20.1.0
110121

111122
### New Features
112-
113123
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
114124
- Introduced a new cell merging feature that allows you to configure and merge cells in a column based on same data or other custom condition, into a single cell.
115125

angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
],
329329
"outputHashing": "none",
330330
"optimization": true,
331-
"externalDependencies": ["lit"]
331+
"externalDependencies": ["lit", "igniteui-i18n-core"]
332332
},
333333
"development": {
334334
"optimization": false,

package-lock.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"dompurify": "^3.3.0",
7777
"express": "^5.2.1",
7878
"fflate": "^0.8.1",
79+
"igniteui-i18n-core": "^1.0.1",
7980
"igniteui-theming": "^24.0.0",
8081
"igniteui-trial-watermark": "^3.1.0",
8182
"jspdf": "^3.0.4",
@@ -125,6 +126,7 @@
125126
"hammerjs": "^2.0.8",
126127
"ig-typedoc-theme": "^7.0.1",
127128
"igniteui-dockmanager": "^1.17.0",
129+
"igniteui-i18n-resources": "1.0.1",
128130
"igniteui-sassdoc-theme": "^2.1.0",
129131
"igniteui-webcomponents": "^6.3.1",
130132
"jasmine": "^5.6.0",

projects/igniteui-angular-elements/esbuild.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const config = {
88
minify: false, // temporary disabled due to Webpack issues https://github.com/webpack/webpack/issues/16262
99
outfile: `${ROOT}/elements.js`,
1010
format: 'esm',
11-
external: ['lit'],
11+
external: ['lit', 'igniteui-i18n-core'],
1212
target: 'es2022',
1313
metafile: true,
1414
treeShaking: true

projects/igniteui-angular-elements/src/analyzer/elements.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
IgxPivotGridComponent,
66
} from "../../../igniteui-angular/grids/pivot-grid";
77
import { IgxTreeGridComponent } from "../../../igniteui-angular/grids/tree-grid";
8+
import { IgxActionStripComponent } from "../../../igniteui-angular/action-strip/src/action-strip/action-strip.component";
9+
import { IgxActionStripToken } from "../../../igniteui-angular/core/src/grid-column-actions/token";
810
import { IgxPaginatorComponent } from "../../../igniteui-angular/paginator/src/paginator/paginator.component";
911
import { IgxPaginatorToken } from "../../../igniteui-angular/paginator/src/paginator/token";
1012
import { IgxColumnGroupComponent } from "../../../igniteui-angular/grids/core/src/columns/column-group.component";
@@ -22,8 +24,6 @@ import { IgxGridToolbarExporterComponent } from "../../../igniteui-angular/grids
2224
import { IgxGridToolbarHidingComponent } from "../../../igniteui-angular/grids/core/src/toolbar/grid-toolbar-hiding.component";
2325
import { IgxGridToolbarPinningComponent } from "../../../igniteui-angular/grids/core/src/toolbar/grid-toolbar-pinning.component";
2426
import { IgxRowIslandComponent } from "../../../igniteui-angular/grids/hierarchical-grid/src/row-island.component";
25-
import { IgxActionStripComponent } from "../../../igniteui-angular/action-strip/src/action-strip/action-strip.component";
26-
import { IgxActionStripToken } from "../../../igniteui-angular/core/src/grid-column-actions/token";
2727
import { IgxGridStateComponent } from "../lib/state.component";
2828

2929
export const registerComponents = [

projects/igniteui-angular-elements/src/public_api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { registerI18n, setCurrentI18n } from 'igniteui-i18n-core';
12
import { ByLevelTreeGridMergeStrategy, ColumnPinningPosition, DefaultMergeStrategy, DefaultTreeGridMergeStrategy, FilteringExpressionsTree, FilteringExpressionsTreeType, FilteringLogic, HorizontalAlignment, IgxBooleanFilteringOperand, IgxDateFilteringOperand, IgxDateTimeFilteringOperand, IgxFilteringOperand, IgxNumberFilteringOperand, IgxStringFilteringOperand, IgxTimeFilteringOperand, NoopFilteringStrategy, NoopSortingStrategy, SortingDirection, VerticalAlignment } from 'igniteui-angular/core';
23
import { DropPosition, GridPagingMode, IgxDateSummaryOperand, IgxNumberSummaryOperand, IgxPivotAggregate, IgxPivotDateAggregate, IgxPivotDateDimension, IgxPivotNumericAggregate, IgxPivotTimeAggregate, IgxSummaryOperand, IgxTimeSummaryOperand, NoopPivotDimensionsStrategy, PivotDimensionType, RowPinningPosition } from 'igniteui-angular/grids/core';
34

@@ -44,4 +45,8 @@ export {
4445
// overlay position settings (used in grids, paginator, toolbar)
4546
HorizontalAlignment,
4647
VerticalAlignment,
48+
49+
// i18n
50+
registerI18n,
51+
setCurrentI18n,
4752
}

projects/igniteui-angular-elements/src/utils/injector-ref.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ClassProvider, createEnvironmentInjector, EnvironmentInjector, getPlatf
22
import { BrowserModule, platformBrowser } from '@angular/platform-browser';
33
import { provideAnimations } from '@angular/platform-browser/animations';
44
import { IgxIconBroadcastService } from '../lib/icon.broadcast.service';
5-
import { ELEMENTS_TOKEN } from 'igniteui-angular/core';
5+
import { ELEMENTS_TOKEN , provideIgniteIntl} from 'igniteui-angular/core';
66

77
/**
88
* Top-level await (TLA) both requires higher ES target and currently has only partial support in ES build
@@ -36,7 +36,8 @@ const injector = createEnvironmentInjector([
3636
// Elements specific:
3737
provideAnimations(),
3838
{ provide: ELEMENTS_TOKEN, useValue: true },
39-
IgxIconBroadcastService
39+
IgxIconBroadcastService,
40+
provideIgniteIntl()
4041
], platformInjector as EnvironmentInjector);
4142

4243
export { injector };

projects/igniteui-angular-i18n/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,9 @@
2222
"bugs": {
2323
"url": "https://github.com/IgniteUI/igniteui-angular/issues"
2424
},
25-
"homepage": "https://github.com/IgniteUI/igniteui-angular/projects/igniteui-angular-i18n#readme"
25+
"homepage": "https://github.com/IgniteUI/igniteui-angular/projects/igniteui-angular-i18n#readme",
26+
"dependencies": {
27+
"igniteui-i18n-core": "^1.0.1",
28+
"igniteui-i18n-resources": "^1.0.1"
29+
}
2630
}

0 commit comments

Comments
 (0)