Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ngx-translate/core

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngx-translate/core

The internationalization (i18n) library for Angular

  • 10.0.2
  • npm
  • Socket score

Version published
Weekly downloads
809K
decreased by-21.15%
Maintainers
1
Weekly downloads
 
Created

What is @ngx-translate/core?

@ngx-translate/core is an internationalization (i18n) library for Angular applications. It allows developers to easily translate their applications into different languages and manage translations dynamically.

What are @ngx-translate/core's main functionalities?

Basic Translation

This feature allows you to set a default language and use a specific language for translations. The 'translate' pipe is used in the template to translate keys.

import { TranslateService } from '@ngx-translate/core';

constructor(private translate: TranslateService) {
  this.translate.setDefaultLang('en');
  this.translate.use('en');
}

// In your template
// <p>{{ 'HELLO' | translate }}</p>

Dynamic Language Switching

This feature allows users to switch languages dynamically at runtime. The 'use' method of TranslateService is used to change the language.

import { TranslateService } from '@ngx-translate/core';

constructor(private translate: TranslateService) {}

switchLanguage(language: string) {
  this.translate.use(language);
}

// In your template
// <button (click)="switchLanguage('en')">English</button>
// <button (click)="switchLanguage('fr')">French</button>

Loading Translations from JSON Files

This feature allows you to load translations from external JSON files. The TranslateHttpLoader is used to load translation files from a server.

import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { HttpClient } from '@angular/common/http';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

export function HttpLoaderFactory(http: HttpClient) {
  return new TranslateHttpLoader(http);
}

@NgModule({
  imports: [
    HttpClientModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [HttpClient]
      }
    })
  ]
})
export class AppModule {}

Translation Parameters

This feature allows you to pass parameters to translation strings. The parameters can be used to dynamically insert values into the translated text.

import { TranslateService } from '@ngx-translate/core';

constructor(private translate: TranslateService) {}

// In your template
// <p>{{ 'HELLO_USER' | translate: { value: 'John' } }}</p>

Other packages similar to @ngx-translate/core

Keywords

FAQs

Package last updated on 22 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc