[IMP] conf: show all relevant versions in the version switcher
From now on, the master branch and the latest released SaaS branch are always shown. SaaS branches are labeled "Odoo Online". The list of the versions shown in the switcher is hard-coded to force their ordering. The class `dropdown-toggle` is always added to the version|language switcher regardless of whether other versions|languages are available, as a quick fix to a CSS issue that occurs when the class is missing. closes odoo/documentation#1565 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
parent
5893edda93
commit
fb469b8211
52
conf.py
52
conf.py
@ -148,7 +148,19 @@ sphinx.transforms.i18n.docname_to_domain = (
|
|||||||
sphinx.util.i18n.docname_to_domain
|
sphinx.util.i18n.docname_to_domain
|
||||||
) = lambda docname, compact: docname.split('/')[1 if docname.startswith('applications/') else 0]
|
) = lambda docname, compact: docname.split('/')[1 if docname.startswith('applications/') else 0]
|
||||||
|
|
||||||
supported_languages = {
|
# The version names that should be shown in the version switcher, if the config option `versions`
|
||||||
|
# is populated. If a version is passed to `versions` but is not listed here, it will not be shown.
|
||||||
|
versions_names = {
|
||||||
|
'master': "master",
|
||||||
|
'saas-15.1': "Odoo Online",
|
||||||
|
'15.0': "Odoo 15",
|
||||||
|
'14.0': "Odoo 14",
|
||||||
|
'13.0': "Odoo 13",
|
||||||
|
}
|
||||||
|
|
||||||
|
# The language names that should be shown in the language switcher, if the config option `languages`
|
||||||
|
# is populated. If a language is passed to `languages` but is not listed here, it will not be shown.
|
||||||
|
languages_names = {
|
||||||
'de': 'Deutsch',
|
'de': 'Deutsch',
|
||||||
'en': 'English',
|
'en': 'English',
|
||||||
'es': 'Español',
|
'es': 'Español',
|
||||||
@ -289,15 +301,18 @@ def _generate_alternate_urls(app, pagename, templatename, context, doctree):
|
|||||||
|
|
||||||
The entry 'version' is added by Sphinx in the rendering context.
|
The entry 'version' is added by Sphinx in the rendering context.
|
||||||
"""
|
"""
|
||||||
# If the list of versions is not set, assume that the project has no alternate version
|
context['version_display_name'] = versions_names[version]
|
||||||
_alternate_versions = app.config.versions and app.config.versions.split(',') or []
|
|
||||||
context['alternate_versions'] = [
|
# If the list of versions is not set, assume the project has no alternate version
|
||||||
(_alternate_version, _build_url(_version=_alternate_version))
|
_provided_versions = app.config.versions and app.config.versions.split(',') or []
|
||||||
for _alternate_version in sorted(_alternate_versions, reverse=True)
|
|
||||||
if _alternate_version != version and (
|
# Map alternate versions to their display names and URLs.
|
||||||
_alternate_version != 'master' or pagename.startswith('developer')
|
context['alternate_versions'] = []
|
||||||
) and not _alternate_version.startswith('saas')
|
for _alternate_version, _display_name in versions_names.items():
|
||||||
]
|
if _alternate_version in _provided_versions and _alternate_version != version:
|
||||||
|
context['alternate_versions'].append(
|
||||||
|
(_display_name, _build_url(_alternate_version))
|
||||||
|
)
|
||||||
|
|
||||||
def _localize():
|
def _localize():
|
||||||
""" Add the pairs of (lang, code, url) for the current document in the rendering context.
|
""" Add the pairs of (lang, code, url) for the current document in the rendering context.
|
||||||
@ -308,19 +323,22 @@ def _generate_alternate_urls(app, pagename, templatename, context, doctree):
|
|||||||
"""
|
"""
|
||||||
_current_lang = app.config.language or 'en'
|
_current_lang = app.config.language or 'en'
|
||||||
# Replace the context value by its translated description ("Français" instead of "french")
|
# Replace the context value by its translated description ("Français" instead of "french")
|
||||||
context['language'] = supported_languages.get(_current_lang)
|
context['language'] = languages_names.get(_current_lang)
|
||||||
|
|
||||||
# If the list of languages is not set, assume that the project has no alternate language
|
# If the list of languages is not set, assume that the project has no alternate language
|
||||||
_alternate_languages = app.config.languages and app.config.languages.split(',') or []
|
_provided_languages = app.config.languages and app.config.languages.split(',') or []
|
||||||
context['alternate_languages'] = [
|
|
||||||
|
# Map alternate languages to their display names and URLs.
|
||||||
|
context['alternate_languages'] = []
|
||||||
|
for _alternate_lang, _display_name in languages_names.items():
|
||||||
|
if _alternate_lang in _provided_languages and _alternate_lang != _current_lang:
|
||||||
|
context['alternate_languages'].append(
|
||||||
(
|
(
|
||||||
supported_languages.get(_alternate_lang),
|
_display_name,
|
||||||
_alternate_lang.split('_')[0] if _alternate_lang != 'en' else 'x-default',
|
_alternate_lang.split('_')[0] if _alternate_lang != 'en' else 'x-default',
|
||||||
_build_url(_lang=_alternate_lang),
|
_build_url(_lang=_alternate_lang),
|
||||||
)
|
)
|
||||||
for _alternate_lang in _alternate_languages
|
)
|
||||||
if _alternate_lang in supported_languages and _alternate_lang != _current_lang
|
|
||||||
]
|
|
||||||
|
|
||||||
def _build_url(_version=None, _lang=None):
|
def _build_url(_version=None, _lang=None):
|
||||||
if app.config.is_remote_build:
|
if app.config.is_remote_build:
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
{{ language }} {# The current language #}
|
{{ language }} {# The current language #}
|
||||||
</button>
|
</button>
|
||||||
{%- else %}
|
{%- else %}
|
||||||
<button class="btn border"
|
<button class="btn border dropdown-toggle"
|
||||||
id="languages"
|
id="languages"
|
||||||
disabled="">
|
disabled="">
|
||||||
{{ language }} {# The current language #}
|
{{ language }} {# The current language #}
|
||||||
|
@ -8,13 +8,13 @@
|
|||||||
<button class="btn border dropdown-toggle"
|
<button class="btn border dropdown-toggle"
|
||||||
id="versions"
|
id="versions"
|
||||||
data-bs-toggle="dropdown">
|
data-bs-toggle="dropdown">
|
||||||
{{ version }} {# The current version #}
|
{{ version_display_name }} {# The current version #}
|
||||||
</button>
|
</button>
|
||||||
{%- else %}
|
{%- else %}
|
||||||
<button class="btn border"
|
<button class="btn border dropdown-toggle"
|
||||||
id="versions"
|
id="versions"
|
||||||
disabled="">
|
disabled="">
|
||||||
{{ version }} {# The current version #}
|
{{ version_display_name }} {# The current version #}
|
||||||
</button>
|
</button>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="versions">
|
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="versions">
|
||||||
|
Loading…
Reference in New Issue
Block a user