Skip to content

Commit

Permalink
Use ffdoc in template_lang.rst
Browse files Browse the repository at this point in the history
Also dont include :ffdoc: in .po file
  • Loading branch information
kovidgoyal committed Nov 15, 2024
1 parent a68f51c commit a70e028
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 263 deletions.
12 changes: 10 additions & 2 deletions manual/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,19 @@ def ffdoc(m):

def source_read_handler(app, docname, source):
src = source[0]
if app.builder.name != 'gettext':
if app.builder.name == 'gettext':
if docname == 'template_lang':
src = re.sub(r':ffdoc:`(.+?)`', ' ', src) # ffdoc should not be translated
else:
if app.config.language != 'en':
src = re.sub(r'(\s+generated/)en/', r'\1' + app.config.language + '/', src)
if docname == 'template_lang':
src = re.sub(r':ffdoc:`(.+?)`', ffdoc, src)
try:
src = re.sub(r':ffdoc:`(.+?)`', ffdoc, src)
except Exception:
import traceback
traceback.print_exc()
raise
# Sphinx does not call source_read_handle for the .. include directive
for m in reversed(tuple(include_pat.finditer(src))):
included_doc_name = m.group(1).lstrip('/')
Expand Down
Loading

3 comments on commit a70e028

@cbhaley
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably don't understand how this works, but the re.sub() on line 55 seems wrong. It looks like it takes the entire :ffdoc:: expression out of the source that translators see, therefore dropping the :ffdoc: from the translated output. Shouldn't it leave the raw :ffdoc:func expression in the text to be translated?

The re.sub() on line 61 uses the function ffdoc() to replace the first match group. The re.sub() on line 55 replaces the entire pattern with a space. It seems to me that it should replace the pattern with r':ffdoc:\1'.

@kovidgoyal
Copy link
Owner Author

@kovidgoyal kovidgoyal commented on a70e028 Nov 15, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BibhuPrasad1998
Copy link

@BibhuPrasad1998 BibhuPrasad1998 commented on a70e028 Nov 16, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.