public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Akira Yokosawa <akiyks@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Akira Yokosawa <akiyks@gmail.com>
Subject: Re: [PATCH] docs: Activate xeCJK only in CJK chapters
Date: Sun, 23 May 2021 08:21:40 +0900	[thread overview]
Message-ID: <1bb6a68a-70cb-3f3a-462b-5ad124d0253e@gmail.com> (raw)
In-Reply-To: <20210522201439.156bded8@coco.lan>

On Sat, 22 May 2021 20:14:39 +0200, Mauro Carvalho Chehab wrote:
> Em Sat, 22 May 2021 16:28:55 +0900
> Akira Yokosawa <akiyks@gmail.com> escreveu:
> 
>> Activating xeCJK in English or Italian-translation documents
>> results in sub-optimal typesetting with wide-looking apostrophes
>> and quotation marks.
>>
>> The xeCJK package provides macros for enabling and disabling its
>> effect in the middle of a document, namely \makexeCJKactive and
>> \makexeCJKinactive.
>>
>> So the goal of this change is to activate xeCJK in the relevant
>> chapters in translations.
>>
>> To do this:
>>
>>     o Define custom macros in the preamble depending on the
>>       availability of the "Noto Sans CJK" font so that those
>>       macros can be embedded in translations.tex after the fact.
>>       By default, xeCJK is inactive.
>>
>>     o Add a script retouch-translations.sh to embed the on/off
>>       macros in translations.tex where necessary.
>>       The patterns in the script are ad-hoc by nature, and will
>>       need updates when the chapter organization changes.
>>
>>     o Invoke the script at the final step of target "latexdocs".
> 
> Interesting solution, but there are probably an easy/better
> way of doing something similar to it.
> 
> There is an extension called:
> 
> 	Documentation/sphinx/load_config.py
> 
> Which allows using a per-document conf.py file. While it can also be
> used to have a "nitpick" version where extra warnings are enabled,
> the main usage were to have separated PDF documents. 
> 
> We ended finding a better solution, so most conf.py got removed
> on this patch: 9fc3a18a942f ("docs: remove extra conf.py files").
> 
> Anyway, perhaps we could simply add a Documentation/translations/conf.py
> that would add the CJK font only there.

Ah, that sounds like the way to go!

But I have no idea how I can load that extra conf.py for translations.

Simply putting the following as Documentation/translations/conf.py
doesn't work.

----
# -*- coding: utf-8; mode: python -*-

# translations have Asian characters
# which are only displayed if xeCJK is used

cjk_cmd = check_output(['fc-list', '--format="%{family[0]}\n"']).decode('utf-8', 'ignore')
if cjk_cmd.find("Noto Sans CJK SC") >= 0:
    print ("translations: enabling CJK for LaTeX builder")
    latex_elements['preamble']  += '''
	% This is needed for translations
        \\usepackage{xeCJK}
        \\setCJKmainfont{Noto Sans CJK SC}
     '''
----

What am I missing?

Note: I'm not good at python.

       Thanks, Akira
> 
> Even better, we could even improve it in a way that each translation
> would generate a separated book, and then use CJK only for the
> non-Latin translations.
> 
> Regards,
> Mauro
> 

  reply	other threads:[~2021-05-22 23:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-22  7:28 [PATCH] docs: Activate xeCJK only in CJK chapters Akira Yokosawa
2021-05-22 16:56 ` Wu X.C.
2021-05-22 23:35   ` Akira Yokosawa
2021-05-22 18:14 ` Mauro Carvalho Chehab
2021-05-22 23:21   ` Akira Yokosawa [this message]
2021-05-25 11:17 ` [PATCH v2] docs: Activate exCJK " Akira Yokosawa
2021-05-25 12:30   ` Wu X.C.
2021-05-25 12:55     ` Akira Yokosawa
2021-05-25 13:39       ` Mauro Carvalho Chehab
2021-05-25 13:38 ` [PATCH v3] " Akira Yokosawa
2021-05-25 15:25 ` [PATCH v4] " Akira Yokosawa
2021-05-27 16:00   ` Jonathan Corbet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1bb6a68a-70cb-3f3a-462b-5ad124d0253e@gmail.com \
    --to=akiyks@gmail.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox