@ngx-translate/http-loader#TranslateHttpLoader TypeScript Examples
The following examples show how to use
@ngx-translate/http-loader#TranslateHttpLoader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: test.utils.ts From WowUp with GNU General Public License v3.0 | 6 votes |
export function testHttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, "./assets/i18n/", ".json");
}
Example #2
Source File: file.translate.loader.ts From geonetwork-ui with GNU General Public License v2.0 | 6 votes |
/**
* This loader will rely on JSON files in the app assets, as well as an app config
* if one was loaded (for custom translations)
* Implements a fallback on default lang if translated labels are empty
*/
@Injectable({
providedIn: 'root',
})
export class FileTranslateLoader extends TranslateHttpLoader {
getTranslation(lang: string) {
const baseLang = lang.substr(0, 2) // removing the right part of e.g. en_EN
return super.getTranslation(baseLang).pipe(
map(this.transform),
map((translations) => {
if (isConfigLoaded()) {
return { ...translations, ...getCustomTranslations(baseLang) }
}
return translations
})
)
}
private transform(translations) {
// filter out empty keys: this should let us fallback on the default lang or
// untranslated key, instead of having a blank space
return Object.keys(translations).reduce(
(prev, curr) =>
translations[curr].trim().length
? { ...prev, [curr]: translations[curr] }
: prev,
{}
)
}
}
Example #3
Source File: app.module.ts From bitcoin-s-ts with MIT License | 5 votes |
// AoT requires an exported function for factories
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json')
}
Example #4
Source File: app.module.ts From dev-manager-desktop with Apache License 2.0 | 5 votes |
// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
Example #5
Source File: app.module.ts From casual-chess with GNU General Public License v3.0 | 5 votes |
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
Example #6
Source File: admin.module.ts From spurtcommerce with BSD 3-Clause "New" or "Revised" License | 5 votes |
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, 'assets/i18n/');
}
Example #7
Source File: app.module.ts From ledge with Mozilla Public License 2.0 | 5 votes |
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
Example #8
Source File: examples.module.ts From enterprise-ng-2020-workshop with MIT License | 5 votes |
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(
http,
`${environment.i18nPrefix}/assets/i18n/examples/`,
'.json'
);
}
Example #9
Source File: core.module.ts From enterprise-ng-2020-workshop with MIT License | 5 votes |
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(
http,
`${environment.i18nPrefix}/assets/i18n/`,
'.json'
);
}
Example #10
Source File: app.module.ts From open-genes-frontend with Mozilla Public License 2.0 | 5 votes |
httpLoaderFactory = (http: HttpClient): TranslateHttpLoader =>
new TranslateHttpLoader(http, '/assets/i18n/', `.json?v=${new Date().getTime()}`)
Example #11
Source File: app.module.ts From tabby with MIT License | 5 votes |
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
Example #12
Source File: app.module.ts From litefy with MIT License | 5 votes |
// AOT compilation support
export function httpTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
}
Example #13
Source File: features.module.ts From coronatest with GNU Affero General Public License v3.0 | 5 votes |
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
}
Example #14
Source File: app.module.ts From coronatest with GNU Affero General Public License v3.0 | 5 votes |
// required for AOT compilation
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
}
Example #15
Source File: shared.module.ts From mns with MIT License | 5 votes |
// AoT requires an exported function for factories
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient);
}
Example #16
Source File: app.module.ts From Smersh with MIT License | 5 votes |
// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http);
}
Example #17
Source File: app.module.ts From bitcoin-s-ts with MIT License | 5 votes |
// AoT requires an exported function for factories
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json')
}
Example #18
Source File: app.module.ts From t3mpl-editor with MIT License | 5 votes |
export function HttpLoaderFactory(httpClient: HttpClient) {
return new TranslateHttpLoader(httpClient, 'assets/i18n/');
}
Example #19
Source File: test-helpers.ts From WowUp with GNU General Public License v3.0 | 5 votes |
// AoT requires an exported function for factories
export function httpLoaderFactoryTest(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, "./assets/i18n/", ".json");
}
Example #20
Source File: app.module.ts From WowUp with GNU General Public License v3.0 | 5 votes |
// AoT requires an exported function for factories
export function httpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, "./assets/i18n/", ".json");
}
Example #21
Source File: app.module.ts From VIR with MIT License | 5 votes |
// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, './assets/i18n/', '.json')
}
Example #22
Source File: app.module.ts From ionic-doctor-online with MIT License | 5 votes |
// The translate loader needs to know where to load i18n files
// in Ionic's static asset pipeline.
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
Example #23
Source File: app.module.ts From msfs-community-downloader with GNU Affero General Public License v3.0 | 5 votes |
// AoT requires an exported function for factories
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
Example #24
Source File: app.module.ts From mylog14 with GNU General Public License v3.0 | 5 votes |
export function LanguageLoader(http: HttpClient) {
return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
}
Example #25
Source File: layout.module.ts From dbm with Apache License 2.0 | 5 votes |
httpLoaderFactory = (http: HttpClient): TranslateHttpLoader =>
new TranslateHttpLoader(http, './renderer/assets/i18n/', '.json')
Example #26
Source File: app.loaders.ts From rubic-app with GNU General Public License v3.0 | 5 votes |
export function httpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', `.json?_t=${new Date().getTime()}`);
}
Example #27
Source File: translation.module.ts From xBull-Wallet with GNU Affero General Public License v3.0 | 5 votes |
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http);
}