Commit 75c319a6 authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: do not activate translation if the erp5js site is a Web Section

Prevent generating wrong urls for now
parent 58ec853e
...@@ -171,7 +171,7 @@ default_url = './' ...@@ -171,7 +171,7 @@ default_url = './'
available_language_set = web_section.getLayoutProperty("available_language_set", default=['en']) available_language_set = web_section.getLayoutProperty("available_language_set", default=['en'])
default_language = web_section.getLayoutProperty("default_available_language", default='en') default_language = web_section.getLayoutProperty("default_available_language", default='en')
for language in available_language_set: for language in available_language_set:
if language == default_language: if (language == default_language) or (web_section.getPortalType() == 'Web Section'):
url_list.append(default_url) url_list.append(default_url)
else: else:
url_list.append('%s/' % language) url_list.append('%s/' % language)
......
...@@ -15,27 +15,32 @@ portal = context.getPortalObject() ...@@ -15,27 +15,32 @@ portal = context.getPortalObject()
default_language = web_section.getLayoutProperty("default_available_language", default='en') default_language = web_section.getLayoutProperty("default_available_language", default='en')
website_url_set = {} website_url_set = {}
#simplify code of Base_doLanguage, can't ues Base_doLanguage directly selected_language = portal.Localizer.get_selected_language()
root_website_url = web_section.getOriginalDocument().absolute_url()
website_url_pattern = r'^%s(?:%s)*(/|$)' % ( if (web_section.getPortalType() == 'Web Section'):
# do not allow language echange
website_url_set[selected_language] = web_section.absolute_url() + '/'
available_language_set = [selected_language]
else:
#simplify code of Base_doLanguage, can't ues Base_doLanguage directly
root_website_url = web_section.getOriginalDocument().absolute_url()
website_url_pattern = r'^%s(?:%s)*(/|$)' % (
re.escape(root_website_url), re.escape(root_website_url),
'|'.join('/' + re.escape(x) for x in available_language_set)) '|'.join('/' + re.escape(x) for x in available_language_set))
for language in available_language_set: for language in available_language_set:
if language == default_language: if language == default_language:
website_url_set[language] = re.sub(website_url_pattern, r'%s/\1' % root_website_url, web_section.absolute_url()) website_url_set[language] = re.sub(website_url_pattern, r'%s/\1' % root_website_url, web_section.absolute_url())
else: else:
website_url_set[language]= re.sub(website_url_pattern, r'%s/%s/\1' % (root_website_url, language), web_section.absolute_url()) website_url_set[language] = re.sub(website_url_pattern, r'%s/%s/\1' % (root_website_url, language), web_section.absolute_url())
view_as_web_method = default_web_page.getTypeBasedMethod( view_as_web_method = default_web_page.getTypeBasedMethod(
"viewAsWeb", "viewAsWeb",
fallback_script_id="WebPage_viewAsWeb" fallback_script_id="WebPage_viewAsWeb"
) )
selected_language = portal.Localizer.get_selected_language()
# base tag # base tag
if selected_language == default_language: if (selected_language == default_language) or (web_section.getPortalType() == 'Web Section'):
base_prefix = "" base_prefix = ""
else: else:
base_prefix = '../' base_prefix = '../'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment