groff-commit
[Top][All Lists]
Advanced

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

[groff] 13/14: [man]: Fix manual section title localization.


From: G. Branden Robinson
Subject: [groff] 13/14: [man]: Fix manual section title localization.
Date: Mon, 24 Jan 2022 10:28:42 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 57b3e1074f01b5a6cebc99461db1c19cb6720071
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Jan 24 20:21:47 2022 +1100

    [man]: Fix manual section title localization.
    
    Commit c64fd60dff was not quite cooked.  The localized strings (in
    English) for the manual section titles need to be set at every document
    load (i.e., when `TH` is called), but only if the groff locale is
    "english".  When switching locales, these strings were getting "stuck"
    in their non-English translations even when returning to an English
    page.
    
    * tmac/an.tmac (an*localize): New macro initializes strings.
    
      (TH): Call `an*localize` if the locale is "english".
    
      (initialization): Drop initialization of section title strings.
    
    Continues fixing <https://savannah.gnu.org/bugs/?61734>.
    
    Tested with several scenarios, including this one that starts out with a
    non-English page and then switches back and forth between languages.
    The package is not tripped up and the center header remains appropriate.
    
    $ ./build/test-groff -man -msv EXPERIMENTS/swedish.1 \
      tmac/en.tmac EXPERIMENTS/english.1 \
      tmac/sv.tmac EXPERIMENTS/swedish.1 \
      tmac/en.tmac EXPERIMENTS/english.1
---
 ChangeLog    | 15 +++++++++++++++
 tmac/an.tmac | 29 ++++++++++++++++++-----------
 2 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7e4e0c10..122bb765 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2022-01-24  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [man]: Commit c64fd60dff was not quite cooked.  The localized
+       strings (in English) for the manual section titles need to be
+       set at every document load (i.e., when `TH` is called), but only
+       if the groff locale is "english".  When switching locales, these
+       strings were getting "stuck" in their non-English translations
+       even when returning to an English page.
+
+       * tmac/an.tmac (an*localize): New macro initializes strings.
+       (TH): Call `an*localize` if the locale is "english".
+       (initialization): Drop initialization of section title strings.
+
+       Continues fixing <https://savannah.gnu.org/bugs/?61734>.
+
 2022-01-24  Deri James  <deri@chuzzlewit.myzen.co.uk>
 
        [gropdf]: Fix Savannah #61908
diff --git a/tmac/an.tmac b/tmac/an.tmac
index df09e86a..4ec18386 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -1,6 +1,6 @@
 .\" an.tmac
 .\"
-.\" Copyright (C) 1989-2021 Free Software Foundation, Inc.
+.\" Copyright (C) 1989-2022 Free Software Foundation, Inc.
 .\"      Written by James Clark (jjc@jclark.com)
 .\"
 .\" This file is part of groff.
@@ -159,6 +159,21 @@
 .  el        .bp 1
 ..
 .
+.
+.\" Localize manual section titles for English.
+.de an*localize
+.  ds an*section1 General Commands Manual\"
+.  ds an*section2 System Calls Manual\"
+.  ds an*section3 Library Functions Manual\"
+.  ds an*section4 Kernel Interfaces Manual\"
+.  ds an*section5 File Formats Manual\"
+.  ds an*section6 Games Manual\"
+.  ds an*section7 Miscellaneous Information Manual\"
+.  ds an*section8 System Manager's Manual\"
+.  ds an*section9 Kernel Developer's Manual\"
+..
+.
+.
 .\" Begin man page.
 .\" .TH title section[ extra1[ extra2[ extra3]]]
 .de1 TH
@@ -224,6 +239,8 @@
 .  nr an-need-break 0
 .  nr an-is-in-diversion 0
 .
+.  if '\\*[locale]'english' .an*localize
+.
 .  ds an-title "\\$1\"
 .  if \\n[CT] .stringup an-title
 .  ds an-section "\\$2\"
@@ -982,16 +999,6 @@
 .
 .\" === Initialize. ===
 .
-.ds an*section1 General Commands Manual\"
-.ds an*section2 System Calls Manual\"
-.ds an*section3 Library Functions Manual\"
-.ds an*section4 Kernel Interfaces Manual\"
-.ds an*section5 File Formats Manual\"
-.ds an*section6 Games Manual\"
-.ds an*section7 Miscellaneous Information Manual\"
-.ds an*section8 System Manager's Manual\"
-.ds an*section9 Kernel Developer's Manual\"
-.
 .mso devtag.tmac
 .nr an-devtag-needs-end-of-heading 0
 .nr an-devtag-needs-second-column 0



reply via email to

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