This repository was archived by the owner on Nov 8, 2021. It is now read-only.
Load translations with promise, to allow preloading#30
Open
baso10 wants to merge 1 commit intongx-translate:masterfrom
Open
Load translations with promise, to allow preloading#30baso10 wants to merge 1 commit intongx-translate:masterfrom
baso10 wants to merge 1 commit intongx-translate:masterfrom
Conversation
tiaguinho
suggested changes
Mar 13, 2018
src/http-loader.ts
Outdated
| import {HttpClient} from "@angular/common/http"; | ||
| import {TranslateLoader} from "@ngx-translate/core"; | ||
| import "rxjs/add/operator/map"; | ||
| import {Observable} from 'rxjs/Rx'; |
There was a problem hiding this comment.
Change the import to 'rxjs/Observable'.
src/http-loader.ts
Outdated
| */ | ||
| public preLoad(lang: string): Promise<any> { | ||
| return new Promise((resolve, reject) => { | ||
| this.http.get(`${this.prefix}${lang}${this.suffix}`) |
There was a problem hiding this comment.
I think you can change the signature to:
get().subscribe(
result => ()....,
error => ()....
);There was a problem hiding this comment.
in this case better to use:
public preLoad(lang: string): Promise<any> {
return this.httpClient.get(`${this.prefix}${lang}${this.suffix}`)
.toPromise()
.then(result => {
this.loadedTranslations[lang] = result;
return result;
})
.catch(() => null);
}|
@baso10 Can you make this changes? |
tiaguinho
approved these changes
Mar 16, 2018
|
Guys, any updates? |
|
Still no updates on this? |
tiaguinho
suggested changes
Jan 13, 2019
src/http-loader.ts
Outdated
| @@ -1,7 +1,10 @@ | |||
| import {HttpClient} from "@angular/common/http"; | |||
| import {TranslateLoader} from "@ngx-translate/core"; | |||
| import {Observable} from 'rxjs/Observable'; | |||
|
Can we push it? |
|
@baso10 please make the changes on import and request as @akaNightmare has suggested so we can merge this into master. |
tiaguinho
approved these changes
Jul 6, 2020
|
Guys, come on :D |
|
@ocombe can you merge this? |
|
We would really need this feature guys :D |
|
ping... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With APP_INITIALIZER and Promise we can load translations before app is started.
Usage example: