From fd35962de838e033a8964e0959c99572f02b15f0 Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Tue, 24 Jul 2018 13:12:49 +0800
Subject: [PATCH] 站点排行 首次加载 选中效果及加载load效果
---
src/app/core/i18n/i18n.service.ts | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/app/core/i18n/i18n.service.ts b/src/app/core/i18n/i18n.service.ts
index e046d53..cf17dd2 100644
--- a/src/app/core/i18n/i18n.service.ts
+++ b/src/app/core/i18n/i18n.service.ts
@@ -8,24 +8,26 @@
@Injectable()
export class I18NService implements AlainI18NService {
- private _default = 'en';
+ private _default = 'zh-CN';
+ // ������������������ ��������� by fx
private _langs = [
- { code: 'en', text: 'English' },
- { code: 'zh-CN', text: '������' }
+ { code: 'zh-CN', text: '������' },
+ { code: 'en', text: 'English' }
];
- constructor(settings: SettingsService,
+ constructor(
+ settings: SettingsService,
private nzLocalService: NzLocaleService,
private translate: TranslateService,
- private injector: Injector) {
+ private injector: Injector
+ ) {
this._default = settings.layout.lang || translate.getBrowserLang();
const lans = this._langs.map(item => item.code);
if (!lans.includes(this._default)) {
this._default = lans[0];
}
translate.addLangs(lans);
- translate.setDefaultLang(this._default);
}
use(lang: string = null, firstLoad = true): Observable<any> {
@@ -35,13 +37,20 @@
if (!firstLoad) this.injector.get(Router).navigate([ '/' ]);
return this.translate.use(lang);
}
-
+ /** ������������������ */
getLangs() {
return this._langs;
}
-
+ /** ������ */
fanyi(key: string) {
return this.translate.instant(key);
}
-
+ /** ������������ */
+ get defaultLang() {
+ return this._default;
+ }
+ /** ������������ */
+ get currentLang() {
+ return this.translate.currentLang || this.translate.getDefaultLang() || this._default;
+ }
}
--
Gitblit v1.8.0