Closed saidrkc closed 7 years ago
The flattenTranslations is a protected since 2.2.1 (yesterday). You should not require the Http to be protected:
export class MyTranslationLoader extends TranslationLoaderJson {
constructor(private http: Http) {
super(http);
}
public load(): Promise<object> {
this.http....
}
}
Or did I miss something?
@Injectable()
export class MyTranslationLoader extends TranslationLoaderJson {
private translations;
constructor(private http: Http) {
super(http);
}
public load({language}: any): Promise<object> {
const headers = new Headers();
headers.append('responseType', 'arraybuffer');
const file = this.http.get( this.cdn + 'messages.es.json', headers)
.map((response: Response) =>
response.json())
.catch((error: any) => Observable.throw(error.json()));
file.subscribe((response: any) => {
this.translations['es'] = response;
});
console.log(this.translations);
if (!this.translations[language]) {
Promise.reject('Language unknown');
}
return Promise.resolve(this.translations[language]);
}
}
Error. Types have separate declarations of a private property 'http'
ok, that's bad, sorry. But you may want to extend TranslationLoader
instead. You are not using any TranslationLoaderJson specific stuff.
https://github.com/tflori/angular-translator/blob/master/src/TranslationLoader/Json.ts
As you can see there is only a load method and you overwrite it.
as there are no more comments I assume this is solved.
feel free to reopen if there is another problem with the private http property.
Hi, I want to extend TranslationLoaderJson and use http service. But is private and can't use it.
Thanks