Skip to content
Permalink
Browse files

[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.
  • Loading branch information...
JKE-be committed Sep 27, 2017
1 parent 2575950 commit 953a693df1284f2292237e3479a210ba28e6f9bf
Showing with 5 additions and 2 deletions.
  1. +4 −2 addons/http_routing/models/ir_http.py
  2. +1 −0 addons/website/models/website.py
@@ -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 @@ def _dispatch(cls):

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()
@@ -50,6 +50,7 @@ def _default_language(self):
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")

0 comments on commit 953a693

Please sign in to comment.
You can’t perform that action at this time.