ngx-translate-router icon indicating copy to clipboard operation
ngx-translate-router copied to clipboard

Get Translated Route of a different language than the current one

Open mmsergi opened this issue 3 years ago • 3 comments

Hi! I want to set up some SEO tags for different langs like:

<link rel="alternate" hreflang="en" href="https://www.example.co/en/blog">
<link rel="alternate" hreflang="es" href="https://www.example.co/es/blog">

The unique method that seems to exist is "translateRoute" but only returns the current lang url.

My problem is I can't access at the same time to both href (url), is there a way to get it?

Thanks community.

mmsergi avatar Jun 29 '21 11:06 mmsergi

This feature looks interesting. Have you found a workaround?

gilsdav avatar Nov 29 '21 15:11 gilsdav

I am also looking for a way to achieve this. What is needed from my perspective is a method that returns the current url in a language provided by param, like this.localizeRouterService.translateCurrentUrl('en)

As far as I have seen, method changeLanguage does something similar, but also changes the language and navigates.

Would it be possible to implement

  • a method that provides the current, untranslated route
  • an additional, optional param "lang" to method translateRoute so we can translate a route into any language

in LocalizeRouterService ?

romankh avatar Dec 10 '21 12:12 romankh

Is there any plans on implementing this?

motiejunas avatar Jan 10 '23 16:01 motiejunas