Re: Greek language/letters in sphinx

349 views
Skip to first unread message

jfbu

unread,
Nov 19, 2019, 3:47:39 AM11/19/19
to sphinx...@googlegroups.com
Le 18/11/2019 à 21:22, tzoumakersx a écrit :
> Hi all!
>
> I am a new user in sphinx. I am about to write some documentation in the greek language (hopefully there will also be some translations but this is another thing)
> ...
> I would be grateful if somebody could offer a little help.
> Thanks in advance
> Nikos


Hi Nikos,

You are right, Sphinx did not properly support Greek
as main language for LaTeX output

See recent discussion

https://groups.google.com/d/msgid/sphinx-users/qmrb5l%247jjq%241%40blaine.gmane.org

Recently released Sphinx 2.2.1 added support for it
using xelatex and GNU FreeFont, and a workaround to an
upstream LaTeX polyglossia problem

https://github.com/sphinx-doc/sphinx/pull/6711

Can you try it out and tell us if it works? (without your latex related changes in conf.py)

You must use

language = 'el'

in your conf.py


Best,

Jean-François


Witthaya Phaliam

unread,
Nov 19, 2019, 4:13:15 AM11/19/19
to sphinx...@googlegroups.com

ในวันที่ อ. 19 พ.ย. 2019 15:47 jfbu <jf...@free.fr> เขียนว่า:
--
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/qr0a70%2430kn%241%40blaine.gmane.org.

jfbu

unread,
Nov 19, 2019, 4:24:42 AM11/19/19
to sphinx...@googlegroups.com
Le 18/11/2019 à 21:22, tzoumakersx a écrit :
> cause according to this https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language
> i think greek are not supported


Indeed Greek ('el') is not listed at https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language

Nevertheless the translation of Sphinx project exists

About 25% of strings are translated only

Volunteers welcome !

http://www.transifex.com/sphinx-doc/sphinx-1/language/el/

LaTeX translations of some layout elements come
from polyglossia package on the fly on PDF compilation
and are not under control of the Sphinx project itself.
(for example the title used for the table of contents
of the PDF)
(and some fancychap styles may
be only for English)
but others like the headings for figures
or tables or literal blocks are part of the translatable
strings of Sphinx. For example I see that Sphinx Greek uses

Σχήμα, Πίνακας, Λίστα

respectively

It also has a string

συνεχίζεται από την προηγούμενη σελίδα

but the "continues on next page" is still in English

You can add to preamble

\renewcommand{\literalblockcontinuesname}{continues on next page}

with suitable Greek translation

(this is for code-blocks with a pagebreak)

Check in LaTeX build repertory the file sphinxmessages.sty
to see what needs to be translated to Greek currently in one's
own latex_elements.'preamble' key

(or you can copy sphinxmessages.sty to source repertory,
customize it, and add it to latex_additional_files list in conf.py)

Jean-François

jfbu

unread,
Nov 19, 2019, 4:30:07 AM11/19/19
to sphinx...@googlegroups.com
Le 19/11/2019 à 10:24, jfbu a écrit :
> Volunteers welcome !
>
> http://www.transifex.com/sphinx-doc/sphinx-1/language/el/

needs to require login first

try this

https://www.transifex.com/sphinx-doc/sphinx-1/

entry point


> LaTeX translations of some layout elements come
> from polyglossia package on the fly on PDF compilation
> and are not under control of the Sphinx project itself.

I meant that the actual used strings can be modified
only by LaTeX commands (see documentation of polyglossia
LaTeX package) but are not part of the message catalog
of Sphinx itself

tzoumakersx

unread,
Nov 20, 2019, 3:40:33 PM11/20/19
to sphinx-users
Hi Jean Francois!

thank you for your reply.
In Ubuntu 19.10 repos there is only sphinx 1.8.5 so I had to install manually, something I am not very familiar with.
So i followed some instructions at your website.
I had to figure out that i needed to install pip3 (i already had pip and pip2 in my system) so that sphinx 2.2.1 could be installed.
At the end of the installation, i got a reminder that some scripts (sphinx-build and sphinx-quickstart) were located in my home folder/.../../
sphinx-builder --version would return 1.8.5
but /homefolder/.../sphinx-builder --version would return 2.2.1

So i made a new quistart in a directory  with the scipt from my home folder.
At this point I am not sure whether sphinc-quickstart script is using the 2.2.1 version or the 1.8.5 (it probably has to do with some environmental variables i guess ... )
Hopefully it used the 2.2.1 version of sphinx.

Then i copied my rst files into this new directory and tried building the pdf.
At the beginning it would complain for a number of things, that had to do with conf.py - master-doc = contents.rst for example
I tried using a plain conf.py, as you suggested, but it wouldn't work.
So i started adding stuff into my conf.py:
at some point it worked and it would produce some pdf.
Since i had no setting for the language in the preamble section the pdf output file would not be ok (I guess this is what you would like to know)
Then i added also the language stuff, Bjournstroup template + fonts
And I got some result, but it would be the same as previously, meaning:
to my view some letters are according to configuration (correct font) but most of the letters are using some default font .


