mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 22:39:46 +00:00
Refactor i18n approach (#2875)
* Refactor i18n approach * chore: move to shared * chore: add default * create DialogService and update LoadingService (#2876) * complete translation infra for ui project, currently broken * cleanup and more dictionaries * chore: fix --------- Co-authored-by: Matt Hill <MattDHill@users.noreply.github.com> Co-authored-by: Matt Hill <mattnine@protonmail.com>
This commit is contained in:
19
web/projects/shared/src/i18n/i18n.pipe.ts
Normal file
19
web/projects/shared/src/i18n/i18n.pipe.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { inject, Injectable, Pipe, PipeTransform } from '@angular/core'
|
||||
import { ENGLISH } from './dictionaries/english'
|
||||
import { I18N, i18nKey } from './i18n.providers'
|
||||
|
||||
@Pipe({
|
||||
standalone: true,
|
||||
name: 'i18n',
|
||||
pure: false,
|
||||
})
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class i18nPipe implements PipeTransform {
|
||||
private readonly i18n = inject(I18N)
|
||||
|
||||
transform(englishKey: i18nKey | null | undefined): string | undefined {
|
||||
return englishKey
|
||||
? this.i18n()?.[ENGLISH[englishKey]] || englishKey
|
||||
: undefined
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user