[FIX] website: alternate languages translated URL
The alternate languages links set in the page `<head>` were not translated in each language, but within the language the user is browsing the website. This leaded to SEO referencing issues, as these links leaded to (30x) redirections if followed, to translate the URL slug within the new current language. e.g. `/fr_FR/shop/product/bose-mini-bluetooth-speaker-7` automatically redirected to `/fr_FR/shop/product/mini-haut-parleur-bluetooth-bose-7` And it was the first link which was displayed as alternate link when being in another language than French, while it should be the second (to avoid the useless redirection). opw-669979
This commit is contained in:
parent
3913667396
commit
2ba7fa3c9d
|
@ -241,14 +241,22 @@ class website(osv.osv):
|
|||
if req is None:
|
||||
req = request.httprequest
|
||||
default = self.get_current_website(cr, uid, context=context).default_lang_code
|
||||
uri = req.path
|
||||
if req.query_string:
|
||||
uri += '?' + req.query_string
|
||||
shorts = []
|
||||
|
||||
def get_url_localized(router, lang):
|
||||
arguments = dict(request.endpoint_arguments)
|
||||
for k, v in arguments.items():
|
||||
if isinstance(v, orm.browse_record):
|
||||
arguments[k] = v.with_context(lang=lang)
|
||||
return router.build(request.endpoint, arguments)
|
||||
router = request.httprequest.app.get_db_router(request.db).bind('')
|
||||
for code, name in self.get_languages(cr, uid, ids, context=context):
|
||||
lg_path = ('/' + code) if code != default else ''
|
||||
lg = code.split('_')
|
||||
shorts.append(lg[0])
|
||||
uri = request.endpoint and get_url_localized(router, code) or request.httprequest.path
|
||||
if req.query_string:
|
||||
uri += '?' + req.query_string
|
||||
lang = {
|
||||
'hreflang': ('-'.join(lg)).lower(),
|
||||
'short': lg[0],
|
||||
|
|
Loading…
Reference in New Issue