
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
ngx-translate-multi-http-loader
Advanced tools
A loader for ngx-translate that loads translations from multiple files using http
A loader for ngx-translate that loads translations using http.
Simple example using ngx-translate: https://stackblitz.com/github/ngx-translate/example
Get the complete changelog here: https://github.com/ngx-translate/multi-http-loader/releases
We assume that you already installed ngx-translate.
Now you need to install the npm module for MultiTranslateHttpLoader
:
npm install @ngx-translate/multi-http-loader --save
Choose the version corresponding to your Angular version:
Angular | @ngx-translate/core | @ngx-translate/multi-http-loader |
---|---|---|
6 | 10.x+ | 3.x+ |
5 | 8.x to 9.x | 1.x to 2.x |
4.3 | 7.x or less | 1.x to 2.x |
2 to 4.2.x | 7.x or less | 0.x |
TranslateModule
to use the MultiTranslateHttpLoader
:The MultiTranslateHttpLoader
uses HttpClient to load translations, which means that you have to import the HttpClientModule from @angular/common/http
before the TranslateModule
:
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {HttpClientModule, HttpClient} from '@angular/common/http';
import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/multi-http-loader';
import {AppComponent} from "./app";
// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
}
@NgModule({
imports: [
BrowserModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
})
],
bootstrap: [AppComponent]
})
export class AppModule { }
The MultiTranslateHttpLoader
also has two optional parameters:
By using those default parameters, it will load your translations files for the lang "en" from: /assets/i18n/en.json
.
You can change those in the HttpLoaderFactory
method that we just defined. For example if you want to load the "en" translations from /public/lang-files/en-lang.json
you would use:
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, "/public/lang-files/", "-lang.json");
}
For now this loader only support the json format.
FAQs
Unknown package
The npm package ngx-translate-multi-http-loader receives a total of 44,493 weekly downloads. As such, ngx-translate-multi-http-loader popularity was classified as popular.
We found that ngx-translate-multi-http-loader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.