combine with ng2-translate
See original GitHub issueI’m submitting a … (check one with “x”)
[ ] bug report => check the README and search github for a similar issue or PR before submitting
[x] support request => check the README and search github for a similar issue or PR before submitting
[ ] feature request
Hi, I want to combine ng2-metadata with ng2-translate. Their TranslateService#get(key: string|Array<string>, interpolateParams?: Object): Observable<string|Object>
is async. What i came up with is a MetadataResole
class that looks like this:
@Injectable()
export class MetadataResolve implements Resolve<any> {
constructor(private translate: TranslateService, private metadataService: MetadataService) {
}
resolve(route: ActivatedRouteSnapshot) {
return this.translate.get((route.data as any).m3tadata.title).toPromise().then(v => {
this.metadataService.setTitle(v);
});
}
}
and is being used like this:
{
path: 'signup',
component: SignupC,
canActivate: [LoggedOutG],
data: {m3tadata: {title: 'AUTH.SIGNUP_P.TITLE'}},
resolve: {metadata: MetadataResolve}
},
Now, this is working. But it looks ugly, do u know of any better way? @fulls1z3
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
ngx-i18n-combine - npm
Merge i18n files from components and merge to common locale files. Latest version: 1.2.0, last published: a year ago.
Read more >ng2-translate customLoader & multiple files per language
I thought "merge" should merge together the observables, creating one "big" observable stream with all the data. ionic2 · rxjs · observable ...
Read more >How to translate your Angular app with ngx-translate
1. Add ngx-translate to your Angular application 2. Set up the TranslateService in your app.module.ts 3. Create your main language translation file (in...
Read more >Ng2-translate | npm.io
ngx-translate extension to facilitate language cache. angularangular2ng2-translatengx-translatetranslatetranslationi18n. 9.0.2 • Published 3 years ago. ngx ...
Read more >How To Use ngx-translate with Angular - DigitalOcean
Creating the translation loader in this way expects you to have a file in your project under an /assets/i18n/ folder, called {lang}.json ,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @tsm91, @Chuvisco88.
I know it’s been quite long time, but I’ve been busy with other projects as well as resolving issues with higher priority. I’ve succeeded developing a loader which uses the
TranslateService
and refactoring @nglibs/meta to use observables.Currently writing unit tests. I think within a day or two, this feature will be OK and included by rc.4.
Released, you can install it via npm. Also, check the documentation and @nglibs/example-app for in-depth examples.