@angular/core#LOCALE_ID TypeScript Examples

The following examples show how to use @angular/core#LOCALE_ID. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.service.ts    From tuxedo-control-center with GNU General Public License v3.0 7 votes vote down vote up
constructor(
    private sysfs: SysFsService,
    private electron: ElectronService,
    private decimalPipe: DecimalPipe,
    public overlayContainer: OverlayContainer,
    @Inject(LOCALE_ID) localeId) {
      this.localeId = localeId;
      this.languageMap = {};
      for (const lang of this.getLanguagesMenuArray()) {
        this.languageMap[lang.id] = lang;
      }

      if (localStorage.getItem('themeClass')) {
        this.themeClass = new BehaviorSubject<string>(localStorage.getItem('themeClass'));
      } else {
        this.themeClass = new BehaviorSubject<string>('light-theme');
      }
    }
Example #2
Source File: app.module.ts    From employee-crud-api with MIT License 6 votes vote down vote up
@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    SlimLoadingBarModule,
    HttpClientModule,
  ],
  providers: [
    {
      provide: LOCALE_ID,
      useValue: 'pt-BR'
    }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
Example #3
Source File: ngx-mat-datefns-date-adapter.spec.ts    From ngx-mat-datefns-date-adapter with MIT License 6 votes vote down vote up
describe('NgxDateFnsDateAdapter with LOCALE_ID override', () => {
  let adapter: NgxDateFnsDateAdapter;

  beforeEach(
    waitForAsync(() => {
      TestBed.configureTestingModule({
        imports: [NgxMatDateFnsDateModule],
        providers: [
          { provide: LOCALE_ID, useValue: 'da' },
          { provide: NGX_MAT_DATEFNS_LOCALES, useValue: [da] },
        ],
      }).compileComponents();
    })
  );

  beforeEach(inject([DateAdapter], (d: NgxDateFnsDateAdapter) => {
    adapter = d;
  }));

  it('should cascade locale id from the LOCALE_ID injection token to MAT_DATE_LOCALE', () => {
    const expectedValue = [
      'søndag',
      'mandag',
      'tirsdag',
      'onsdag',
      'torsdag',
      'fredag',
      'lørdag',
    ];

    expect(adapter.getDayOfWeekNames('long')).toEqual(expectedValue);
  });
});
Example #4
Source File: chat-page.component.ts    From avid-covider with MIT License 6 votes vote down vote up
constructor(private http: HttpClient,
              private storage: ReportStoreService,
              private notifications: NotificationService,
              private source: SourceService,
              private mapService: MapService,
              public layout: LayoutService,
              private shareService: ShareService,
              private reminders: RemindersService,
              private appinstall: AppinstallService,
              @Inject(LOCALE_ID) private locale) {}
Example #5
Source File: heatmap.component.ts    From avid-covider with MIT License 6 votes vote down vote up
constructor(public layout: LayoutService, public mapService: MapService, private i18n: I18nService,
              private storage: ReportStoreService, @Inject(LOCALE_ID) private locale) {
    this.popupStream.pipe(
      debounceTime(250),
      distinctUntilChanged((prev, curr) => prev.city_id === curr.city_id),
    ).subscribe((ev) => {
      this.popupVisible = !!ev.city_id;
      if (this.popupVisible) {
        this.popupLeft = (this.padding + ev.location.x) + 'px';
        this.popupTop = (this.padding + ev.location.y) + 'px';
        this.popupData = this.mapService.popup_data[ev.city_id] || {};

        this.popupData.txCityName = this.popupData.translations ?
          (this.popupData.translations[this.locale] || this.popupData.translations.he) :
          this.popupData.city_name;
      }
    });
  }
Example #6
Source File: intro-page.component.ts    From avid-covider with MIT License 6 votes vote down vote up
constructor(private notifications: NotificationService,
              public layout: LayoutService,
              public mapService: MapService,
              private storage: ReportStoreService,
              public cityRanking: CityRankingService,
              @Inject(LOCALE_ID) public locale) {
    this.cityRanking.national.pipe(first()).subscribe((national) => {
      this.national = national;
      this.dateSpan = [
        national.scores[0].date.split('-').slice(1).reverse().join('/'),
        national.scores[national.scores.length - 1].date.split('-').slice(1).reverse().join('/'),
      ];
    });
  }
Example #7
Source File: reminders.service.ts    From avid-covider with MIT License 6 votes vote down vote up
constructor(private notifications: NotificationService,
              private appinstall: AppinstallService,
              private source: SourceService,
              @Inject(LOCALE_ID) private locale) {
    this.titleTranslations = {};
    for (const item of script.s[1].keys) {
      if (item.name.indexOf('reminder:') === 0) {
        this.titleTranslations[item.name.slice(9)] = item.show;
      }
    }
  }
Example #8
Source File: i18n.service.ts    From avid-covider with MIT License 5 votes vote down vote up
constructor(@Inject(LOCALE_ID) public locale: string, private storage: ReportStoreService) {
    this.ltr = locale === 'en' || locale === 'es' || locale === 'ru' || locale === 'fr';
    this.storage.device.locale = this.locale;
  }
Example #9
Source File: pb-date-pipe.ts    From protobuf-ts with Apache License 2.0 5 votes vote down vote up
constructor(@Inject(LOCALE_ID) private readonly locale: string) {
  }
Example #10
Source File: fims-date.pipe.ts    From digital-bank-ui with Mozilla Public License 2.0 5 votes vote down vote up
constructor(@Inject(LOCALE_ID) locale: string) {
    super(locale);
  }
Example #11
Source File: app.module.ts    From open-genes-frontend with Mozilla Public License 2.0 5 votes vote down vote up
@NgModule({
  declarations: [
    AppComponent,
    HeaderComponent,
    FooterComponent,
    LanguageComponent,
    BurgerMenuComponent,
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot(APP_ROUTES, ROUTER_OPTIONS),
    HttpClientModule,
    // ngx-translate and the loader module
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: httpLoaderFactory,
        deps: [HttpClient],
      },
    }),
    BrowserAnimationsModule,
    MaterialModule,
    IconModule,
    GoogleAnalyticsModule,
    DirectivesModule,
    TermHintModule,
    SnackBarModule,
    UiComponentsModule,
  ],
  providers: [
    TranslateService,
    { provide: LOCALE_ID, useValue: 'en' },
    {
      provide: HTTP_INTERCEPTORS,
      useClass: HttpReqInterceptor,
      multi: true,
    },
    { provide: MatPaginatorIntl, useClass: CustomMatPaginatorIntl },
  ],
  exports: [MaterialModule],
  bootstrap: [AppComponent],
})
export class AppModule {}
Example #12
Source File: app.module.ts    From onchat-web with Apache License 2.0 5 votes vote down vote up
@NgModule({
  declarations: [
    AppComponent,
    RtcComponent,
    NotificationComponent,
  ],
  imports: [
    RippleModule,
    SharedModule,
    ActiveClassModule,
    OverlayModule,
    BrowserAnimationsModule,
    BrowserModule,
    HammerModule,
    ReactiveFormsModule,
    FormsModule,
    HttpClientModule,
    AppRoutingModule,
    IonicModule.forRoot({
      mode: 'ios',
      backButtonText: '',
      backButtonIcon: 'chevron-back-outline'
    }),
    SocketioModule.forRoot({
      url: '',
      options: {
        path: environment.socketioPath,
        autoConnect: false,
        transports: ['websocket'] // 只使用WebSocket连接
      }
    }),
    QuillModule.forRoot({
      placeholder: '在此处插入文字…'
    }),
    ServiceWorkerModule.register('ngsw-worker.js', {
      enabled: environment.production,
      registrationStrategy: 'registerImmediately'
    })
  ],
  providers: [
    { provide: LOCALE_ID, useValue: 'zh-Hans' },
    { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: CacheInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: BaseInterceptor, multi: true },
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
    { provide: ErrorHandler, useClass: GlobalErrorHandler }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
Example #13
Source File: i18n.service.ts    From open-source with MIT License 5 votes vote down vote up
constructor(
    @Inject(LOCALE_ID) private locale: string,
  ) {}
Example #14
Source File: analysis.component.ts    From one-platform with MIT License 5 votes vote down vote up
constructor(
    private router: ActivatedRoute,
    private dashboardService: DashboardService,
    private titleCasePipe: TitleCasePipe,
    @Inject(LOCALE_ID) private locale: string
  ) {}
Example #15
Source File: header.component.ts    From avid-covider with MIT License 5 votes vote down vote up
constructor(@Inject(LOCALE_ID) public locale) { }
Example #16
Source File: city-results.component.ts    From avid-covider with MIT License 5 votes vote down vote up
constructor(@Inject(LOCALE_ID) private locale, public mapService: MapService) {
    this.mapService.configStream.pipe(first()).subscribe((config: any) => {
      this.ready = true;
    });
  }
Example #17
Source File: app.component.ts    From avid-covider with MIT License 5 votes vote down vote up
constructor(@Inject(LOCALE_ID) private locale, private appinstall: AppinstallService) {
    console.log('LOCALE=', locale);
  }
Example #18
Source File: app.module.ts    From EXOS-Core with MIT License 5 votes vote down vote up
@NgModule({
    declarations: [
    ],
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        FormsModule,
        HttpClientModule,
        MaterialModule,
        RootModule,
        DashboardModule,
        NotificationsModule,
        WalletModule,
        SettingsModule,
        LoginModule,
        LogoutModule,
        SwapsModule,
        AboutModule,
        AppSharedModule,
        LoadModule,
        NetworkModule,
        NotFoundModule,
        ReportModule,
        UpdateModule,
        DetailsModule,
        WexoDetailsModule,
        AdvancedModule,
        ToolsModule,
        HistoryModule,
        AppRoutingModule,
        FlexLayoutModule,
    ],
    exports: [
    ],
    providers: [
        HttpErrorHandler,
        httpInterceptorProviders,
        // ApiService,
        // HubService,
        // ChainService,
        ElectronService,
        // GlobalService,
        { provide: APP_TITLE, useValue: 'EXOS Core' },
        {
            provide: LOCALE_ID,
            deps: [LocaleService],
            useFactory: (Locale: { locale: any; }) => Locale.locale
        }
    ],
    bootstrap: [RootComponent]
})
export class AppModule {
    constructor(theming: Theming, log: Logger) {
        log.info('Environment: ' + environment.environment);
        theming.start();
    }
}
Example #19
Source File: timeline-score-formater.pipe.ts    From one-platform with MIT License 5 votes vote down vote up
constructor(@Inject(LOCALE_ID) private locale: string) {}