public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: cygwin@cygwin.com, bug-gnu-gettext@gnu.org
Subject: Re: cygwin started speaking German today
Date: Thu, 08 Sep 2011 20:57:00 -0000	[thread overview]
Message-ID: <201109082256.46125.bruno@clisp.org> (raw)
In-Reply-To: <20110908135039.GD6163@calimero.vinschen.de>

Hello Corinna,

Corinna Vinschen wrote:
> > After Cygwin 1.7 added working locales and defined LANG=C.UTF-8 for all users,
> > libintl could be extended to respect the choices the user has made in the
> > system control panels.
> 
> That's the wrong approach.

Before discussing the technical details, let me remind the goal.

The goal of GNU gettext is to enable localization of programs on all
systems that support that. The benefit for the user is that programs feel
more "friendly". The benefit for the Free Software community is that more
users can use our programs and can contribute to their development, even if
they don't speak English.

Cygwin 1.7 has made major steps towards this goal,
  - by adding working locales,
  - by implementing various internationalization related API in cygwin.dll,
  - by choosing UTF-8 as the default encoding for locales, with automatic
    charset conversion happening in the connection to the console window.

The last cornerstone that is missing is that a user needs to do nothing to
enable the localization of messages to his/her language. It should be
automatic. Gettext 0.18.1.1 fills this gap.

> Cygwin is not Windows but a POSIX system in the first place.

POSIX explicitly allows and foresees such localization without a specific
action of the user. Quoting POSIX:2008
<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html>:

     "All implementations shall define a locale as the default locale, to be
      invoked when no environment variables are set, or set to the empty
      string.  This default locale can be the POSIX locale or any other
      implementation-defined locale.  Some implementations may provide
      facilities for local installation administrators to set the default
      locale, customizing it for each location.  POSIX:2008 does not require
      such a facility."

This "facility" for "local installation administrators" is the
"Regional Settings" control panel, in Windows (as well as in MacOS X).

So, what we need is that when the user has set his/her regional settings
to "German", and has not set any environment variables, then a program
that does

      setlocale (LC_ALL, "");

will pick up the German locale. In Cygwin 1.7 it is called "de_DE.UTF-8".

There are three ways to achieve this behaviour:

  a) The system can set environment variables that reflect the regional
     settings. For example, if the user has chosen German, Cygwin's
     login process could set LANG to de_DE.UTF-8.

     This approach is used in Linux desktops like KDE.

  b) The system's setlocale() function can, when the second argument is
     the empty string and the respective environment variables don't
     specify anything, fetch the value from the "Regional settings"
     panel.

     Cygwin could do that.

  c) Programs can call libintl_setlocale(), and libintl_setlocale can,
     when the second argument is the empty string and the respective
     environment variables don't specify anything, fetch the value
     from the "Regional settings" panel.

     This is what's implemented in gettext 0.18.1.1.

> Do NOT call Windows functions in Cygwin libraries, unless
> the lib is doing something very special which isn't provided by POSIX
> functions.  Only call POSIX functions.  Don't mix the Cygwin and the
> Windows environment.  Please leave the interfacing to the underlying OS
> the sole job of Cygwin.

OK, then the following four facilities are needed in Cygwin.

1) We need the name of the locale which is in effect when the user has
   not specified environment variables.

   Either through option a) above. Programs can then do getenv ("LANG").
   Cygwin documentation <http://www.cygwin.com/cygwin-ug-net/setup-locale.html>
   currently says "The default locale in the absence of the aforementioned
   locale environment variables is "C.UTF-8"." This would have to change.

   Or through option b) above. Programs can then peek at the return
   value of  setlocale (LC_ALL, "").

   Or through an API function that calls GetUserDefaultLCID() and
   converts that to a glibc style locale name (e.g. "zh_CN.UTF-8")
   or to an RFC 3066 style locale name (e.g. "zh-Hans").

2) We need the name of the locale of the current thread.

   Either through a function newlocale(), as in POSIX.

   Or through an API function that calls GetThreadLocale() and
   converts that to a glibc style locale name (e.g. "zh_CN.UTF-8")
   or to an RFC 3066 style locale name (e.g. "zh-Hans").

   Locale per thread is mainly needed for web application servers,
   not for GUI programs.

3) Gettext needs the priority list of languages, if the "Regional Settings"
   panel can specify it. MacOS X has this setting customizable, I don't know
   whether newer Windows versions have it has well.

