【发布时间】:2018-05-15 16:57:38
【问题描述】:
我有网站https://www.mobydisc.de/。它有 DE 和 EN 版本。当我从浏览器访问该站点时,该站点的所有内容都在DE。
当我使用https://www.google.com/webmasters/tools/googlebot-fetch-details 查看网站时,内容位于DE,但菜单位于EN。
我该如何解决?
设置:
LANGUAGE_CODE = 'de'
TIME_ZONE = 'Europe/Berlin'
USE_I18N = True
USE_L10N = True
USE_TZ = True
CMS_LANGUAGES = {
1: [
{
'code': 'de',
'name': gettext('Deutsch'),
'fallbacks': ['en'],
'public': True,
},
{
'code': 'en',
'name': gettext('English'),
'fallbacks': ['de'],
'public': True,
'hide_untranslated': True,
'redirect_on_fallback':False,
},
],
'default': {
'fallbacks': ['de'],
'redirect_on_fallback':True,
'public': True,
'hide_untranslated': False,
}
}
LANGUAGES = [
('de', 'Deutsch'),
('en', 'English'),
]
过滤器:
@register.filter(name="get_menu_title_without_mega")
def get_menu_title_without_mega(text):
if megamenu(text):
# print("mega remove")
regexp = re.compile("[ ]+mega[0-9]+$", re.MULTILINE)
# print(text,regexp.sub("",text))
return regexp.sub("",text)
else:
return text`
【问题讨论】:
-
你能贴出模板中呈现菜单的部分吗? (包括菜单标签使用的任何自定义菜单模板)
-
@markwalker_ 这里gist.github.com/mki/1b722c54da5fcdcf970ae50fd966cae2
-
那么
get_menu_title_without_mega是做什么的?这是在不使用gettext的情况下返回字符串吗? -
@markwalker_在问题处添加
get_menu_title_without_mega的代码
标签: django django-cms