[FIX] website, http_routing: fix translate on website.page

Before this commit:
website.page won't be rendered as translated items since it is not going though
 a controller (route) enabling multilang. Website.page were not considered as
 multilang items and no lang prefix were applied on link.

Now:
website.page will correcly handling translation.

In case of one route doesn't match a controller, it is now by default a route of
type multilang.

Add a new field auto_redirect_lang on website model to allow to deactive the
autoredirect of the lang optionnaly. The code will arrive after more tests.
This commit is contained in:
Jeremy Kersten
2017-09-27 21:33:50 +02:00
parent 257595011d
commit 953a693df1
2 changed files with 5 additions and 2 deletions
+4 -2
View File
@@ -170,7 +170,9 @@ def is_multilang_url(local_url, langs=None):
func = router.match(path, method='POST', query_args=query_string)[0]
return (func.routing.get('website', False) and
func.routing.get('multilang', func.routing['type'] == 'http'))
except Exception:
except werkzeug.exceptions.NotFound:
return True
except Exception as e:
return False
@@ -331,7 +333,7 @@ class IrHttp(models.AbstractModel):
request.is_frontend_multilang = (
request.is_frontend and
func and func.routing.get('multilang', func.routing['type'] == 'http')
(not func or (func and func.routing.get('multilang', func.routing['type'] == 'http')))
)
cls._geoip_setup_resolver()
+1
View File
@@ -50,6 +50,7 @@ class Website(models.Model):
language_ids = fields.Many2many('res.lang', 'website_lang_rel', 'website_id', 'lang_id', 'Languages', default=_active_languages)
default_lang_id = fields.Many2one('res.lang', string="Default Language", default=_default_language, required=True)
default_lang_code = fields.Char(related='default_lang_id.code', string="Default language code", store=True)
auto_redirect_lang = fields.Boolean('Autoredirect Language', default=True, help="Should users be redirected to their browser's language")
social_twitter = fields.Char(related="company_id.social_twitter")
social_facebook = fields.Char(related="company_id.social_facebook")