4) Programs that do number or date/time formatting will need to access the
   values that the user has specified. E.g. those set in
   <http://www.sisulizer.de/_img/codepage-problems/codepage-regional.jpg>
   <http://pc-error-free.com/blog/wp-content/uploads/2008/12/regional-settings.gif>
   <http://www.sisulizer.de/_img/codepage-problems/w7-regions-and-languages-formats.jpg>

I believe all of these are available through Win32 or MUI API calls,
and decently internationalized programs will need this.

Bruno
-- 
In memoriam Elisabeth von Thadden <http://en.wikipedia.org/wiki/Elisabeth_von_Thadden>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  reply	other threads:[~2011-09-08 20:57 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-30 10:18 Voelker, Bernhard
2011-08-30 11:28 ` Charles Wilson
2011-09-08  2:31 ` Charles Wilson
2011-09-08 10:46   ` Bruno Haible
2011-09-08 10:55     ` Voelker, Bernhard
2011-09-08 11:06     ` Eric Blake
2011-09-08 12:05     ` Charles Wilson
2011-09-08 12:48       ` Andy Koppe
2011-09-08 13:13         ` Eric Blake
2011-09-08 12:51       ` Andy Koppe
2011-09-08 21:58         ` Bruno Haible
     [not found]       ` <201109082344.55506.bruno@clisp.org>
2011-09-09  9:18         ` Charles Wilson
2011-09-09 12:33           ` Andy Koppe
2011-09-09 15:00             ` Corinna Vinschen
2011-09-10 11:36               ` Thorsten Kampe
2011-09-13 18:39               ` Eric Blake
2011-09-17 21:50                 ` David Sastre
2011-09-17 22:50                   ` Ken Brown
2011-09-18  3:19                     ` David Sastre
2011-10-04 12:29                 ` Corinna Vinschen
2011-10-04 12:46                   ` Charles Wilson
2011-10-04 14:30                     ` Corinna Vinschen
2011-10-04 18:04                       ` Erwin Waterlander
2011-10-04 18:21                         ` Corinna Vinschen
2011-10-05 16:04                           ` Erwin Waterlander
2011-10-05 16:28                             ` Corinna Vinschen
2011-10-05 16:52                               ` Erwin Waterlander
2011-10-05 17:32                               ` Charles Wilson
2011-10-05 18:24                                 ` Ken Brown
2011-10-05 18:29                                   ` Corinna Vinschen
2011-10-05 18:44                                   ` Erwin Waterlander
2011-10-05 18:50                                   ` Yaakov (Cygwin/X)
2011-10-05 18:58                                     ` Christopher Faylor
2011-10-10 17:24                                   ` Corinna Vinschen
2011-10-11 15:41                                     ` Erwin Waterlander
2011-10-11 16:54                                     ` Charles Wilson
2011-10-11 17:29                                       ` Christopher Faylor
2011-10-16 18:42                                       ` Charles Wilson
2011-10-17  6:59                                         ` Corinna Vinschen
2011-10-17 13:17                                           ` Charles Wilson
2011-10-17 13:52                                             ` Corinna Vinschen
2011-10-17 13:58                                               ` Corinna Vinschen
2011-10-05 18:29                                 ` Corinna Vinschen
2011-10-06  1:35                       ` [OT] " Andrey Repin
2011-10-05 12:08                     ` Ken Brown
2011-09-09 15:13             ` Charles Wilson
2011-09-09 20:08               ` Andy Koppe
2011-09-08 13:45     ` Corinna Vinschen
2011-09-08 13:51     ` Corinna Vinschen
2011-09-08 20:57       ` Bruno Haible [this message]
2011-09-09 15:09         ` Corinna Vinschen
2011-09-09 15:58           ` Andy Koppe
2011-09-10 11:45           ` Thorsten Kampe
2011-09-10 13:50             ` Christopher Faylor
2011-09-10 16:10               ` Thorsten Kampe
2011-09-10 17:11                 ` Christopher Faylor
2011-08-31  8:39 Voelker, Bernhard
2011-08-31 14:01 ` Charles Wilson
2011-08-31 15:19   ` Charles Wilson
2011-09-01  5:30 Voelker, Bernhard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201109082256.46125.bruno@clisp.org \
    --to=bruno@clisp.org \
    --cc=bug-gnu-gettext@gnu.org \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).