Skip to content

Commit 563d494

Browse files
authored
Merge pull request #793 from readthedocs/agj/update-translations-rebase
Finalized addition of theme localization
2 parents bad2112 + f38476e commit 563d494

30 files changed

+1025
-109
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@
99
*.map
1010
.ropeproject/
1111
.ruby-version
12+
bin/
1213
dist/
1314
bower_components/
15+
include/
16+
lib/
17+
local/
1418
node_modules
1519
npm-debug.log
1620
package-lock.json
21+
pip-selfcheck.json
1722
sphinx_rtd_theme/static/fonts/Lato/
1823
sphinx_rtd_theme/static/fonts/RobotoSlab/
24+
.python-version
25+
.node-version

.readthedocs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
build:
2-
image: latest
1+
version: 2
32
python:
43
version: 3.6
5-
requirements_file: docs/requirements.txt
4+
install:
5+
- requirements: docs/requirements.txt

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ matrix:
1010
env: TOXENV=docs
1111
install:
1212
- pip install tox-travis
13+
- pip install sphinx
1314
script:
1415
- tox
1516

.tx/config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[sphinx-rtd-theme.sphinx-rtd-theme]
2+
file_filter = sphinx_rtd_theme/locale/<lang>/LC_MESSAGES/sphinx.po
3+
source_file = sphinx_rtd_theme/locale/en/LC_MESSAGES/sphinx.po
4+
source_lang = en
5+
6+
[main]
7+
host = https://www.transifex.com
8+
type = PO

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include *.txt
2+
include babel.cfg
23
include LICENSE
34
recursive-include sphinx_rtd_theme *.conf
45
recursive-include sphinx_rtd_theme *.css
@@ -9,5 +10,7 @@ recursive-include sphinx_rtd_theme *.svg
910
recursive-include sphinx_rtd_theme *.ttf
1011
recursive-include sphinx_rtd_theme *.woff
1112
recursive-include sphinx_rtd_theme *.woff2
13+
recursive-include sphinx_rtd_theme/locale *.pot *.po *.mo
1214
recursive-include tests *.py
1315
recursive-include tests *.rst
16+
prune build

README.rst

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
21
**************************
32
Read the Docs Sphinx Theme
43
**************************
54

65
.. image:: https://img.shields.io/pypi/v/sphinx_rtd_theme.svg
76
:target: https://pypi.python.org/pypi/sphinx_rtd_theme
8-
:alt: Pypi Version
9-
.. image:: https://travis-ci.org/rtfd/sphinx_rtd_theme.svg?branch=master
10-
:target: https://travis-ci.org/rtfd/sphinx_rtd_theme
7+
:alt: Pypi Version
8+
.. image:: https://travis-ci.org/readthedocs/sphinx_rtd_theme.svg?branch=master
9+
:target: https://travis-ci.org/readthedocs/sphinx_rtd_theme
1110
:alt: Build Status
1211
.. image:: https://img.shields.io/pypi/l/sphinx_rtd_theme.svg
1312
:target: https://pypi.python.org/pypi/sphinx_rtd_theme/
@@ -16,39 +15,56 @@ Read the Docs Sphinx Theme
1615
:target: http://sphinx-rtd-theme.readthedocs.io/en/latest/?badge=latest
1716
:alt: Documentation Status
1817

19-
The ``sphinx_rtd_theme`` is a sphinx_ theme designed to look modern and be mobile-friendly.
20-
This theme is primarily focused to be used on readthedocs.org_ but can work with your
21-
own sphinx projects. To read more and see a working demo_ head over to readthedocs.org_.
18+
This Sphinx_ theme was designed to provide a great reader experience for
19+
documentation users on both desktop and mobile devices. This theme is used
20+
primarily on `Read the Docs`_ but can work with any Sphinx project. You can find
21+
a working demo of the theme in the `theme documentation`_
2222

23-
.. _sphinx: http://www.sphinx-doc.org
24-
.. _readthedocs.org: http://www.readthedocs.org
25-
.. _demo: https://sphinx-rtd-theme.readthedocs.io/en/latest/
23+
.. _Sphinx: http://www.sphinx-doc.org
24+
.. _Read the Docs: http://www.readthedocs.org
25+
.. _theme documentation: https://sphinx-rtd-theme.readthedocs.io/en/latest/
2626

27+
Installation
28+
============
2729

28-
Installing
29-
==========
30+
This theme is distributed on PyPI_ and can be installed with ``pip``:
3031

31-
The theme is distributed on PyPI_ and can be installed with pip::
32+
.. code:: console
3233
3334
pip install sphinx-rtd-theme
3435
35-
For more information read the full installing docs
36-
`here <https://sphinx-rtd-theme.readthedocs.io/en/latest/installing.html>`__.
36+
To use the theme in your Sphinx project, you will need to add the following to
37+
your ``conf.py`` file:
3738

