xref: /dflybsd-src/contrib/grep/lib/propername.h (revision 91b9ed38d3db6a8a8ac5b66da1d43e6e331e259a)
1dc7c36e4SJohn Marino /* Localization of proper names.  -*- coding: utf-8 -*-
2*09d4459fSDaniel Fojt    Copyright (C) 2006, 2008-2020 Free Software Foundation, Inc.
395b7b453SJohn Marino    Written by Bruno Haible <bruno@clisp.org>, 2006.
495b7b453SJohn Marino 
595b7b453SJohn Marino    This program is free software: you can redistribute it and/or modify
695b7b453SJohn Marino    it under the terms of the GNU General Public License as published by
795b7b453SJohn Marino    the Free Software Foundation; either version 3 of the License, or
895b7b453SJohn Marino    (at your option) any later version.
995b7b453SJohn Marino 
1095b7b453SJohn Marino    This program is distributed in the hope that it will be useful,
1195b7b453SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
1295b7b453SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1395b7b453SJohn Marino    GNU General Public License for more details.
1495b7b453SJohn Marino 
1595b7b453SJohn Marino    You should have received a copy of the GNU General Public License
16*09d4459fSDaniel Fojt    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
1795b7b453SJohn Marino 
1895b7b453SJohn Marino /* INTRODUCTION
1995b7b453SJohn Marino 
2095b7b453SJohn Marino    What do
2195b7b453SJohn Marino 
2295b7b453SJohn Marino       Torbjörn Granlund    (coreutils)
2395b7b453SJohn Marino       François Pinard      (coreutils)
2495b7b453SJohn Marino       Danilo Šegan         (gettext)
2595b7b453SJohn Marino 
2695b7b453SJohn Marino    have in common?
2795b7b453SJohn Marino 
2895b7b453SJohn Marino    A non-ASCII name. This causes trouble in the --version output. The simple
29dc7c36e4SJohn Marino    "solution" unfortunately mutilates the name.
3095b7b453SJohn Marino 
3195b7b453SJohn Marino      $ du --version | grep Granlund
3295b7b453SJohn Marino      Écrit par Torbjorn Granlund, David MacKenzie, Paul Eggert et Jim Meyering.
3395b7b453SJohn Marino 
3495b7b453SJohn Marino      $ ptx --version | grep Pinard
3595b7b453SJohn Marino      Écrit par F. Pinard.
3695b7b453SJohn Marino 
3795b7b453SJohn Marino    What is desirable, is to print the full name if the output character set
3895b7b453SJohn Marino    allows it, and the ASCIIfied name only as a fallback.
3995b7b453SJohn Marino 
4095b7b453SJohn Marino      $ recode-sr-latin --version
4195b7b453SJohn Marino      ...
4295b7b453SJohn Marino      Written by Danilo Šegan and Bruno Haible.
4395b7b453SJohn Marino 
4495b7b453SJohn Marino      $ LC_ALL=C recode-sr-latin --version
4595b7b453SJohn Marino      ...
4695b7b453SJohn Marino      Written by Danilo Segan and Bruno Haible.
4795b7b453SJohn Marino 
4895b7b453SJohn Marino    The 'propername' module does exactly this. Plus, for languages that use
4995b7b453SJohn Marino    a different writing system than the Latin alphabet, it allows a translator
5095b7b453SJohn Marino    to write the name using that different writing system. In that case the
5195b7b453SJohn Marino    output will look like this:
5295b7b453SJohn Marino       <translated name> (<original name in English>)
5395b7b453SJohn Marino 
54dc7c36e4SJohn Marino    To use the 'propername' module requires three simple steps:
5595b7b453SJohn Marino 
5695b7b453SJohn Marino      1) Add it to the list of gnulib modules to import,
5795b7b453SJohn Marino 
58dc7c36e4SJohn Marino      2) Change the arguments of version_etc(),
5995b7b453SJohn Marino 
6095b7b453SJohn Marino           from "Paul Eggert"
6195b7b453SJohn Marino           to   proper_name ("Paul Eggert")
6295b7b453SJohn Marino 
6395b7b453SJohn Marino           from "Torbjorn Granlund"
6495b7b453SJohn Marino           to   proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund")
6595b7b453SJohn Marino 
6695b7b453SJohn Marino           from "F. Pinard"
6795b7b453SJohn Marino           to   proper_name_utf8 ("Franc,ois Pinard", "Fran\303\247ois Pinard")
6895b7b453SJohn Marino 
6995b7b453SJohn Marino         (Optionally, here you can also add / * TRANSLATORS: ... * / comments
7095b7b453SJohn Marino         explaining how the name is written or pronounced.)
7195b7b453SJohn Marino 
7295b7b453SJohn Marino      3) If you are using GNU gettext version 0.16.1 or older, in po/Makevars,
7395b7b453SJohn Marino         in the definition of the XGETTEXT_OPTIONS variable, add:
7495b7b453SJohn Marino 
7595b7b453SJohn Marino            --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."'
7695b7b453SJohn Marino            --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."'
7795b7b453SJohn Marino 
7895b7b453SJohn Marino         This specifies automatic comments for the translator. (Requires
7995b7b453SJohn Marino         xgettext >= 0.15. The double-quotes inside the quoted string are on
8095b7b453SJohn Marino         purpose: they are part of the --keyword argument syntax.)
8195b7b453SJohn Marino  */
8295b7b453SJohn Marino 
8395b7b453SJohn Marino #ifndef _PROPERNAME_H
8495b7b453SJohn Marino #define _PROPERNAME_H
8595b7b453SJohn Marino 
8695b7b453SJohn Marino 
8795b7b453SJohn Marino #ifdef __cplusplus
8895b7b453SJohn Marino extern "C" {
8995b7b453SJohn Marino #endif
9095b7b453SJohn Marino 
9195b7b453SJohn Marino /* Return the localization of NAME.  NAME is written in ASCII.  */
92cf28ed85SJohn Marino extern const char * proper_name (const char *name) /* NOT attribute const */;
9395b7b453SJohn Marino 
9495b7b453SJohn Marino /* Return the localization of a name whose original writing is not ASCII.
9595b7b453SJohn Marino    NAME_UTF8 is the real name, written in UTF-8 with octal or hexadecimal
9695b7b453SJohn Marino    escape sequences.  NAME_ASCII is a fallback written only with ASCII
9795b7b453SJohn Marino    characters.  */
9895b7b453SJohn Marino extern const char * proper_name_utf8 (const char *name_ascii,
9995b7b453SJohn Marino                                       const char *name_utf8);
10095b7b453SJohn Marino 
10195b7b453SJohn Marino #ifdef __cplusplus
10295b7b453SJohn Marino }
10395b7b453SJohn Marino #endif
10495b7b453SJohn Marino 
10595b7b453SJohn Marino 
10695b7b453SJohn Marino #endif /* _PROPERNAME_H */
107