To sum up:
i have the doubt whether sphinx 2.2.1 is used during the above procedure - i AM using the correct scritpt for a quickstart but does it use the correct version of sphinx ? that i do not know
If sphinx version is correct during the build procedure, I do not see much difference to previous build.

I could try a few suggestions and help improve sphinx if  you like - since I am also interested in a correct project output (pdf)

Nikos

jfbu

unread,
Nov 20, 2019, 4:37:28 PM11/20/19
to sphinx...@googlegroups.com
Le 20/11/2019 à 21:40, tzoumakersx a écrit :
> i have the doubt whether sphinx 2.2.1 is used during the above procedure -
> i AM using the correct scritpt for a quickstart but does it use the correct
> version of sphinx ? that i do not know
> If sphinx version is correct during the build procedure, I do not see much
> difference to previous build.


Hi Nikos,

sorry that I got you started on some complicated procedures.
I usually insert something such as

# -- version info --

_DEBUG_HEADER = '''Sphinx version: %s
Python version: %s (%s)
Docutils version: %s %s
Pygments version: %s
Jinja2 version: %s
'''

import sphinx
import jinja2
import docutils
import platform
import pygments

print(_DEBUG_HEADER %
(sphinx.__display_version__,
platform.python_version(),
platform.python_implementation(),
docutils.__version__, docutils.__version_details__,
pygments.__version__,
jinja2.__version__))


at end of conf.py so that I know what is used during Sphinx build
(and as I use this all the time I have forgotten what happens otherwise)

But back to Greek, actually I linked to

https://github.com/sphinx-doc/sphinx/pull/6711

as it shows what was changed:


- usage of 'xelatex' as latex_engine,

- slight enhancement of the default xelatex font config to work around some problem

done manually it will be in conf.py

latex_elements = {
'fontpkg': r"""
\setmainfont{FreeSerif}[
Extension = .otf,
UprightFont = *,
ItalicFont = *Italic,
BoldFont = *Bold,
BoldItalicFont = *BoldItalic
]
\setsansfont{FreeSans}[
Extension = .otf,
UprightFont = *,
ItalicFont = *Oblique,
BoldFont = *Bold,
BoldItalicFont = *BoldOblique,
]
\setmonofont{FreeMono}[
Extension = .otf,
UprightFont = *,
ItalicFont = *Oblique,
BoldFont = *Bold,
BoldItalicFont = *BoldOblique,
]
\newfontfamily\greekfont{FreeSerif}
\newfontfamily\greekfontsf{FreeSans}
\newfontfamily\greekfonttt{FreeMono}
""",
}

(the last three lines above are the only addition needed
by Greekto the Sphinx default xelatex set-up since 2.0)

and also language = 'el'

That's all there is to it

A priori, with the above and if GNU FreeFont and if nothing
else related to LaTeX fonts is added to your conf.py it
should work.

Make sure in particular you don't have strange fontenc
setting or usage of some font packages

Jean-François

tzoumakers tzoumakers

unread,
Nov 21, 2019, 1:28:26 AM11/21/19
to sphinx...@googlegroups.com
Hi Jean-Francois

again, thank you for your time and effort helping me

I tried your suggestions.
your little 'version script' output produced this :

Running Sphinx v1.8.5
Sphinx version: 1.8.5
Python version: 3.7.5rc1 (CPython)
Docutils version: 0.15.2 release
Pygments version: 2.3.1
Jinja2 version: 2.10

So sphinx is in version 1.8.5 - does this matter?
Under latex_elements
i removed anything and added only your suggestion about the font (so no 'preamble'  or anything else)
I also set
language = 'el'

The output is still the same:

this is the front page, where the main title looks ok, however one new thing is that in the date part i see something new
which maybe is french? (those 'de' words)

here is the table of contents, where the numbers look ok, but the titles are not, some  letters look ok (one can distinguish them as bold) and some do not look ok

this is chapter 1, where the chapter name is ok, but the subtitle and the rest of the text is not

this is the last page of chapter 1 which is a blank page, where header looks ok, but footer is not

this is a page in chapter 3 with a mix of stuff, english and greek, and a link , some good some not good.

Nikos

--
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.

tzoumakers tzoumakers

unread,
Nov 21, 2019, 1:29:59 AM11/21/19
to sphinx...@googlegroups.com
also the engine is set to xelatex

jfbu

unread,
Nov 21, 2019, 3:54:47 AM11/21/19
to sphinx...@googlegroups.com
Hi Nikos,

Hi Nikos,

This is very intriguing and spectacular.

No idea about the date on front page
(it is not French) but apart from that all your
problems could be a pure LaTeX one unrelated to
Sphinx.

To investigate better is it possible you make a copy of
your on-going Sphinx project, keeping only in the source
one heading and sub-heading and one sentence (it
does not have to make senses) in each source document?

(we only need obviously a few paragraphs of text to test this)

Then execute make latexpdf and share the result i.e.
both the rst sources and the latex build repertory
as one small zip archive?

To understand the problem I need indeed both the .tex
file produced by Sphinx and the .log file produced by
latex (both will be in latex build repertory), and it is
simpler to get the entire repertory in case (this is not
probable) some problem arises from the other files
in there

