jbms / sphinx-immaterial

Adaptation of the popular mkdocs-material material design theme to the sphinx documentation system
https://jbms.github.io/sphinx-immaterial/
Other
177 stars 28 forks source link

Is there a way to internationalize json domain titles ? #274

Closed rperrot closed 2 days ago

rperrot commented 11 months ago

Hi,

first of all, thank you for your really helpful theme/extension.

I' trying to use json domain in a non english document and I'm stuck with the "required/optional" members string. I'd like to change it but I can't find a way to change it using a parameter/option.

I think the issue is because theses strings are hard coded here :

https://github.com/jbms/sphinx-immaterial/blob/9adb3f18bf759b287627b0dcaff7e1bd512ed0b6/sphinx_immaterial/apidoc/json/domain.py#L866

Is there a way to customize it or it's impossible ?

Yours,

2bndy5 commented 11 months ago

True, the strings are hardcoded in English, and there is no config option to change or remove them. We could use Sphinx' own translation mechanism, but I think that would require a .po file (in the doc project's source) that defines the translation for the words phrases "Required members" and "Optional members". This idea would be simple to implement on our end:

                heading = "%s members" % ("Required" if required else "Optional") 
                field_list, body = self._make_field(_(heading))

But it will require a message catalog (.po file) of translations on the user's end.