38-
.. _PyPI: https://pypi.python.org/pypi/sphinx_rtd_theme
39+
.. code:: python
40+
41+
import sphinx_rtd_theme
42+
43+
extensions = [
44+
...
45+
"sphinx_rtd_theme",
46+
]
3947
48+
html_theme = "sphinx_rtd_theme"
49+
50+
For more information read the full documentation on `installing the theme`_
51+
52+
.. _PyPI: https://pypi.python.org/pypi/sphinx_rtd_theme
53+
.. _installing the theme: https://sphinx-rtd-theme.readthedocs.io/en/latest/installing.html
4054

4155
Configuration
4256
=============
4357

44-
The ``sphinx_rtd_theme`` is highly customizable on both the page level and on a global level.
45-
To see all the possible configuration options read the configuring docs
46-
`here <https://sphinx-rtd-theme.readthedocs.io/en/latest/configuring.html>`__.
58+
This theme is highly customizable on both the page level and on a global level.
59+
To see all the possible configuration options, read the documentation on
60+
`configuring the theme`_.
4761

62+
.. _configuring the theme: https://sphinx-rtd-theme.readthedocs.io/en/latest/configuring.html
4863

4964
Contributing
5065
============
5166

52-
If you would like to help improve the theme or have more control
53-
over the theme in case of a fork please read our contributing guide
54-
`here <https://sphinx-rtd-theme.readthedocs.io/en/latest/contributing.html>`__.
67+
If you would like to help modify or translate the theme, you'll find more
68+
information on contributing in our `contributing guide`_.
69+
70+
.. _contributing guide: https://sphinx-rtd-theme.readthedocs.io/en/latest/contributing.html

