commit db993c17e02b3924eca88d112c3f0342f1ce7a5d
Author:     G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Jan 15 03:38:11 2021 +1100
Commit:     G. Branden Robinson <g.branden.robinson@gmail.com>
CommitDate: Fri Jan 15 13:53:09 2021 +1100

    [docs]: Update hyphenation and localization stuff.

diff --git a/doc/groff.texi b/doc/groff.texi
index fab68a50..9efc1be9 100644
--- a/doc/groff.texi
+++ b/doc/groff.texi
@@ -26,7 +26,7 @@
 @copying
 This manual documents GNU @code{troff} version 1.23.0.
 
-Copyright @copyright{} 1994--2020 Free Software Foundation, Inc.
+Copyright @copyright{} 1994--2021 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -7271,7 +7271,8 @@ powers of two for the configuration parameters; they are computationally
 easy to ``mask off'' and compare to zero.  To almost everyone else, the
 arrangement seems recondite and unfriendly.}  The entries in the table
 below are termed @dfn{values}, and the sum of the desired values is the
-@dfn{mode}.
+@dfn{mode}.  The default hyphenation mode depends on the language in use
+on the system; see the @code{hpf} request below.
 
 @table @code
 @item 0
@@ -7279,8 +7280,7 @@ disables hyphenation.
 
 @item 1
 enables hyphenation except after the first and before the last character
-of a word; this is the default if @var{mode} is omitted and also the
-start-up value of GNU @code{troff}.
+of a word.
 @end table
 
 The remaining values ``imply'' 1; that is, they enable hyphenation
@@ -7350,12 +7350,12 @@ s- plit- t- in- g
 @endExample
 
 @noindent
-instead of the correct `split- ting'.  U.S. English patterns as
-distributed with GNU @code{troff} need two characters at the beginning
-and three characters at the end; this means that value@tie{}4 of
-@code{hy} is mandatory.  Value@tie{}8 is possible as an additional
-restriction, but values@tie{}16 and@tie{}32 should be avoided, as should
-mode@tie{}1 (the default!).  Modes@tie{}4 and@tie{}6 are typical.
+instead of the correct `split- ting'.  English patterns as distributed
+with GNU @code{troff} need two characters at the beginning and three
+characters at the end; this means that value@tie{}4 of @code{hy} is
+mandatory.  Value@tie{}8 is possible as an additional restriction, but
+values@tie{}16 and@tie{}32 should be avoided, as should mode@tie{}1 (the
+default!).  Modes@tie{}4 and@tie{}6 are typical.
 
 A table of left and right minimum character counts for hyphenation as
 needed by the patterns distributed with GNU @code{troff} follows; see
@@ -7365,7 +7365,7 @@ the @cite{groff_tmac@r{(5)}} man page for more information on GNU
 @multitable {German traditional}    {pattern name}    {left min}    {right min}
 @headitem    language           @tab pattern name @tab left min @tab right min
 @item        Czech              @tab cs           @tab 2        @tab 2
-@item        U.S. English       @tab us           @tab 2        @tab 3
+@item        English            @tab en           @tab 2        @tab 3
 @item        French             @tab fr           @tab 2        @tab 3
 @item        German traditional @tab det          @tab 2        @tab 2
 @item        German reformed    @tab den          @tab 2        @tab 2
