How to set text not translatable (i18n)

51 views
Skip to first unread message

Mysaa Java

unread,
Nov 28, 2020, 7:42:43 AM11/28/20
to sphinx-users

Hello.
I used sphinx gettext to export my docs to .pot files. But this process exports too many strings, for example, on the Nav Links sections, i have this line: « * :ref:`genindex`  » that gets exported to pot files. Is there a way i can set a string or a type of string (the strings that start with, a colon for example) not to be exported in .pot ?

Thanks in advance !

Komiya Takeshi

unread,
Nov 28, 2020, 8:23:03 AM11/28/20
to sphinx...@googlegroups.com
Hi,

Unfortunately, there is no way to do that. Please write a code to
customize it. There are many software to manipulate .po files!

Thanks,
Takeshi KOMIYA

2020年11月28日(土) 21:42 Mysaa Java <samso...@gmail.com>:
>
>
> Hello.
> I used sphinx gettext to export my docs to .pot files. But this process exports too many strings, for example, on the Nav Links sections, i have this line: « * :ref:`genindex` » that gets exported to pot files. Is there a way i can set a string or a type of string (the strings that start with, a colon for example) not to be exported in .pot ?
>
> Thanks in advance !
>
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/e8ac1ee9-7e34-4421-aee6-817f9f83a1bbn%40googlegroups.com.

Mysaa Java

unread,
Nov 28, 2020, 3:31:15 PM11/28/20
to sphinx-users
Ok thanks !
May i ask another question here (if you say no, i'll make another discussion)

I made a custom directive that generates a video and displays it. But the video generation process is quite long, and, when i launch sphinx gettext or pdf target, the videos takes a lot of unneeded time to generate.
So, is there a way i can know which target sphinx was launched with inside my directive code, so i generate the video the good way ?

Thanks !

Komiya Takeshi

unread,
Nov 28, 2020, 10:20:19 PM11/28/20
to sphinx...@googlegroups.com
> May i ask another question here (if you say no, i'll make another discussion)

Of course, yes :-)

> I made a custom directive that generates a video and displays it. But the video generation process is quite long, and, when i launch sphinx gettext or pdf target, the videos takes a lot of unneeded time to generate.
> So, is there a way i can know which target sphinx was launched with inside my directive code, so i generate the video the good way ?

Directive itself should not know what builder is running now because
the output of the directive are cached and used to other builds
(a.k.a. incremental build feature). It would be better to process it
after the builder is determined. That is the resolving phase (see
https://www.sphinx-doc.org/en/master/extdev/index.html#build-phases).
So you need to process videos in two steps. 1) Generate an
intermediate node on the directive, and 2) process a video by type of
current builder on resolving phase.

```
from docutils import nodes

class my_video(nodes.Element):
"""A node for video"""
pass

class VideoDirective(Directive):
def run(self):
# generate a video node (please fill attributes using options
if you need it on latter step).
node = my_video()
return [node]

def on_doctree_resolved(app, doctree, docname):
# process my_video nodes only if HTML builds
# Note: you can also use "builder.format" to determine builder types.
if app.builder.name == 'html':
for video in doctree.traverse(my_video):
process_video(video)
```

Thanks,
Takeshi KOMIYA

Mysaa Java

unread,
Dec 8, 2020, 12:55:15 PM12/8/20
to sphinx-users
Thanks a lot for your quick answer, this is exactly what i needed (i thought i already answered you, sorry) !
Reply all
Reply to author
Forward
0 new messages