question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

combine with ng2-translate

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
fulls1z3commented, Mar 7, 2017

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.

0reactions
fulls1z3commented, Mar 14, 2017

Released, you can install it via npm. Also, check the documentation and @nglibs/example-app for in-depth examples.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found