@@ -7452,15 +7452,32 @@ Character codes that would otherwise be invalid in GNU @code{troff} can
 be used.  By default, every code maps to itself except those for letters
 `A' to `Z', which map to those for `a' to `z'.
 
+@cindex localization
 @pindex troffrc
 @pindex troffrc-end
-@pindex hyphen.us
-@pindex hyphenex.us
+@pindex cs.tmac
+@pindex de.tmac
+@pindex en.tmac
+@pindex fr.tmac
+@pindex ja.tmac
+@pindex sv.tmac
+@pindex zh.tmac
+@tindex LC_ALL
+@tindex LANG
 The set of hyphenation patterns is associated with the language set by
 the @code{hla} request.  The @code{hpf} request is usually invoked by
-the @file{troffrc} or @file{troffrc-end} file; by default,
-@file{troffrc} loads hyphenation patterns and exceptions for U.S.
-English (in files @file{hyphen.us} and @file{hyphenex.us}).
+a localization file loaded by the @file{troffrc} or @file{troffrc-end}
+file.  By default, @file{troffrc} checks the environment variables
+@env{LC_ALL} and @env{LANG} (in that order) and attempts to load a
+localization file matching the first two characters of the variable's
+value.@footnote{As of @code{groff} 1.23.0, localization files for Czech
+(@code{cs}), German (@code{de}), English (@code{en}), French
+(@code{fr}), Japanese (@code{ja}), Swedish (@code{sv}), and Chinese
+(@code{zh}) exist.}  For Western languages, the localization file sets
+the hyphenation mode and loads hyphenation patterns and exceptions.  If
+the environment variables are not set, set to ``C'', or a localization
+file for the locale does not exist, the English localization file is
+used.
 
 A second call to @code{hpf} (for the same language) replaces the
 hyphenation patterns with the new ones.
@@ -7469,8 +7486,8 @@ Invoking @code{hpf} or @code{hpfa} causes an error if there is no
 hyphenation language.
 
 If no @code{hpf} request is specified (either in the document, in a
-@file{troffrc} or @file{troffrc-end} file, or in a macro package), GNU
-@code{troff} won't automatically hyphenate at all.
+file loaded at start-up, or in a macro package), GNU @code{troff} won't
+automatically hyphenate at all.
 @endDefreq
 
 @Defreq {hcode, c1 code1 [c2 code2] @dots{}}
@@ -7521,8 +7538,9 @@ Set the hyphenation language to @var{lang}.  Hyphenation exceptions
 specified with the @code{hw} request and hyphenation patterns and
 exceptions specified with the @code{hpf} and @code{hpfa} requests are
 associated with the hyphenation language.  The @code{hla} request is
-usually invoked by the @file{troffrc} or @file{troffrc-end} files;
-@file{troffrc} sets the default language to @samp{us} (U.S. English).
+usually invoked by a localization file, which is in turn loaded by the
+the @file{troffrc} or @file{troffrc-end} file; see the @code{hpf}
+request above.
 
 The hyphenation language is associated with the current environment
 (@pxref{Environments}).
@@ -7534,7 +7552,7 @@ register @samp{.hla}.
 @Example
 .ds curr_language \n[.hla]
 \*[curr_language]
-    @result{} us
+    @result{} en
 @endExample
 @endDefreq
 
@@ -15259,7 +15277,7 @@ implementations.
 @cindex hyphenation, incompatibilities with @acronym{AT&T} @code{troff}
 GNU @code{troff} does not always hyphenate words as @acronym{AT&T}
 @code{troff} does.  The @acronym{AT&T} implementation uses a set of
-hard-coded rules specific to U.S. English, while GNU @code{troff} uses
+hard-coded rules specific to English, while GNU @code{troff} uses
 language-specific hyphenation pattern files derived from @TeX{}.
 Furthermore, in old versions of @code{troff} there was a limited amount
 of space to store hyphenation exceptions (arguments to the @code{hw}

commit ea58825c604ab677c55fab4476bc6f0b8abfc777
Author:     G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Jan 15 03:27:15 2021 +1100
Commit:     G. Branden Robinson <g.branden.robinson@gmail.com>
CommitDate: Fri Jan 15 13:53:08 2021 +1100

    tmac/en.tmac: Set hyphenation mode to 4.

diff --git a/tmac/en.tmac b/tmac/en.tmac
index 6aae40db..0bc41967 100644
--- a/tmac/en.tmac
+++ b/tmac/en.tmac
@@ -22,6 +22,9 @@
 .
 .ds locale english\"
 .
+.\" Set the minimum hyphenation mode that works with the patterns.
+.hy 4
+.
 .\" Set the hyphenation language to English.
 .do hla en
 .

commit a704c76b9b909b832f37a47933dae664c5f2e76a
Author:     G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jan 4 17:53:05 2021 +1100
Commit:     G. Branden Robinson <g.branden.robinson@gmail.com>
CommitDate: Fri Jan 15 13:53:08 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).

diff --git a/tmac/troffrc b/tmac/troffrc
index d0d54b80..c30ae736 100644
--- a/tmac/troffrc
+++ b/tmac/troffrc
@@ -54,12 +54,31 @@ 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
+.\" XXX: Consider not merging this until we have a "quiet" version of
+.\" .mso (and .so).
+.do mso \*[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

commit 55af800b24976861e76cd1f7bee640d50f790ebd
Author:     G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jan 4 17:44:57 2021 +1100
Commit:     G. Branden Robinson <g.branden.robinson@gmail.com>
CommitDate: Fri Jan 15 13:53:08 2021 +1100

    tmac/en.tmac: Add English localization file.

diff --git a/tmac/en.tmac b/tmac/en.tmac
new file mode 100644
index 00000000..6aae40db
--- /dev/null
+++ b/tmac/en.tmac
@@ -0,0 +1,38 @@
+.\" English localization for groff
+.\"
+.\" Copyright (C) 2021 Free Software Foundation, Inc.
+.\"
+.\" This file is part of groff.
+.\"
+.\" groff is free software; you can redistribute it and/or modify it
+.\" under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation, either version 3 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" groff is distributed in the hope that it will be useful, but WITHOUT
+.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+.\" License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with this program.  If not, see
+.\" <http://www.gnu.org/licenses/>.
+.\"
+.\" Please send comments to groff@gnu.org.
+.
+.ds locale english\"
+.
+.\" Set the hyphenation language to English.
+.do hla en
+.
+.\" Load hyphenation patterns and exceptions.
+.do hpf hyphen.en
+.do hpfa hyphenex.en
+.
+.
+.\" Local Variables:
+.\" mode: nroff
+.\" coding: latin-1
+.\" fill-column: 72
+.\" End:
+.\" vim: set filetype=groff textwidth=72:
diff --git a/tmac/tmac.am b/tmac/tmac.am
index e953df45..13d33501 100644
--- a/tmac/tmac.am
+++ b/tmac/tmac.am
@@ -77,6 +77,7 @@ TMACNORMALFILES = \
   tmac/troffrc \
   tmac/troffrc-end \
   tmac/trans.tmac \
+  tmac/en.tmac \
   tmac/hyphen.en \
   tmac/hyphenex.en \
   tmac/fr.tmac \

commit ad9f00c55d122a8fe44c576798f1aa0abb17e545
Author:     G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jan 4 17:10:20 2021 +1100
Commit:     G. Branden Robinson <g.branden.robinson@gmail.com>
CommitDate: Fri Jan 15 13:53:08 2021 +1100

    [troffrc]: Change hyphenation language us to en.
    
    The first-order determinant of hyphenation points is language, not
    territory.  Use ISO 639 2-letter language codes for hyphenation and
    exception patterns instead of ISO 3166 2-letter territory codes.

diff --git a/tmac/troffrc b/tmac/troffrc
index 2ba343ef..d0d54b80 100644
--- a/tmac/troffrc
+++ b/tmac/troffrc
@@ -54,12 +54,12 @@ troffrc!html
 .el \
 .	do tr \[char65]\~
 .
-.\" Set the hyphenation language to 'us'.
-.do hla us
+.\" Set the hyphenation language to English.
+.do hla en
 .
 .\" Load hyphenation patterns and exceptions.
-.do hpf hyphen.us
-.do hpfa hyphenex.us
+.do hpf hyphen.en
+.do hpfa hyphenex.en
 .
 .\" Handle paper formats.
 .do mso papersize.tmac

commit 7e4a5de02eebc36fb1b590b9d24aaf5d5d8eecaf
Author:     G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jan 4 16:59:03 2021 +1100
Commit:     G. Branden Robinson <g.branden.robinson@gmail.com>
CommitDate: Fri Jan 15 13:53:08 2021 +1100

    tmac: Rename *.us to *.en.
    
    The first-order determinant of hyphenation points is language, not
    territory.  Use ISO 639 2-letter language codes for hyphenation and
    exception patterns instead of ISO 3166 2-letter territory codes.

diff --git a/tmac/hyphen.us b/tmac/hyphen.en
similarity index 100%
rename from tmac/hyphen.us
rename to tmac/hyphen.en
diff --git a/tmac/hyphenex.us b/tmac/hyphenex.en
similarity index 100%
rename from tmac/hyphenex.us
rename to tmac/hyphenex.en
diff --git a/tmac/tmac.am b/tmac/tmac.am
index e91110b3..e953df45 100644
--- a/tmac/tmac.am
+++ b/tmac/tmac.am
@@ -77,8 +77,8 @@ TMACNORMALFILES = \
   tmac/troffrc \
   tmac/troffrc-end \
   tmac/trans.tmac \
-  tmac/hyphen.us \
-  tmac/hyphenex.us \
+  tmac/hyphen.en \
+  tmac/hyphenex.en \
   tmac/fr.tmac \
   tmac/hyphen.fr \
   tmac/sv.tmac \