babel.cfg

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# How setup this file
2+
# http://babel.pocoo.org/en/latest/setup.html
3+
# this file description:
4+
# http://babel.pocoo.org/en/latest/messages.html#extraction-method-mapping-and-configuration
5+
6+
# Extraction from Jinja2 HTML templates
7+
[jinja2: **/**.html]
8+
encoding = utf-8
9+
ignore_tags = script,style
10+
include_attrs = alt title summary placeholder

docs/changelog.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Other Changes
1717
--------------
1818

1919
* Add the ``navigation`` template block around the navigation area.
20+
* Added Spanish translation
21+
* Added i18n support using Babel
2022

2123
0.4.3
2224
======
@@ -93,7 +95,7 @@ Fixes
9395
* Color accessibility improvements on the left navigation
9496

9597
Other Changes
96-
--------------
98+
---------------
9799

98100
* Write theme version and build date at top of JavaScript and CSS
99101
* Changed code and literals to use a native font stack (#612)

docs/conf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import os
55
import re
66

7-
sys.path.append(os.path.abspath('..'))
7+
if not 'READTHEDOCS' in os.environ:
8+
sys.path.insert(0, os.path.abspath('..'))
89
sys.path.append(os.path.abspath('./demo/'))
910

1011
from sphinx.locale import _
11-
1212
from sphinx_rtd_theme import __version__
1313

1414

@@ -26,11 +26,14 @@
2626
'sphinx.ext.mathjax',
2727
'sphinx.ext.viewcode',
2828
'sphinxcontrib.httpdomain',
29+
'sphinx_rtd_theme',
2930
]
3031

3132
templates_path = ['_templates']
3233
source_suffix = '.rst'
3334
exclude_patterns = []
35+
locale_dirs = ['locale/']
36+
gettext_compact = False
3437

3538
master_doc = 'index'
3639
suppress_warnings = ['image.nonlocal_uri']

docs/contributing.rst

Lines changed: 75 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,113 @@
1+
************
2+
Contributing
3+
************
14

2-
***********************************
3-
Contributing or modifying the theme
4-
***********************************
5+
This project follows the Read the Docs :doc:`code of conduct
6+
<rtd:code-of-conduct>`. If you are not familiar with our code of conduct policy,
7+
take a minute to read the policy before starting with your first contribution.
58

6-
The sphinx_rtd_theme is primarily a sass_ project that requires a few other sass libraries. I'm
7-
using bower_ to manage these dependencies and sass_ to build the css. The good news is
8-
I have a very nice set of grunt_ operations that will not only load these dependencies, but watch
9-
for changes, rebuild the sphinx demo docs and build a distributable version of the theme.
10-
The bad news is this means you'll need to set up your environment similar to that
11-
of a front-end developer (vs. that of a python developer). That means installing node and ruby.
12-
13-
.. seealso::
9+
Modifying the theme
10+
===================
1411

15-
If you are unsure of appropriate actions to take while interacting with our
16-
community please read our :doc:`Code of Conduct <rtd:code-of-conduct>`.
12+
The styles for this theme use SASS_ and a custom CSS framework called Wyrm_. We
13+
use Bower_ to manage these dependencies and SASS_ to build the CSS. Grunt_ is
14+
used to watch for changes, rebuild the static assets, and rebuild the Sphinx
15+
demo documentation.
1716

17+
.. note::
18+
The installation of Ruby and Node is outside the scope of this
19+
documentation. You will need both in order to make changes to this theme.
1820

1921
Set up your environment
20-
=======================
22+
-----------------------
2123

22-
#. Install sphinx_ into a virtual environment.
24+
#. Install Sphinx_ and documentation build dependencies.
2325

24-
.. code:: bash
26+
.. code:: console
2527
26-
pip install sphinx sphinxcontrib-httpdomain
28+
pip install -e '.[dev]'
2729
28-
#. Install sass.
30+
#. Install SASS.
2931

30-
.. code:: bash
32+
.. code:: console
3133
3234
gem install sass
3335
34-
#. Install node, bower, grunt, and theme dependencies.
35-
36-
.. code:: bash
37-
38-
# Install node
39-
brew install node
36+
#. Install Bower, Grunt, and theme dependencies locally.
4037

41-
# Install bower and grunt
42-
npm install -g bower grunt-cli
38+
.. code:: console
4339
44-
# Now that everything is installed, let's install the theme dependencies.
4540
npm install
4641
47-
Now that our environment is set up, make sure you're in your virtual environment, go to
48-
this repository in your terminal and run grunt:
42+
Making changes
43+
--------------
4944

50-
.. code::
45+
Changes to the theme can be compiled and tested with the default Grunt task:
46+
47+
.. code:: console
5148
5249
grunt
5350
54-
This default task will do the following **very cool things that make it worth the trouble**:
51+
This default task will do the following:
52+
53+
#. Install and update any Bower dependencies.
54+
#. Build the static CSS from SASS source files.
55+
#. Build the demo documentation.
56+
#. Watch for changes to the SASS files and documentation and rebuild everything
57+
on any detected changes.
58+
59+
Alternatively, if you don't need to watch the files, Grunt can be called with
60+
the same task used for releases:
61+
62+
.. code:: console
63+
64+
grunt build
65+
66+
.. _Bower: http://www.bower.io
67+
.. _SASS: http://www.sass-lang.com
68+
.. _Wyrm: http://www.github.com/snide/wyrm/
69+
.. _Grunt: http://www.gruntjs.com
70+
.. _Sphinx: http://www.sphinx-doc.org/en/stable/
71+
72+
Translations
73+
============
74+
75+
Translations are managed using `Transifex`_. You can join any of the existing
76+
language teams or request a new language is added to the project. For more
77+
information on our translation standards, see our docs on
78+
:doc:`rtd:development/i18n`
79+
80+
Periodically, core team should update the translation files outside our normal
81+
releases. Someone from the core team, with write access to Transifex, should run
82+
the following:
83+
84+
.. code:: console
5585
56-
#. Install and update any bower dependencies.
57-
#. Run sphinx and build new docs.
58-
#. Watch for changes to the sass files and build css from the changes.
59-
#. Rebuild the sphinx docs anytime it notices a change to ``.rst``, ``.html``, ``.js``
60-
or ``.css`` files.
86+
python setup.py update_translations
6187
62-
.. _bower: http://www.bower.io
63-
.. _sass: http://www.sass-lang.com
64-
.. _wyrm: http://www.github.com/snide/wyrm/
65-
.. _grunt: http://www.gruntjs.com
66-
.. _node: http://www.nodejs.com
67-
.. _sphinx: http://www.sphinx-doc.org/en/stable/
88+
This will extract new messages, upload the messages to Transifex, and will
89+
update our local translation files. Changes can be checked in to a branch and
90+
put up for review.
6891

92+
.. _Transifex: https://www.transifex.com/readthedocs/sphinx-rtd-theme
6993

70-
Releasing the Theme
94+
Releasing the theme
7195
===================
7296

73-
When you release a new version,
74-
you should do the following:
97+
To release a new version of the theme, core team will take the following steps:
7598

7699
#. Bump the version in ``sphinx_rtd_theme/__init__.py``, ``bower.json`` and ``package.json`` --
77100
we try to follow `semver <http://semver.org/>`_, so be careful with breaking changes.
78101
#. Update the changelog (``docs/changelog.rst``) with the version information.
79-
#. Run a ``grunt build`` to rebuild all the theme assets.
102+
#. Run ``grunt build`` to rebuild all the theme assets.
103+
#. Run ``python setup.py update_translations`` to compile new translation files and update Transifex
80104
#. Commit that change.
81105
#. Tag the release in git: ``git tag $NEW_VERSION``.
82106
#. Push the tag to GitHub: ``git push --tags origin``.
83107
#. Upload the package to PyPI:
84108

85-
.. code:: bash
109+
.. code:: console
86110
87-
$ rm -rf dist/
88-
$ python setup.py sdist bdist_wheel
89-
$ twine upload --sign --identity [email protected] dist/*
111+
rm -rf dist/
112+
python setup.py sdist bdist_wheel
113+
twine upload --sign --identity [email protected] dist/*

0 commit comments

Comments
 (0)