import 'rxjs/add/operator/map'; import { Injectable, NgZone } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { Router, ActivatedRoute } from '@angular/router'; @Injectable() export class LocalizedRouterService { constructor(private readonly translate: TranslateService, private route: ActivatedRoute, private router: Router, private zone: NgZone) { } go(route: string, additionalParams?: string) { const translatedUrl = `/${route.split('/').map(segment => { return this.translate.instant(segment); }).join('/')}`; this.zone.run(() => { this.router.navigate([translatedUrl], { relativeTo: this.route, queryParams: { data: additionalParams } }); }); } url() { return this.router.url; } }