-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
7,711 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './selector.service' | ||
export * from './theme.service' | ||
export * from './icons' | ||
export * from './translate' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { HttpClient } from '@angular/common/http' | ||
import en from '@angular/common/locales/en' | ||
import localeZhExtra from '@angular/common/locales/extra/zh-Hans' | ||
import zh from '@angular/common/locales/zh' | ||
import localeZh from '@angular/common/locales/zh-Hans' | ||
import { ZhHans as AuthZhHans, ZhHant as AuthZhHant } from '@metad/cloud/auth' | ||
import { ZhHans as IAppZhHans, ZhHant as IAppZhHant } from '@metad/cloud/indicator-market/i18n' | ||
import { registerLocaleData as nxRegisterLocaleData, zhHans as CoreZhHans, zhHant as CoreZhHant } from '@metad/core' | ||
import { ZhHans, ZhHant } from '@metad/ocap-angular/i18n' | ||
import { ZhHans as StoryZhHans, ZhHant as StoryZhHant } from '@metad/story/i18n' | ||
import { MissingTranslationHandler, MissingTranslationHandlerParams } from '@ngx-translate/core' | ||
import { TranslateHttpLoader } from '@ngx-translate/http-loader' | ||
import { } from '@metad/core' | ||
import { Observable, map } from 'rxjs' | ||
import { LanguagesEnum } from '../types' | ||
import { registerLocaleData } from '@angular/common' | ||
import { enUS, zhCN, zhHK } from 'date-fns/locale' | ||
|
||
|
||
export const LOCALE_DEFAULT = LanguagesEnum.SimplifiedChinese | ||
registerLocaleData(localeZh, LOCALE_DEFAULT, localeZhExtra) | ||
registerLocaleData(zh) | ||
registerLocaleData(en) | ||
nxRegisterLocaleData(CoreZhHans, LanguagesEnum.SimplifiedChinese) | ||
nxRegisterLocaleData(CoreZhHant, LanguagesEnum.TraditionalChinese) | ||
|
||
class CustomTranslateHttpLoader extends TranslateHttpLoader { | ||
getTranslation(lang: string): Observable<Object> { | ||
let ocapTranslates = {} | ||
switch (lang) { | ||
case LanguagesEnum.Chinese: | ||
case LanguagesEnum.SimplifiedChinese: | ||
ocapTranslates = { | ||
...ZhHans, | ||
...CoreZhHans, | ||
...StoryZhHans, | ||
...AuthZhHans, | ||
...IAppZhHans | ||
} | ||
break | ||
case LanguagesEnum.TraditionalChinese: | ||
ocapTranslates = { | ||
...ZhHant, | ||
...CoreZhHant, | ||
...StoryZhHant, | ||
...AuthZhHant, | ||
...IAppZhHant | ||
} | ||
break | ||
default: | ||
} | ||
return super.getTranslation(lang).pipe( | ||
map((t) => ({ | ||
...t, | ||
...ocapTranslates | ||
})) | ||
) | ||
} | ||
} | ||
|
||
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader { | ||
return new CustomTranslateHttpLoader(http, `./assets/i18n/`, '.json') | ||
} | ||
|
||
export class MyMissingTranslationHandler implements MissingTranslationHandler { | ||
handle(params: MissingTranslationHandlerParams) { | ||
if (params.interpolateParams) { | ||
return params.interpolateParams['Default'] || params.key | ||
} | ||
return params.key | ||
} | ||
} | ||
|
||
export function mapDateLocale(locale: string) { | ||
switch (locale) { | ||
case 'zh-CN': | ||
case 'zh-Hans': | ||
case 'zh': | ||
return zhCN | ||
case 'zh-Hant': | ||
return zhHK | ||
default: | ||
return enUS | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
apps/cloud/src/app/@theme/header/settings/settings.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<div role="tooltip" class="z-50"> | ||
<div class="px-3 py-2 border-b flex items-center border-gray-200 rounded-t-lg dark:border-gray-600"> | ||
<h3 class="mb-0 font-semibold"> | ||
{{ 'PAC.MENU.UserSettings' | translate: { Default: 'User Settings' } }} | ||
</h3>: | ||
|
||
<span class="flex-1 overflow-hidden text-ellipsis"> | ||
{{ isAuthenticated$ | async | user }} | ||
</span> | ||
</div> | ||
<div class="w-[220px] flex flex-col justify-start items-stretch p-4" *ngIf="isAuthenticated$ | async as user"> | ||
<div class="flex flex-col justify-start items-stretch p-2"> | ||
<ngm-select [label]="'PAC.MENU.GENERAL.LANGUAGE' | translate: { Default: 'Language' }" | ||
[placeholder]="'PAC.MENU.GENERAL.LANGUAGE_PLACEHOLDER' | translate: { Default: 'Select Language' }" | ||
[displayBehaviour]="DisplayBehaviour.descriptionOnly" | ||
[selectOptions]="languages" | ||
[ngModel]="preferredLanguage$ | async" | ||
(ngModelChange)="onLanguageSelect($event)" | ||
> | ||
<mat-icon ngmSuffix>translate</mat-icon> | ||
</ngm-select> | ||
</div> | ||
|
||
<button mat-button (click)="onProfile()"> | ||
<mat-icon>account_circle</mat-icon> | ||
<span>{{ 'PAC.menu.profile' | translate }}</span> | ||
</button> | ||
|
||
<button mat-button (click)="onLogoutClick()"> | ||
<mat-icon>settings_power</mat-icon> | ||
<span>{{ 'PAC.menu.logout' | translate }}</span> | ||
</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.