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

Show source shows english source #65

Closed
StanFromIreland opened this issue Feb 1, 2025 · 8 comments
Closed

Show source shows english source #65

StanFromIreland opened this issue Feb 1, 2025 · 8 comments

Comments

@StanFromIreland
Copy link
Collaborator

StanFromIreland commented Feb 1, 2025

Would it be better to redirect to translation .po files? I would be for a redirect as generally when I use it it is to fix a typo or something like that and I would like to see the raw content.

This would have to be done elsewhere but this issue is more for discussion rather than implementation.

@StanFromIreland
Copy link
Collaborator Author

@rffontenelle @JulienPalard What do you think?

@rffontenelle
Copy link

Well, if the English source reST file is shown, one doesn't see the translation. If we change this so the translation file (.po) is shown, one will not see the reST document structure (roles, directives, paragraphs, etc.).

The best would be to show a translated reST file combining both documents, but last time I checked, this is not possible.

@m-aciek
Copy link
Collaborator

m-aciek commented Feb 1, 2025

It would definitely be helpful. Sphinx doesn't produce localized rst files, HTML builder takes rsts and builds directly with gettext. I envision this as a second link next to "Show source" titled "Show translation source". @StanFromIreland could you open a discussion or feature request in Sphinx?

@rffontenelle
Copy link

I envision this as a second link next to "Show source" titled "Show translation source".

Now that's a great idea!

@StanFromIreland
Copy link
Collaborator Author

Opened a request in sphinx-doc.

@m-aciek
Copy link
Collaborator

m-aciek commented Feb 18, 2025

Let's track it upstream.

@m-aciek m-aciek closed this as completed Feb 18, 2025
@m-aciek
Copy link
Collaborator

m-aciek commented Feb 20, 2025

Draft of a patch in CPython repo. Figuring out the language in template context would be needed. Plus a local test.

Index: Doc/tools/templates/customsourcelink.html
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Doc/tools/templates/customsourcelink.html b/Doc/tools/templates/customsourcelink.html
--- a/Doc/tools/templates/customsourcelink.html	(revision 9e23e0ad2cc4267829388bc29688ac0c2bfb3604)
+++ b/Doc/tools/templates/customsourcelink.html	(date 1740052456655)
@@ -8,6 +8,13 @@
             rel="nofollow">{{ _('Show Source') }}
         </a>
       </li>
+      {%- if TODO %}
+      <li>
+        <a href="https://github.com/python/python-docs-{{ TODO }}/blob/{{ version }}/{{ pagename }}.po"
+            rel="nofollow">{{ _('Show translation source') }}
+        </a>
+      </li>
+      {%- endif %}
     </ul>
   </div>
 {%- endif %}

@StanFromIreland
Copy link
Collaborator Author

StanFromIreland commented Feb 20, 2025

This is simple enough and works for me:

      {% if language != "en" %}
      <li>
        <a href="https://github.com/python/python-docs-{{ language }}/blob/{{ version }}/{{ pagename }}.po"
           rel="nofollow">{{ _('Show translation source') }}</a>
      </li>
      {% endif %}
preview

Image

python/cpython#130355

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

No branches or pull requests

3 participants