Core: use different directories for translation files

Created on 26 Jan 2018  路  4Comments  路  Source: ngx-translate/core

I'm using ngx-translate to translate buttons, headers, ... in my app and this works fine. My translation files are in the /assets/i18n/ folder.

Now I have mockdata which I also have to translate, but my mockdata is in another directory -> /assets/data/

To load my json translations files from the i18n folder I use:

export function setTranslateLoader(http: HttpClient) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

but now I also want to load the files from the data directory.

How can I achieve that?

  • ngx-translate version: 8.0.0

  • Angular version: 4.4.3

Most helpful comment

In plunker the "root file" is not as in classic angular app
You must add "src"
{prefix: './assets/i18n/', suffix: '.json'} besome
{prefix: './src/assets/i18n/', suffix: '.json'}

All 4 comments

Hey,
Solution here : issues 199

Hi, thanks for your answer. I tried this code but i dont really get it to work.
can you take a look at my plunker?
https://plnkr.co/edit/K2dZuYAREvOA48sm66N9?p=info

Hey,

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/forkJoin';
Observable.forkJoin(...)

fail in error... as if angular can't find Observable import.
You can force it via :

import Rx from 'rxjs/Rx';
Rx.Observable.forkJoin(...)

In plunker the "root file" is not as in classic angular app
You must add "src"
{prefix: './assets/i18n/', suffix: '.json'} besome
{prefix: './src/assets/i18n/', suffix: '.json'}

Was this page helpful?
0 / 5 - 0 ratings