[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Coordination on standardizing gettext() in future POSIX
From: |
Bruno Haible |
Subject: |
Re: Coordination on standardizing gettext() in future POSIX |
Date: |
Tue, 21 Jan 2020 20:10:49 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-171-generic; KDE/5.18.0; x86_64; ; ) |
Hi Jörg,
Regarding the gettext(1) program and whether it expands escape sequences
by default:
1) [1] is ambiguous / self-contradictory.
On one hand it says:
This utility interprets C escape sequences such as \t for tab. Use \\ to
print a backslash...
Which sounds like they are expanded by default.
On the other hand it says:
OPTIONS
-e
Enable expansion of some escape sequences.
Which sounds like they are NOT expanded by default.
So, you can't resolve this question by referencing an ambiguous specification.
2) GNU gettext(1) and Solaris gettext(1) differ in this respect:
GNU:
$ gettext 'abc\ndef'; echo
abc\ndef
Solaris:
$ gettext 'abc\ndef'; echo
abc
def
This makes it hard to standardize, since the behaviours differ, and
both implementations will want to claim need for backward-compatibility.
3) Additionally, there's the problem that gettext(1) does not and can not
(as a program) deal with strings that contain placeholders. As soon as
the shell program to be internationalized references variables in its
strings, you need a shell function. In GNU gettext, it is called 'eval_gettext'
[2]. Even the simple hello-world program shows the need for this shell
function:
=========================================================================
#!/bin/sh
# Example for use of GNU gettext.
# This file is in the public domain.
#
# Source code of the POSIX sh program.
. gettext.sh
TEXTDOMAIN=hello-sh
export TEXTDOMAIN
TEXTDOMAINDIR='@localedir@'
export TEXTDOMAINDIR
gettext "Hello, world!"; echo
pid=$$
eval_gettext "This program is running as process number \$pid."; echo
=========================================================================
Because of 2) and 3), I think it would be a mistake to standardize the
Solaris gettext(1) behaviour:
- It would be contradicting wide use on GNU/Linux systems,
- It would ignore half of the functionality that even simple shell
scripts need.
Bruno
[1]
http://web.archive.org/web/20030428195733/http://www.li18nux.org/docs/html/LI18NUX-2000-amd4.htm
[2] https://www.gnu.org/software/gettext/manual/html_node/sh.html
- Re: Coordination on standardizing gettext() in future POSIX, Joerg Schilling, 2020/01/21
- Re: Coordination on standardizing gettext() in future POSIX,
Bruno Haible <=
- Re: Coordination on standardizing gettext() in future POSIX, Joerg Schilling, 2020/01/22
- Re: Coordination on standardizing gettext() in future POSIX, Joerg Schilling, 2020/01/23
- Re: Coordination on standardizing gettext() in future POSIX, Bruno Haible, 2020/01/24
- Re: Coordination on standardizing gettext() in future POSIX, Joerg Schilling, 2020/01/24
- About printf %2$s (Was: Coordination on standardizing gettext() in future POSIX), Stephane Chazelas, 2020/01/31