Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add localization language support #403

Closed
macagua opened this issue Mar 23, 2017 · 6 comments
Closed

Add localization language support #403

macagua opened this issue Mar 23, 2017 · 6 comments
Labels
Improvement Minor improvement to code

Comments

@macagua
Copy link
Contributor

macagua commented Mar 23, 2017

Hi guys

Is possible to add localization language support? because the footer templates are in English, but my Sphinx project is about Spanish documentation

Here I see that the templates have i18n support, but it's don't have locales directory for localization, for example Spanish language
https://github.com/rtfd/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/footer.html

Any idea ?

@ericholscher
Copy link
Member

I'm not 100% sure how to actually translate Sphinx themes. I believe it should use the same i18n infrastructure as Sphinx itself, but haven't done the research on it. This would be a great place for contribution and having folks who care about keeping the theme translated as part of our core team, if you're curious of a good way to contribute!

@mitya57
Copy link
Contributor

mitya57 commented Mar 24, 2017

I can share the steps I was using in our project:

  • Install babel from PyPI.
  • Create file babel.cfg (in this repository) with this content:
    # Extraction from Jinja2 HTML templates
    [jinja2: **/**.html]
    encoding = utf-8
    ignore_tags = script,style
    include_attrs = alt title summary
  • Add this to setup.cfg:
    [extract_messages]
    mapping_file = babel.cfg
    output_file = sphinx-rtd-theme.pot
    keywords = _ l_ lazy_gettext
  • Run python setup.py extract_messages to generate sphinx-rtd-theme.pot.
  • Create the .po file for your language using msgmerge tool (I think you can use Babel if you prefer).
  • Translate it using your favourite application (i.e. gtranslator).
  • Place the translated .po file in your project as locale/$LANG/LC_MESSAGES/sphinx.po.
  • Add locale_dirs = ['locale/'] to your project’s conf.py.

@macagua
Copy link
Contributor Author

macagua commented Mar 24, 2017

@mitya57 you are the man really thanks! 🍺

@macagua
Copy link
Contributor Author

macagua commented Mar 24, 2017

@ericholscher then I fork this repo, add support for localization language following the @mitya57 guide and return this improvement via a pull request!!!

@Blendify
Copy link
Member

@macagua any update on this?

@macagua
Copy link
Contributor Author

macagua commented Apr 1, 2017

@Blendify yes, please check out #405

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code
Projects
None yet
Development

No branches or pull requests

6 participants