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
More customization options for figure_language_filename for localized images #7768
Comments
BTW the fact that Yet on my system with Sphinx 1.8.5 the variables would be:
If this were changed so that the output of |
Thank you for reporting. I agree this is a bug. And it seems the configuration was designed as
I'll try to fix this not to cause breaking changes later. |
Sounds good. Making For the other, feature proposal part of this issue, I'd suggest to then consider adding a new token that would be basically |
As a first step, I just posted #8006 to fix that an absolute path is passed to Now I'm considering about next step, adding a new key for |
Thanks for the bugfix! Yeah, I think what I'd need would be a dirname of the document, and possibly always resolved to be relative to the root folder of the project, e.g. with:
Referenced in:
as:
I'd need to have access somehow to:
So that the
In my concrete example, this would resolve to (
for example (French locale). Currently I'm monkey-patching Sphinx this way and it works fine for the use case, though of course I'm looking forward to using an upstream solution :) |
…ilename Fix #7768: i18n: Wrong root element is passed to figure_language_filename
I just merged #8006 now. And I'll add |
…th} token To build structured i18n imaging directory, figure_language_filename now supports `{docpath}` token that is a dirname of the current document.
…e_filename Close #7768: i18n: figure_language_filename supports {docpath} token
Is your feature request related to a problem? Please describe.
I'm working on the localization of the Godot Engine documentation, and we use a separate repository to hold the massive PO files that we use for Weblate and Sphinx.
I'm now working on image localization (upstream issue) and I find that even though
figure_language_filename
seems to provide some customization option, it's impossible to host the localized images in the separate repository.Indeed, both the
{root}
and{path}
substitution tokens resolve to absolute paths from the host system (e.g.root: /home/akien/Projects/godot/godot-docs-l10n/docs/tutorials/shading/img/vs_popup
), and since I can't do post-processing of the subsituted string, I can't strip the/home/akien/Projects/godot/godot-docs-l10n/docs/
base path to attempt using something like../img/{language}/{rel_path}/{filename}{ext}
.Describe the solution you'd like
I'd like the addition of one or more new path substitution tokens that can be used to customize the path to localized images more freely.
For example, for this structure:
and
index.rst
referencing.. image:: img/image.png
, I could imagine two useful substitution tokens:Alternatively (and possible as a better solution),
{root}
and{path}
could be changed to actually be relative to the Sphinx project's root folder, i.e. the{resolved_path}
in my example above, i.e.:(While the documentation currently states that these would be
img/image
andimg/
, which is wrong in my tests on Linux with Sphinx 1.8.5).I don't specifically need access to the file-relative path
img/
in my use case, but I imagine that some projects may benefit from it.Describe alternatives you've considered
I don't see any alternative option that would enable the workflow I want to use with localized images not being either in the original image's folder, or in one of its subfolders.
Edit: We came up with
twothree hacks that we could use to workaround the currently limited substitution tokens offered byfigure_language_filename
:format()
with our custom post-processing: Enabling localization of images godotengine/godot-docs-l10n#5 (comment)I did not test with latest Sphinx as it's not properly supported on ReadTheDocs yet, but the relevant code seems to be unchanged from 1.8.5:
https://github.com/sphinx-doc/sphinx/blob/3.x/sphinx/util/i18n.py#L299-L315
Additional context
The text was updated successfully, but these errors were encountered: