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

ngx-translate-multi-http-loader

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-translate-multi-http-loader - npm Package Compare versions

Comparing version 8.0.2 to 9.0.0

esm2020/lib/multi-http-loader.mjs

58

package.json
{
"name": "ngx-translate-multi-http-loader",
"version": "8.0.2",
"version": "9.0.0",
"license": "MIT",
"author": "Raphael Balet",
"maintainers": [
"denniske.npm@gmail.com"
"raphael.balet@outlook.com"
],
"peerDependencies": {
"@angular/common": "^14.0.0",
"@angular/core": "^14.0.0"
"keywords": [
"angular",
"i18n",
"transalte",
"ngx-translate"
],
"homepage": "https://github.com/rbalet/ngx-translate-multi-http-loader#readme",
"bugs": {
"url": "https://github.com/rbalet/ngx-translate-multi-http-loader/issues"
},
"repository": {
"url": "https://github.com/rbalet/ngx-translate-multi-http-loader"
},
"dependencies": {
"@angular/common": ">=14.0.0",
"@angular/core": ">=14.0.0",
"tslib": "^2.4.0"
},
"peerDependencies": {
"@angular/common": ">=12.0.0",
"@angular/core": ">=12.0.0",
"@ngx-translate/core": ">=14.0.0",
"deepmerge": ">=4.2.2",
"rxjs": ">=7.4.0",
"tslib": ">=2.0.0"
"rxjs": "7.5.7"
},
"devDependencies": {
"typescript": ">=4.4.3"
"module": "fesm2015/ngx-translate-multi-http-loader.mjs",
"es2020": "fesm2020/ngx-translate-multi-http-loader.mjs",
"esm2020": "esm2020/ngx-translate-multi-http-loader.mjs",
"fesm2020": "fesm2020/ngx-translate-multi-http-loader.mjs",
"fesm2015": "fesm2015/ngx-translate-multi-http-loader.mjs",
"typings": "index.d.ts",
"exports": {
"./package.json": {
"default": "./package.json"
},
".": {
"types": "./index.d.ts",
"esm2020": "./esm2020/ngx-translate-multi-http-loader.mjs",
"es2020": "./fesm2020/ngx-translate-multi-http-loader.mjs",
"es2015": "./fesm2015/ngx-translate-multi-http-loader.mjs",
"node": "./fesm2015/ngx-translate-multi-http-loader.mjs",
"default": "./fesm2020/ngx-translate-multi-http-loader.mjs"
}
},
"main": "dist/multi-http-loader.js",
"types": "dist/multi-http-loader.d.ts",
"files": [
"/dist"
]
}
"sideEffects": false
}
# @ngx-translate/multi-http-loader [![npm version](https://badge.fury.io/js/ngx-translate-multi-http-loader.svg)](https://badge.fury.io/js/ngx-translate-multi-http-loader)
A loader for [ngx-translate](https://github.com/ngx-translate/core) that loads translations using http.
Angular 13 example: https://github.com/denniske/ngx-translate-multi-http-loader-demo
Angular 6 example: https://stackblitz.com/edit/ngx-translate-multi-http-loader-sample
Angular 13 example: https://github.com/denniske/ngx-translate-multi-http-loader-demo
Get the complete changelog here: https://github.com/denniske/ngx-translate-multi-http-loader/releases

@@ -14,2 +15,6 @@

## breaking change: v9.0.0
* This library is now using `httpBackend` instead of the `httpClient`, to avoid being delayed by interceptor, which was creating errors while loading.
* From the v9, the library will only be using a list of `string[]` so `prefix` & `suffix` aren't needed anymore and `.json` gonna be the default suffix.
## Installation

@@ -27,28 +32,25 @@

Angular | @ngx-translate/core | ngx-translate-multi-http-loader
----------- |---------------------| --------------------------
14 | 14.x+ | 8.x+
13 | 14.x+ | 7.x+
6 | 10.x+ | 1.x+
| Angular | @ngx-translate/core | ngx-translate-multi-http-loader |
| ------- | ------------------- | ------------------------------- |
| 14 | 14.x+ | 8.x+ |
| 13 | 14.x+ | 7.x+ |
| 6 | 10.x+ | 1.x+ |
## Usage
#### 1. Setup the `TranslateModule` to use the `MultiTranslateHttpLoader`:
_The `MultiTranslateHttpLoader` uses HttpBackend to load translations, therefore :_
1. Create and export a new `HttpLoaderFactory` function
2. Import the `HttpClientModule` from `@angular/common/http`
3. Setup the `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`:
```ts
```typescript
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {HttpClientModule, HttpClient} from '@angular/common/http';
import {HttpClientModule, HttpBackend} from '@angular/common/http';
import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
import {MultiTranslateHttpLoader} from "ngx-translate-multi-http-loader";
import {AppComponent} from "./app";
import {MultiTranslateHttpLoader} from 'ngx-translate-multi-http-loader';
import {AppComponent} from './app';
// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient) {
return new MultiTranslateHttpLoader(http, [
{prefix: "./assets/translate/core/", suffix: ".json"},
{prefix: "./assets/translate/shared/", suffix: ".json"},
]);
export function HttpLoaderFactory(_httpBackend: HttpBackend) {
return new MultiTranslateHttpLoader(_httpBackend, ['/assets/i18n/core/', '/assets/i18n/vendors/']);
}

@@ -64,3 +66,3 @@

useFactory: HttpLoaderFactory,
deps: [HttpClient]
deps: [HttpBackend]
}

@@ -74,21 +76,11 @@ })

The `MultiTranslateHttpLoader` takes a list of translation file configurations. Each configuration has two optional parameters:
- prefix: string = "/assets/translate/"
- suffix: string = ".json"
The `MultiTranslateHttpLoader` takes a list of strings.
By using those default parameters, it will load your translations files for the lang "en" from: `/assets/translate/en.json`.
Those strings, for example `['/assets/i18n/core/', '/assets/i18n/vendors/']`,
will load your translations files for the lang "en" from : `/assets/i18n/core/en.json` and `/assets/i18n/vendors/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 `/assets/translate/core/en.json` and `/assets/translate/shared/en.json` you would use:
```ts
export function HttpLoaderFactory(http: HttpClient) {
return new MultiTranslateHttpLoader(http, [
{prefix: "./assets/translate/core/", suffix: ".json"},
{prefix: "./assets/translate/shared/", suffix: ".json"},
]);
}
```
The loader will merge all translation files from the server using [deepmerge](https://github.com/KyleAMathews/deepmerge).
For now this loader only support the json format.
The loader will merge all translation files from the server using [deepmerge](https://github.com/KyleAMathews/deepmerge).
## Authors and acknowledgment
* Former maintainer [Dennis Keil](https://github.com/denniske)
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