• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / ae25c6b6-5290-47f3-82ca-1d26e21b49a6

18 Nov 2024 02:08AM UTC coverage: 90.353% (+0.001%) from 90.352%
ae25c6b6-5290-47f3-82ca-1d26e21b49a6

Pull #3241

circleci

minlovehua
feat(i18n): i18n design and review #TINFR-916
Pull Request #3241: feat(i18n): i18n design and review #TINFR-916

5521 of 6758 branches covered (81.7%)

Branch coverage included in aggregate %.

27 of 29 new or added lines in 10 files covered. (93.1%)

19 existing lines in 2 files now uncovered.

13192 of 13953 relevant lines covered (94.55%)

996.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/i18n/i18n.service.ts
1
import { inject, Injectable } from '@angular/core';
2
import { THY_I18N_EN_US, THY_I18N_LOCALE_ID, THY_I18N_ZH_CN, ThyI18nLocale, zhCnLocale, enUsLocale } from '.';
3

4
function normalizeLocale(localeId: string): string {
5
    return localeId?.toLowerCase().replace(/_/g, '-');
241✔
6
}
7

1✔
8
@Injectable({
9
    providedIn: 'root'
241✔
10
})
482✔
11
export class ThyI18nService {
482✔
12
    private locales: { [id: string]: ThyI18nLocale } = {
13
        'zh-cn': inject(THY_I18N_ZH_CN, { optional: true }) || zhCnLocale,
241✔
14
        'en-us': inject(THY_I18N_EN_US, { optional: true }) || enUsLocale
15
    };
16

17
    private defaultLocaleId: string = normalizeLocale(inject(THY_I18N_LOCALE_ID, { optional: true })) || 'zh-cn';
241✔
18

19
    /**
20
     * 当前语言包
21
     */
22
    locale: ThyI18nLocale = this.locales[this.defaultLocaleId];
23

NEW
24
    /**
×
NEW
25
     * 设置语言
×
26
     * @param id 可以传入 zh-cn(或zh-CN)、 en-us(或en-US)
27
     */
28
    setLocale(id: string) {
1✔
29
        const localeId = normalizeLocale(id);
30
        this.locale = this.locales[localeId] || this.locales[this.defaultLocaleId];
31
    }
32
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc