mardi 6 février 2018

Ember.js re-render links on locale change

My application uses the ember-i18n addon. For SEO purposes, I wanted to put a /[lang-code]/ in the URL.

When changing the language, history.pushState can change the URL and its alright, but the links on the page do not change for the new language, even though router.rootURL is changed.

So far I can just change the window.location.pathname, but thus a new network request is being made.

I tried overriding the href-to helper (from ember-href-to addon) and added this:

_recomputeOnLocaleChange: Ember.observer('i18n.locale', function() {
    console.log("here?");
    this.recompute();
})  

It executes on locale change, but apparently recompute does nothing. Even with setTimeout (because perhaps rootURL didn't change yet). Links are all the same.

Can you suggest anything? Would be greatly appreciated! Thank you!!




Aucun commentaire:

Enregistrer un commentaire