groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 04/10: tmac/troffrc: Derive groff locale from system.


From: G. Branden Robinson
Subject: [groff] 04/10: tmac/troffrc: Derive groff locale from system.
Date: Thu, 15 Apr 2021 06:24:51 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 12434c13bec939a68e543e6aae758bc7e92c3fb0
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jan 4 17:53:05 2021 +1100

    tmac/troffrc: Derive groff locale from system.
    
    Determine the groff locale (default input language) using the system
    locale.  Use the environment if possible.  Try LC_ALL first, then LANG.
    "C" means English (en).  Otherwise, only the first two characters of the
    locale name are used.
    
    Unrecognized locales (those without a supporting xx.tmac file) are
    ignored, and groff falls back to English.
    
    Those who want groff's default locale to differ from LC_ALL/LANG should
    edit this troffrc to source the appropriate groff locale macro file
    (cs.tmac, de.tmac, den.tmac, fr.tmac, ja.tmac, sv.tmac, zh.tmac).
---
 tmac/troffrc | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/tmac/troffrc b/tmac/troffrc
index d0d54b8..3ab545f 100644
--- a/tmac/troffrc
+++ b/tmac/troffrc
@@ -54,12 +54,29 @@ troffrc!html
 .el \
 .      do tr \[char65]\~
 .
-.\" Set the hyphenation language to English.
-.do hla en
 .
-.\" Load hyphenation patterns and exceptions.
-.do hpf hyphen.en
-.do hpfa hyphenex.en
+.\" Determine the groff locale from the environment if possible.  Try
+.\" LC_ALL first, then LANG.  "C" means English (en).  Otherwise, only
+.\" the first two characters of the locale name are used.
+.do ds troffrc!language \V[LC_ALL]
+.do if '\*[troffrc!language]'' \{\
+.      do ds troffrc!language \V[LANG]
+.      do if '\*[troffrc!language]'' \
+.              do ds troffrc!language C
+.\}
+.do if '\*[troffrc!language]'C' \
+.      do ds troffrc!language en
+.do length troffrc!lang_length \*[troffrc!language]
+.do if (\n[troffrc!lang_length] > 2) \
+.      do substring troffrc!language 0 1
+.do msoquiet \*[troffrc!language].tmac
+.do rm troffrc!language
+.do rr troffrc!lang_length
+.\" If the configured system locale has no groff localization, fall back
+.\" to English.
+.do if !d locale \
+.      do mso en.tmac
+.
 .
 .\" Handle paper formats.
 .do mso papersize.tmac



reply via email to

[Prev in Thread] Current Thread [Next in Thread]