Skip to content

Commit

Permalink
fixed: Fixed an issue when switching languages
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoJiSen committed Nov 21, 2024
1 parent ba36157 commit f7cf3c2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/elements/nav/nav.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class ElementNavComponent implements OnInit {
{
id: 'Chinese-hant',
click: () => {
this._i18n.use('zh-hant');
this._i18n.use('zh_hant');
},
name: '中文(繁體)'
},
Expand Down
3 changes: 3 additions & 0 deletions src/app/elements/replay/guacamole/guacamole.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ export class ElementReplayGuacamoleComponent implements OnInit, OnChanges {
}
this.recordingDisplay.scale(this.getPropScale());
};

clearInterval(this.interval);

// @ts-ignore
this.interval = setInterval(() => {
if (this.lastDuration === this.max) {
clearInterval(this.interval);
Expand Down
17 changes: 12 additions & 5 deletions src/app/services/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ export class I18nService {

getLangCode() {
let langCode = this._cookie.get(this.LANG_COOKIE_NAME);

if (!langCode) {
langCode = navigator.language.toLowerCase();
}

if (['zh', 'zh-cn'].includes(langCode)) {
return 'zh';
} else if (langCode.indexOf('zh-') > -1) {
return 'zh-hans';
} else if (langCode.indexOf('zh_hant') > -1) {
// zh-hant zh-tw zh-hk
return 'zh-hant';
return 'zh_hant';
} else if (langCode.indexOf('zh-hans') > -1) {
return 'zh';
} else if (langCode.indexOf('ja') > -1) {
return 'ja';
} else {
Expand Down Expand Up @@ -58,16 +62,19 @@ export class I18nService {

use(lang) {
let useLang;

this._translate.use(lang);

if (lang.indexOf('en') > -1) {
useLang = 'en';
} else if (lang.indexOf('ja') > -1) {
useLang = 'ja';
} else if (lang.indexOf('zh-hant') > -1) {
useLang = 'zh-hant';
} else if (lang.indexOf('zh_hant') > -1) {
useLang = 'zh_hant';
} else {
useLang = 'zh-hans';
}

this._cookie.set('django_language', useLang, 365, '/');
}
}
File renamed without changes.

0 comments on commit f7cf3c2

Please sign in to comment.