+2023-06-02 Paul Eggert <eggert@cs.ucla.edu>
+
+ propername-lite: new module
+ propername_lite acts like propername_utf8 but needs less
+ infrastructure, e.g., it does not worry about memory allocation.
+ * MODULES.html.sh (func_all_modules): Mention it.
+ * lib/propername.h (proper_name_lite): New decl.
+ * lib/propername-lite.c, modules/propername-lite: New files.
+ * pygnulib/GLEmiter.py (GLEmiter.po_Makevars):
+ Treat proper_name_lite like proper_name_utf8.
+
2023-06-02 Bruno Haible <bruno@clisp.org>
openmp-init: Silence "no previous prototype for 'openmp_init'" warning.
func_module gettext
func_module gettext-h
func_module propername
+ func_module propername-lite
func_module iconv
func_module striconv
func_module xstriconv
--- /dev/null
+/* Localization of proper names.
+ Copyright 2023 Free Software Foundation, Inc.
+
+ This program 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.
+
+ This program 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 <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "propername.h"
+
+#include "c-strcase.h"
+#include "gettext.h"
+#include "localcharset.h"
+
+/* Return the localization of the name spelled NAME_ASCII in ASCII,
+ and NAME_UTF8 in UTF-8. */
+
+char const *
+proper_name_lite (char const *name_ascii, char const *name_utf8)
+{
+ char const *translation = gettext (name_ascii);
+ return (translation != name_ascii ? translation
+ : c_strcasecmp (locale_charset (), "UTF-8") == 0 ? name_utf8
+ : name_ascii);
+}
...
Written by Danilo Segan and Bruno Haible.
- The 'propername' module does exactly this. Plus, for languages that use
- a different writing system than the Latin alphabet, it allows a translator
+ The 'propername' and 'propername-lite’ modules do this. Plus, for
+ languages that do not use the Latin alphabet, they allow a translator
to write the name using that different writing system. In that case the
- output will look like this:
+ propername and propername_utf8 output will look like this:
<translated name> (<original name in English>)
+ whereas the propername_lite output will just be the translated name
+ if available, otherwise the original name (in UTF-8 if possible and
+ in ASCII if not).
To use the 'propername' module requires two simple steps:
from "Torbjorn Granlund"
to proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund")
+ or proper_name_lite ("Torbjorn Granlund", "Torbj\303\266rn Granlund")
from "F. Pinard"
to proper_name_utf8 ("Franc,ois Pinard", "Fran\303\247ois Pinard")
+ or proper_name_lite ("Franc,ois Pinard", "Fran\303\247ois Pinard")
+
+ In source code, the second argument of proper_name_lite and
+ proper_name_utf8 should use octal escapes, not UTF-8 - e.g.,
+ "Fran\303\247ois Pinard", not "François Pinard". Doing it
+ this way can avoid mishandling non-ASCII characters if the
+ source is recoded to non-UTF8, or if the compiler does not
+ treat UTF-8 as-is in character string contents.
(Optionally, here you can also add / * TRANSLATORS: ... * / comments
explaining how the name is written or pronounced.)
+
+ Here is an example in context.
+
+ printf (_("Written by %s and %s.\n"),
+ / * TRANSLATORS: This is the proper name "Danilo Šegan".
+ In the original Cyrillic it is "Данило Шеган". * /
+ proper_name_utf8 ("Danilo Segan", "Danilo \305\240egan"),
+ proper_name ("Bruno Haible"));
*/
#ifndef _PROPERNAME_H
extern const char * proper_name_utf8 (const char *name_ascii,
const char *name_utf8);
+/* Return the localization of the name spelled NAME_ASCII in ASCII,
+ and NAME_UTF8 in UTF-8. This function needs less infrastructure
+ than proper_name and proper_name_utf8. */
+extern const char *proper_name_lite (const char *name_ascii,
+ const char *name_utf8);
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+Description:
+Lighter-weight localization of proper names.
+
+Files:
+lib/propername-lite.c
+lib/propername.h
+
+Depends-on:
+localcharset
+c-strcase
+gettext-h
+
+configure.ac:
+m4_ifdef([AM_XGETTEXT_OPTION],
+ [AM_][XGETTEXT_OPTION([--keyword='proper_name_lite:1,\"This is a proper name. See the gettext manual, section Names.\"'])])
+
+Makefile.am:
+lib_SOURCES += propername-lite.c propername.h
+
+Include:
+"propername.h"
+
+License:
+LGPL
+
+Maintainer:
+all
--keyword=_ --flag=_:1:pass-c-format \\
--keyword=N_ --flag=N_:1:pass-c-format \\
--keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \\
+ --keyword='proper_name_lite:1,"This is a proper name. See the gettext manual, section Names."' \\
--keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \\
--flag=error:3:c-format --flag=error_at_line:5:c-format