[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gettext binaries for Cygwin
From: |
Brian Inglis |
Subject: |
Re: gettext binaries for Cygwin |
Date: |
Wed, 4 Dec 2024 13:15:41 -0700 |
User-agent: |
Mozilla Thunderbird |
On 2024-12-04 09:21, Bruno Haible wrote:
Brian Inglis wrote:
(and the patch history there), all available in the build repo:
https://cygwin.com/git/?p=git/cygwin-packages/gettext.git
The two patches
gettext-0.22.5-gettext-runtime-intl-gnulib-lib-localename-unsafe-c.patch
gettext-0.22.5-gettext-tools-gnulib-lib-localename-unsafe-c.patch
in my understanding have the effect that when a user
- has set their language preference in the Windows Control Panel,
- has not any LC_* or LANG environment variable set,
- uses a Cygwin program that makes use of gettext
(with the usual setlocale(LC_ALL,"") in main()),
no translations will be produced, thus ignoring the Windows Control Panel
setting.
Is my understanding correct?
If so, why is this patch present? Is it considered to be a feature?
The three patches to {tools,runtime{,/intl}/gnulib/lib/localename_unsafe.c
remove the condition on Cygwin as locale is always set properly (unless users
work to do something bad!)
Cygwin Base package base-files installs usual skeleton and default profile
scripts:
https://cygwin.com/git/?p=cygwin-apps/base-files.git;a=tree;f=etc/defaults/etc/profile.d;hb=HEAD
including:
$ tail /etc/profile.d/lang.sh
# The latest version as installed by the Cygwin Setup program can
# always be found at /etc/defaults/etc/profile.d/lang.sh
# Modifying /etc/profile.d/lang.sh directly will prevent
# setup from updating it.
# System-wide lang.sh file
# if no locale variable is set, indicate terminal charset via LANG
test -z "${_LC_ALL_SET_:-${LC_CTYPE:-$LANG}}" && export LANG=$(/usr/bin/locale
-uU)
Also /etc/profile.d/cygwin.sh sets up PATH TMP TEMP PRINTER HOME, and some other
skeletons also do similar setup:
$ grep LANG= /etc/skel/.*
/etc/skel/.mkshrc:#\\builtin export LANG=C LC_CTYPE=$p LC_MEASUREMENT=$p
LC_MESSAGES=$p LC_PAPER=$p
/etc/skel/.profile:export LANG=$(locale -uU)
$ locale --help
...
Default locale information:
-i, --input Print current input locale
-u, --user Print locale of user's default UI language
-s, --system Print locale of system default UI language
-f, --format Print locale of user's regional format settings
(time, numeric & monetary)
-n, --no-unicode Print system default locale for non-Unicode programs
-U, --utf Attach ".UTF-8" to the result
...
$ for o in s u f i n; do export LANG=`locale -${o}U`; \
echo "locale -$o: $LANG `date`"; done
locale -s: en_US.UTF-8 Wed, Dec 4, 2024 12:05:07 PM
locale -u: en_GB.UTF-8 04 Dec 2024 12:05:07
locale -f: en_CA.UTF-8 2024 Dec 04 Wed 12:05:07
locale -i: en_CA.UTF-8 2024 Dec 04 Wed 12:05:07
locale -n: en_CA.UTF-8 2024 Dec 04 Wed 12:05:07
Although there was no match in the default skeleton search above, I personally
use `locale -fU` to set my *Regional* settings, and have argued for "-f" to be
used instead of "-u":
$ grep -C1 LANG ~/.bash_profile
# language
export LANGUAGE=${LANGUAGE:-'en_CA:en_GB:en'}
--
/usr/bin/locale -fU > /dev/null 2>&1 \
&& LANG=$(/usr/bin/locale -fU) \
|| LANG=$(/usr/bin/locale | \
/bin/sed -e '/^LANG=\|^LC_CTYPE=\|^LC_ALL=/{s///;h};$!d;x;s/"//g')
[ "${LANG:0:2}" = "en" ] || LANG=en_CA.UTF-8
export LANG
Also for time zones Cygwin tzset builds and uses a table based on upstream CLDR:
/usr/share/unicode/cldr/common/supplemental/windowsZones.xml
to convert from MS Windows to IANA TZ DB time zones.
$ tail /etc/profile.d/tzset.sh
# Modifying /etc/profile.d/tzset.sh directly will prevent
# setup from updating it.
# System-wide tzset.sh file
#Uses the geographical location setting of the user to find the right
#mapping, rather than the locale setting. Only on Windows 2000 which
#doesn't know about the user's geographical location, or if fetching
#the geographical location fails, it falls back to the user's locale.
test -z "$TZ" && export TZ=$(/usr/bin/tzset)
$ [ -n "$TZ" ] && zdump
zdump -Vc2024,2025 America/Edmonton
America/Edmonton Sun Mar 10 08:59:59 2024 UT = Sun Mar 10 01:59:59 2024 MST
isdst=0 gmtoff=-25200
America/Edmonton Sun Mar 10 09:00:00 2024 UT = Sun Mar 10 03:00:00 2024 MDT
isdst=1 gmtoff=-21600
America/Edmonton Sun Nov 3 07:59:59 2024 UT = Sun Nov 3 01:59:59 2024 MDT
isdst=1 gmtoff=-21600
America/Edmonton Sun Nov 3 08:00:00 2024 UT = Sun Nov 3 01:00:00 2024 MST
isdst=0 gmtoff=-25200
--
Take care. Thanks, Brian Inglis Calgary, Alberta, Canada
La perfection est atteinte Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut
-- Antoine de Saint-Exupéry
- cannot compile under cygwin because of gnulib/uninorm, Denis Excoffier, 2024/12/03
- Re: cannot compile under cygwin because of gnulib/uninorm, Bruno Haible, 2024/12/04
- Re: cannot compile under cygwin because of gnulib/uninorm, Brian Inglis, 2024/12/04
- Re: gettext binaries for Cygwin, Bruno Haible, 2024/12/04
- Re: gettext binaries for Cygwin,
Brian Inglis <=
- Re: gettext binaries for Cygwin, Bruno Haible, 2024/12/04
- Re: gettext binaries for Cygwin, Brian Inglis, 2024/12/04
- Re: gettext binaries for Cygwin, Bruno Haible, 2024/12/04
- Re: gettext binaries for Cygwin, Brian Inglis, 2024/12/04
- Re: gettext binaries for Cygwin, Bruno Haible, 2024/12/04
- Re: gettext binaries for Cygwin, Brian . Inglis, 2024/12/04
- Re: gettext binaries for Cygwin, Bruno Haible, 2024/12/05
- Re: gettext binaries for Cygwin, Brian . Inglis, 2024/12/05
- Re: gettext binaries for Cygwin, Denis Excoffier, 2024/12/05
- Re: gettext binaries for Cygwin, address@hidden, 2024/12/06