(perhaps we will simply see tons of LaTeX warnings of
the type
font not available, substitute used)

And prior to executing make latexpdf on such
a new, clean, small, project with the conf.py
using GNU FreeFont as I explained previously

please also insert in your conf.py this extra

latex_elements = {
'passoptionstopackages': r'\XeTeXtracingfonts1\relax',
}


i.e. add to existing latex_elements the above key value pair

J.-F.


tzoumakers tzoumakers

unread,
Nov 21, 2019, 6:51:10 AM11/21/19
to sphinx...@googlegroups.com
Hi JF

i created a new project from the very beginning for testing purposes.
It only contains two pages, table of contents , actually a few lines of text.
So simple that can be debugged.

In the clean conf.py I added:

1. latex_engine = 'xelatex'
2. language = 'el' (introduced when quickstart script asked me to )
3. in latex_elements :
 -- the previously given font stuff
 -- the new passoptionstopackages thing
4. at the very end, the version script

In the zip file (from google drive - could not attach it otherwise) you will also find the file output.txt which is actually the redirection of the command line output into that file (in the file I explain what i did).
And my small script to run 'make latexpdf' for convenience.

Again, thanks a lot for your time.
Nikos
ERROR: google will not allow me to post a zip file, is it ok to send it to your email instead?

jfbu

unread,
Nov 21, 2019, 7:26:29 AM11/21/19
to sphinx...@googlegroups.com
Le 21/11/2019 à 12:50, tzoumakers tzoumakers a écrit :
> ERROR: google will not allow me to post a zip file, is it ok to send it to your email instead?
>
> -
Hi,

My email is not public on GitHub and I don't know what happens
if you reply the my @public.gmane.org thing showing up in
the headers in the newsreader (Thunderbird, as I don't use
google groups web interface).

However if you search on https://startpage.com/

(who uses google.com directly nowadays? damn all trackers)

"jfbu latex" and scroll down the list

you will quickly find some references to latex packages on ctan
and you will identify quickly an email address which you can use

Please don't post this email address here.

(although one sees it in the commit messages to sphinx dev repo :) )

are you sure you can't attach a file to your message?

trying here to see what happens from my Thunderbird interface

(group is gmane.comp.python.sphinx.user)

with emptyfile.zip archive



Best,

Jean-François
emptyfile.zip

jfbu

unread,
Nov 21, 2019, 1:21:02 PM11/21/19
to sphinx...@googlegroups.com
Hi all,

Nikos sent files to me off-list.

And the explanation is very simple.

I had **completely** forgotten that prior to Sphinx 2.0.0,
the LaTeX writer escaped Greek letter (without diacritics)
to LaTeX math mark-up hence they used the math font.

Hence it was simply impossible
to have Greek as main language in a document. (although
one could get Greek letters with diacritics look fine)

I should have recognized the glyphs on Nikos pictures,
but in addition of having nil memory, I also have blurry
vision.

Thus Nikos absolutely needs to use Sphinx from the 2.x
series, and ideally at least Sphinx 2.2.1.

In addition thanks to Nikos test Greek sample
I realized perhaps it was better to use

smartquotes = False

in conf.py

(see http://www.sphinx-doc.org/en/master/usage/configuration.html#confval-smartquotes)

or possibly to modify smartquotes_excludes.

Perhaps Nikos will confirm or invalidate that last point. (we can incorporate that upstream like for Japanese)

For more related info, check "Greek" inside the Sphinx CHANGES file


http://www.sphinx-doc.org/en/master/changes.html

In brief,

Only way to get PDF output via LaTeX from Sphinx for
Greek as main language is to use Sphinx 2.2.1 or later...

(at least Sphinx 2.0.0 but then some extras are needed in conf.py)

Sorry for latency in saying something useful...

Jean-François


tzoumakers tzoumakers

unread,
Nov 21, 2019, 1:43:40 PM11/21/19
to sphinx...@googlegroups.com
Jean Francois,

i would like to thank you for the time and effort in my problem.
Indeed using a later version of Sphinx solved the problem.

But I think I need to explain how to install it in Ubuntu cause that was probably the initial problem.
I am using Ubuntu 19.10 which has Sphinx 1.8.5 in its repositories.
I am not aware of any other way to install the latest (2.2.1) version of Sphinx, other than the python tool named pip (as stated in Sphinx documentation for installation)
One problem i faced with it, was that i had to install pip3 (note the 3 at the end) through the Ubuntu repo.
Afterwards, installing Sphinx was pretty straightforward. However, it is installed in /home and PATH is not updated.
So in my project anything like 'make latexpdf' would use the Ubuntu version of Sphinx, hence 1.8.5 .
I uninstalled the ubuntu version but still PATH was missing the sphinx path (the one under /home)
After updating the PATH environmental variable with appropriate path, then i was able to build latex and produce pdf.
Correctly!  (as far as i have seen till now)
So once again, thanks Jean-Francois!

Nikos

--
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.

jfbu

unread,
Nov 22, 2019, 7:29:22 AM11/22/19
to sphinx...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages