[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 35/54: tmac/troffrc: Derive groff locale from system.
From: |
Keith Marshall |
Subject: |
[groff] 35/54: tmac/troffrc: Derive groff locale from system. |
Date: |
Sat, 23 Oct 2021 16:57:31 -0400 (EDT) |
keithmarshall pushed a commit to branch dev-gropdf-boxes
in repository groff.
commit 4a639b37fc6ce331f4ca4d12cf320ec4c20cd783
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 35/54: tmac/troffrc: Derive groff locale from system.,
Keith Marshall <=