pydata-sphinx-theme icon indicating copy to clipboard operation
pydata-sphinx-theme copied to clipboard

Translations for page elements

Open chrisjsewell opened this issue 5 years ago • 9 comments

I'm pretty sure the next/previous page translations don't work here, because the internal sphinx catalog (https://github.com/sphinx-doc/sphinx/tree/3.x/sphinx/locale) does not contain translations for them (the _ filter is a shorthand for using this)

https://github.com/pandas-dev/pydata-sphinx-theme/blob/7163801b25d3e2f15a06fa403bac4fbd00818198/pydata_sphinx_theme/layout.html#L7-L10

FYI I noticed this whilst adding a custom translation catalog to sphinx-book-theme: https://github.com/executablebooks/sphinx-book-theme/commit/d2a8b44271bc20baa49d5ea1a94aea18a25b2e3d 😄

We could think about adding something similar here

chrisjsewell avatar Sep 23 '20 22:09 chrisjsewell

note there are individual translations for "next" "previous" and "page", so as a minimum you could just use those i.e. "{{ _('next')}} {{ _('page')}}", but obviously this does not guarantee the correct translation

chrisjsewell avatar Sep 23 '20 23:09 chrisjsewell

I see the project has no PO or MO files. If I were to provide Spanish and French translations, would they be merged?

jpmckinney avatar Apr 21 '21 22:04 jpmckinney

Does this mean that Sphinx would be able to translate these files?

I'd be +1 on this, though we should also document the files in the docs so others know how to edit them etc

choldgraf avatar Apr 22 '21 00:04 choldgraf

My understanding is that at minimum MO files must be committed in the theme, e.g. https://github.com/sphinx-doc/sphinx/tree/4.x/sphinx/locale contains strings for files in the basic theme. Same for sphinx_rtd_theme and others. Committing the PO file makes it much easier to update the MO file.

jpmckinney avatar Apr 22 '21 19:04 jpmckinney

Why is there a _templates directory? Py-Babel will not look in directories with an underscore: https://github.com/python-babel/babel/blob/5afe2b2f11dcdd6090c00231d342c2e9cd1bdaab/babel/messages/extract.py#L140-L143

I don't think the theme should be using _templates...

jpmckinney avatar Apr 22 '21 20:04 jpmckinney

Hmm, well I think it's fine for a theme to use any name. I remove the _ in #399.

jpmckinney avatar Apr 22 '21 22:04 jpmckinney

I'm a bit confused why some templates are in pydata-sphinx-theme and others are in _templates, TBH.

jpmckinney avatar Apr 22 '21 22:04 jpmckinney

I'm personally fine with it - we were just following convention I think.

I think the idea is that the HTML templates in the main folder are larger structural pieces, and _templates contains smaller "components" (maybe components is a better folder name) that are inserted into the bigger templates. But this folder was created after we had already created some "components" in the larger folder, which is why this might be confusing.

choldgraf avatar Apr 22 '21 22:04 choldgraf