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.

URL not translated to non default language?

See original GitHub issue

Hello,

I have followed the sample usage configuration with the following routes.


export const appRoutes: Routes = [
    {
        path: 'about-us',
        component: AboutUsComponent,
    },
    {
        path: '',
        redirectTo: 'about-us',
        pathMatch: 'full'
    },
    {path: '**', component: PageNotFoundComponent}
];

on my translation files

en.json

{
    "ROUTES": {
        "about-us": "about-us"
    }
}

es.json

{
    "ROUTES": {
        "about-us": "acerca-de"
    }
}

and on the localizeRouterHttpLoader json

{
    "locales": ["en", "es"]
}

The routes /en/about-us and /es/about-uswork and change the language accordingly but the route/es/acerca-de` is not found.

Is this expected behaviour? Is this library supposed to translate paths too or simply add a prefix to whatever path the route declares to toggle a language change?

In case it might matter, I am in my AppComponent setting the default language to english too.

Cheers, Joel.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
meeroslavcommented, Sep 27, 2017

Hi @lifenautjoe,

Your path es/acerca-de should work. If you are setting the default language in AppComponent that would most likely override settings from LocalizeRouter and could cause this behaviour. Try to use LocalizeRouter to set your default language. Check docs for more information on how default language setting works.

If that doesn’t help, please create plunkr or provide link to repo so I can check it in your code.

1reaction
lifenautjoecommented, Sep 27, 2017

Hi @meeroslav,

I made the Plunkr 🎉 .

I can reproduce the same issue in there as you will see when trying to go to the spanish version of a page and found another issue:

When the language changes, the page url doesnt get re-evaluated. If this is not desired functionality, what are we to do when the user selects another language? How can we send them to the page they are currently but in another language? So from en/about-us to es/acerca-de

Here’s the plunkr with both issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fallback to default language when node not translated to ...
The default language is English. Mostly, the author will be translating the articles to Japanese and sometimes no translation.
Read more >
Default Language is not pointing to site original URLs.
Hi. I have set up English as the default language for this site. However, after I selected the second language (Chinese in this...
Read more >
Redirect and switch to default language if no translation exists
We want to use language path prefix in the URLs for pages with majority-translated content. On these pages we wish to re-direct users...
Read more >
Language URL format options - WPML
WPML gives you the option of formatting your language URLs in domains, directories, or as parameters. Learn how it works and find what's...
Read more >
If translation does not exist, link to default language?
modify your code of your navigation, check the language specific status of the page you want to add to the nav. · via...
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