Using "textwrap" package for unwrappable languages (Japanese)

c.buhtz at posteo.jp c.buhtz at posteo.jp
Wed Aug 30 07:32:02 EDT 2023


Hi,

I do use "textwrap" package to wrap longer texts passages. Works well 
with English.
But the source string used is translated via gettext before it is 
wrapped.

Using languages like Japanese or Chinese would IMHO result in unwrapped 
text. Japanese rules do allow to break a line nearly where ever you 
want.

How can I handle it with "textwrap"?

At runtime I don't know which language is really used. So I'm not able 
to decide using "textwrap" or just inserting "\n" every 65 characters.

Another approach would be to let the translators handle the line breaks. 
But I would like to avoid it because some of them don't know what "\n" 
means and they don't know the length rule (in my case 65 characters).

Any ideas about it?

Kind
Christian


More information about the Python-list mailing list