diff --git a/docs/i18n.en-US.md b/docs/i18n.en-US.md index 5823ae737..e6f0220fb 100644 --- a/docs/i18n.en-US.md +++ b/docs/i18n.en-US.md @@ -27,13 +27,11 @@ registerLocaleData(zh); `ng-zorro-antd` internationalization defaults to the Chinese version, for example the default English version: ```ts -import { NZ_I18N, en_US } from 'ng-zorro-antd/i18n'; +import { en_US, provideNzI18n } from 'ng-zorro-antd/i18n'; @NgModule({ - ... - imports : [ NgZorroAntdModule ], - providers : [ { provide: NZ_I18N, useValue: en_US } ] + providers: [provideNzI18n(en_US)] }) -export class AppModule { } +export class App1Module {} ``` Of course, you can also use runtime changes: @@ -144,7 +142,7 @@ In order to make language uniformity, NG-ALAIN provides a simple unified configu ```ts // #region i18n import { default as ngLang } from '@angular/common/locales/zh'; -import { NZ_I18N, zh_CN as zorroLang } from 'ng-zorro-antd/i18n'; +import { provideNzI18n, zh_CN as zorroLang } from 'ng-zorro-antd/i18n'; import { DELON_LOCALE, zh_CN as delonLang } from '@delon/theme'; const LANG = { abbr: 'zh', @@ -157,7 +155,7 @@ import { registerLocaleData } from '@angular/common'; registerLocaleData(LANG.ng, LANG.abbr); const LANG_PROVIDES = [ { provide: LOCALE_ID, useValue: LANG.abbr }, - { provide: NZ_I18N, useValue: LANG.zorro }, + provideNzI18n(LANG.zorro), { provide: DELON_LOCALE, useValue: LANG.delon }, ]; // #endregion @@ -173,7 +171,7 @@ export class AppModule {} ```ts // #region i18n import { default as ngLang } from '@angular/common/locales/en'; -import { NZ_I18N, en_US as zorroLang } from 'ng-zorro-antd/i18n'; +import { provideNzI18n, en_US as zorroLang } from 'ng-zorro-antd/i18n'; import { DELON_LOCALE, en_US as delonLang } from '@delon/theme'; const LANG = { abbr: 'en', @@ -186,7 +184,7 @@ import { registerLocaleData } from '@angular/common'; registerLocaleData(LANG.ng, LANG.abbr); const LANG_PROVIDES = [ { provide: LOCALE_ID, useValue: LANG.abbr }, - { provide: NZ_I18N, useValue: LANG.zorro }, + provideNzI18n(LANG.zorro), { provide: DELON_LOCALE, useValue: LANG.delon }, ]; // #endregion diff --git a/docs/i18n.zh-CN.md b/docs/i18n.zh-CN.md index a8e4a2da3..561e3259f 100644 --- a/docs/i18n.zh-CN.md +++ b/docs/i18n.zh-CN.md @@ -27,13 +27,11 @@ registerLocaleData(zh); NG-ZORRO 国际化默认是中文版,例如默认为英文版本: ```ts -import { NZ_I18N, en_US } from 'ng-zorro-antd/i18n'; +import { en_US, provideNzI18n } from 'ng-zorro-antd/i18n'; @NgModule({ - ... - imports : [ NgZorroAntdModule ], - providers : [ { provide: NZ_I18N, useValue: en_US } ] + providers: [provideNzI18n(en_US)] }) -export class AppModule { } +export class App1Module {} ``` 当然,也可以使用运行时更改: @@ -144,7 +142,7 @@ export class I18nTestComponent { ```ts // #region i18n import { default as ngLang } from '@angular/common/locales/zh'; -import { NZ_I18N, zh_CN as zorroLang } from 'ng-zorro-antd/i18n'; +import { provideNzI18n, zh_CN as zorroLang } from 'ng-zorro-antd/i18n'; import { DELON_LOCALE, zh_CN as delonLang } from '@delon/theme'; const LANG = { abbr: 'zh', @@ -157,7 +155,7 @@ import { registerLocaleData } from '@angular/common'; registerLocaleData(LANG.ng, LANG.abbr); const LANG_PROVIDES = [ { provide: LOCALE_ID, useValue: LANG.abbr }, - { provide: NZ_I18N, useValue: LANG.zorro }, + provideNzI18n(LANG.zorro), { provide: DELON_LOCALE, useValue: LANG.delon }, ]; // #endregion @@ -173,7 +171,7 @@ export class AppModule {} ```ts // #region i18n import { default as ngLang } from '@angular/common/locales/en'; -import { NZ_I18N, en_US as zorroLang } from 'ng-zorro-antd/i18n'; +import { provideNzI18n, en_US as zorroLang } from 'ng-zorro-antd/i18n'; import { DELON_LOCALE, en_US as delonLang } from '@delon/theme'; const LANG = { abbr: 'en', @@ -186,7 +184,7 @@ import { registerLocaleData } from '@angular/common'; registerLocaleData(LANG.ng, LANG.abbr); const LANG_PROVIDES = [ { provide: LOCALE_ID, useValue: LANG.abbr }, - { provide: NZ_I18N, useValue: LANG.zorro }, + provideNzI18n(LANG.zorro), { provide: DELON_LOCALE, useValue: LANG.delon }, ]; // #endregion diff --git a/package.json b/package.json index 125dded58..5b6286b2f 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "extend": "^3.0.2", "file-saver": "^2.0.5", "ng-github-button": "^16.0.0", - "ng-zorro-antd": "^16.1.0", + "ng-zorro-antd": "^16.2.0", "ngx-color": "~9.0.0", "ngx-countdown": "^16.0.0", "ngx-highlight-js": "^16.1.0", diff --git a/schematics/application/files/src/app/app.module.ts b/schematics/application/files/src/app/app.module.ts index 3534fac59..c18d50c4f 100644 --- a/schematics/application/files/src/app/app.module.ts +++ b/schematics/application/files/src/app/app.module.ts @@ -13,7 +13,7 @@ import { Observable } from 'rxjs'; import { default as ngLang } from '@angular/common/locales/zh'; import { DELON_LOCALE, zh_CN as delonLang } from '@delon/theme'; import { zhCN as dateLang } from 'date-fns/locale'; -import { NZ_DATE_LOCALE, NZ_I18N, zh_CN as zorroLang } from 'ng-zorro-antd/i18n'; +import { NZ_DATE_LOCALE, provideNzI18n, zh_CN as zorroLang } from 'ng-zorro-antd/i18n'; const LANG = { abbr: 'zh', ng: ngLang, @@ -26,7 +26,7 @@ import { registerLocaleData } from '@angular/common'; registerLocaleData(LANG.ng, LANG.abbr); const LANG_PROVIDES = [ { provide: LOCALE_ID, useValue: LANG.abbr }, - { provide: NZ_I18N, useValue: LANG.zorro }, + provideNzI18n(LANG.zorro), { provide: NZ_DATE_LOCALE, useValue: LANG.date }, { provide: DELON_LOCALE, useValue: LANG.delon }, ]; diff --git a/schematics/plugin/plugin.default-language.spec.ts b/schematics/plugin/plugin.default-language.spec.ts index f2ca1cc6e..e0d96e713 100644 --- a/schematics/plugin/plugin.default-language.spec.ts +++ b/schematics/plugin/plugin.default-language.spec.ts @@ -13,7 +13,7 @@ describe('NgAlainSchematic: plugin: default-language', () => { it(`should working`, () => { const content = tree.readContent(PATH); expect(content).toContain(`@angular/common/locales/en`); - expect(content).toContain(`NZ_I18N, en_US`); + expect(content).toContain(`provideNzI18n, en_US`); expect(content).toContain(`DELON_LOCALE, en_US`); }); @@ -21,7 +21,7 @@ describe('NgAlainSchematic: plugin: default-language', () => { await runner.runSchematic('plugin', { name: 'defaultLanguage', type: 'add', defaultLanguage: 'zh' }, tree); const content = tree.readContent(PATH); expect(content).toContain(`@angular/common/locales/zh`); - expect(content).toContain(`NZ_I18N, zh_CN`); + expect(content).toContain(`provideNzI18n, zh_CN`); expect(content).toContain(`DELON_LOCALE, zh_CN`); }); }); diff --git a/schematics/plugin/plugin.default-language.ts b/schematics/plugin/plugin.default-language.ts index def03cbee..d044b867b 100644 --- a/schematics/plugin/plugin.default-language.ts +++ b/schematics/plugin/plugin.default-language.ts @@ -40,6 +40,7 @@ export function pluginDefaultLanguage(options: PluginOptions): Rule { .replace(/abbr: '([^']+)/, `abbr: '${options.defaultLanguage}`); // zorro content = content.replace(/NZ_I18N, ([^ ]+)/, `NZ_I18N, ${targetLang.zorro}`); + content = content.replace(/provideNzI18n, ([^ ]+)/, `provideNzI18n, ${targetLang.zorro}`); // delon content = content.replace(/DELON_LOCALE, ([^ ]+)/, `DELON_LOCALE, ${targetLang.zorro}`); tree.overwrite(modulePath, content); diff --git a/src/app/core/code/files/app.module.ts b/src/app/core/code/files/app.module.ts index 846b4ccf2..d3087099b 100644 --- a/src/app/core/code/files/app.module.ts +++ b/src/app/core/code/files/app.module.ts @@ -9,7 +9,7 @@ import { RouterModule } from '@angular/router'; import { DemoNgZorroAntdModule } from './ng-zorro-antd.module'; import { NZ_ICONS } from 'ng-zorro-antd/icon'; -import { NZ_I18N, en_US } from 'ng-zorro-antd/i18n'; +import { provideNzI18n, en_US } from 'ng-zorro-antd/i18n'; import { IconDefinition } from '@ant-design/icons-angular'; import * as AllIcons from '@ant-design/icons-angular/icons'; @@ -62,7 +62,8 @@ providers: [ deps: [StartupService], multi: true }, - { provide: NZ_I18N, useValue: en_US }, { provide: NZ_ICONS, useValue: icons } + provideNzI18n(en_US), + { provide: NZ_ICONS, useValue: icons } ], declarations: [ ${componentName} ], bootstrap: [ ${componentName} ] diff --git a/src/app/core/code/files/global-config.module.ts b/src/app/core/code/files/global-config.module.ts index 1b98dea34..0d51e91d6 100644 --- a/src/app/core/code/files/global-config.module.ts +++ b/src/app/core/code/files/global-config.module.ts @@ -34,11 +34,11 @@ alainProvides.push(AlainConfigService as any); // Please refer to: https://ng.ant.design/docs/global-config/en#how-to-use // #region NG-ZORRO Config -import { NzConfig, NZ_CONFIG } from 'ng-zorro-antd/core/config'; +import { NzConfig, provideNzConfig } from 'ng-zorro-antd/core/config'; const ngZorroConfig: NzConfig = {}; -const zorroProvides = [{ provide: NZ_CONFIG, useValue: ngZorroConfig }]; +const zorroProvides = [provideNzConfig(ngZorroConfig)]; // #endregion diff --git a/src/app/global-config.module.ts b/src/app/global-config.module.ts index a767184fd..e9c73020e 100644 --- a/src/app/global-config.module.ts +++ b/src/app/global-config.module.ts @@ -52,11 +52,11 @@ const alainProvides = [{ provide: ALAIN_CONFIG, useValue: alainConfig }]; // Please refer to: https://ng.ant.design/docs/global-config/en#how-to-use // #region NG-ZORRO Config -import { NzConfig, NZ_CONFIG } from 'ng-zorro-antd/core/config'; +import { NzConfig, provideNzConfig } from 'ng-zorro-antd/core/config'; const ngZorroConfig: NzConfig = {}; -const zorroProvides = [{ provide: NZ_CONFIG, useValue: ngZorroConfig }]; +const zorroProvides = [provideNzConfig(ngZorroConfig)]; // #endregion