diff --git a/src/ngx-translate-loaders/translate-browser.loader.ts b/src/ngx-translate-loaders/translate-browser.loader.ts index 85d59c96f0a..a1825f2f93b 100644 --- a/src/ngx-translate-loaders/translate-browser.loader.ts +++ b/src/ngx-translate-loaders/translate-browser.loader.ts @@ -34,7 +34,7 @@ export class TranslateBrowserLoader implements TranslateLoader { if (hasValue(messages)) { return observableOf(messages); } else { - const translationHash: string = environment.production ? `.${(process.env.languageHashes as any)[lang + '.json5']}` : ''; + const translationHash: string = environment.production ? `.${(environment["languageHashes"] !== undefined ? environment["languageHashes"] : process.env.languageHashes as any)[lang + '.json5']}` : ''; // If they're not available on the transfer state (e.g. when running in dev mode), retrieve // them using HttpClient return this.http.get(`${this.prefix}${lang}${translationHash}${this.suffix}`, { responseType: 'text' }).pipe( diff --git a/src/ngx-translate-loaders/translate-server.loader.ts b/src/ngx-translate-loaders/translate-server.loader.ts index 1f47dfe95b5..763f12dd16e 100644 --- a/src/ngx-translate-loaders/translate-server.loader.ts +++ b/src/ngx-translate-loaders/translate-server.loader.ts @@ -3,6 +3,7 @@ import { Observable, of as observableOf } from 'rxjs'; import { readFileSync } from 'fs'; import { TransferState } from '@angular/platform-browser'; import { NGX_TRANSLATE_STATE, NgxTranslateState } from './ngx-translate-state'; +import { environment } from "../environments/environment"; /** * A TranslateLoader for ngx-translate to parse json5 files server-side, and store them in the @@ -23,7 +24,7 @@ export class TranslateServerLoader implements TranslateLoader { * @param lang the language code */ public getTranslation(lang: string): Observable { - const translationHash: string = (process.env.languageHashes as any)[lang + '.json5']; + const translationHash: string = (environment["languageHashes"] !== undefined ? environment["languageHashes"] : process.env.languageHashes as any)[lang + '.json5']; // Retrieve the file for the given language, and parse it const messages = JSON.parse(readFileSync(`${this.prefix}${lang}.${translationHash}${this.suffix}`, 'utf8')); // Store the parsed messages in the transfer state so they'll be available immediately when the