Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed django#513 -- Added a language switcher for the documentation.
  • Loading branch information
Dunedan authored and timgraham committed Apr 1, 2016
1 parent c05e733 commit 6c849e4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 24 deletions.
13 changes: 11 additions & 2 deletions djangoproject/scss/_style.scss
Expand Up @@ -2174,9 +2174,9 @@ h2 + .list-link-soup {

}

// Docs version switcher
// Switcher for docs version and language

#doc-versions {
#version-switcher {

position: fixed;
right: 15px;
Expand All @@ -2191,6 +2191,15 @@ h2 + .list-link-soup {
margin-right: 4px;
}

ul {
text-align: right;
}
}

#doc-versions, #doc-languages {
margin-top: 0.5em;
margin-bottom: 0.5em;

li {
display: none;
margin: 0 3px;
Expand Down
63 changes: 41 additions & 22 deletions djangoproject/templates/docs/doc.html
Expand Up @@ -45,35 +45,54 @@
{% endblock body_extra %}

{% block content %}
{% get_all_doc_versions docurl as other_versions %}
<ul id="doc-versions" class="version-switcher">
{% for other_version in other_versions %}
{% if version != other_version %}
<div id="version-switcher">
<ul id="doc-languages" class="language-switcher">
{% for available_lang in available_languages %}
{% if lang != available_lang %}
<li class="other">
{% if docurl %}
{% url 'document-detail' lang=lang version=other_version url=docurl host 'docs' as other_url %}
{% url 'document-detail' lang=available_lang version=version url=docurl host 'docs' as other_url %}
{% else %}
{% url 'document-index' lang=lang version=other_version host 'docs' as other_url %}
{% url 'document-index' lang=available_lang version=version host 'docs' as other_url %}
{% endif %}
<a href="{{ other_url }}{% if searchparams %}search/?{{ searchparams }}{% endif %}">{{ other_version }}</a>
<a href="{{ other_url }}{% if searchparams %}search/?{{ searchparams }}{% endif %}">{{ available_lang }}</a>
</li>
{% endif %}
{% endfor %}
<li class="current{% if release.is_dev %} dev{% endif %}"
title="{% if release.is_dev %}{% blocktrans trimmed %}
This document is for Django's development version, which can be significantly different from previous releases.
{% endblocktrans %}{% else %}{% blocktrans trimmed %}
This document describes Django {{ version }}.
{% endblocktrans %}{% endif %} {% blocktrans trimmed %}
Click on the links on the left to see other versions.
{% endblocktrans %}">
<span>{% trans "Documentation version:" %}
<strong>{% if release.is_dev %}
development{% else %}{{ version }}
{% endif %}</strong>
</span>
</li>
</ul>
<li class="current"
title="{% blocktrans %}Click on the links on the left to switch to another language.{% endblocktrans %}">
<span>{% trans "Language:" %} <strong>{{ lang }}</strong></span>
</li>
</ul>

{% get_all_doc_versions docurl as other_versions %}
<ul id="doc-versions" class="version-switcher">
{% for other_version in other_versions %}
{% if version != other_version %}
<li class="other">
{% if docurl %}
{% url 'document-detail' lang=lang version=other_version url=docurl host 'docs' as other_url %}
{% else %}
{% url 'document-index' lang=lang version=other_version host 'docs' as other_url %}
{% endif %}
<a href="{{ other_url }}{% if searchparams %}search/?{{ searchparams }}{% endif %}">{{ other_version }}</a>
</li>
{% endif %}
{% endfor %}
<li class="current{% if release.is_dev %} dev{% endif %}"
title="{% if release.is_dev %}{% blocktrans trimmed %}
This document is for Django's development version, which can be significantly different from previous releases.
{% endblocktrans %}{% else %}{% blocktrans trimmed %}
This document describes Django {{ version }}.
{% endblocktrans %}{% endif %} {% blocktrans trimmed %}
Click on the links on the left to see other versions.
{% endblocktrans %}">
<span>{% trans "Documentation version:" %}
<strong>{% if release.is_dev %}development{% else %}{{ version }}{% endif %}</strong>
</span>
</li>
</ul>
</div>

{% block body %}
<div id="docs-content">
Expand Down

0 comments on commit 6c849e4

Please sign in to comment.