public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* the purpose of locale.alias
@ 2023-09-10  8:55 Bruno Haible
  2023-09-11  7:57 ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: Bruno Haible @ 2023-09-10  8:55 UTC (permalink / raw)
  To: libc-alpha

Hi,

What is the purpose of glibc's locale.alias, typically installed as
/usr/share/locale/locale.alias ? (I'm not talking about the X11 locale.alias
here.)

I would like to suggest to improve the comments in it, to clarify its
purpose.

* The comments so far say:
  "
   # Note: This file is obsolete and is kept around for the time being for
   # backward compatibility.  Nobody should rely on the names defined here.
   # Locales should always be specified by their full name.
  "
  And indeed, while nowadays most GNU/Linux users use locales with UTF-8
  encoding, all of the aliases in the current locale.alias file are for
  locales with traditional encodings; they are thus not useful today any more.

* But a valid future use of locale.alias is when a language code changes
  (like in the past: no -> nb, or iw -> he), or when a country code changes
  (like in the past with Yugoslavia or Soviet Union). Such changes can happen
  in the future, and for people who use a rolling-release distribution and
  use locale names in their .profile script, it is useful to be able to
  add a line
     ll_oldCC.UTF-8    ll_newCC.UTF-8
  to the locale.alias file.

* Then there are also people who "want to unify language codes on all
  environments" [1]. This sounds like of minor importance to me. Do you
  think this is a reasonable use-case of locale.alias or not?

Other purposes, that I have missed?

Bruno

[1] https://askubuntu.com/questions/883622/





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: the purpose of locale.alias
  2023-09-10  8:55 the purpose of locale.alias Bruno Haible
@ 2023-09-11  7:57 ` Florian Weimer
  2023-09-12 18:55   ` Bruno Haible
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2023-09-11  7:57 UTC (permalink / raw)
  To: Bruno Haible; +Cc: libc-alpha

* Bruno Haible:

> * But a valid future use of locale.alias is when a language code changes
>   (like in the past: no -> nb, or iw -> he), or when a country code changes
>   (like in the past with Yugoslavia or Soviet Union). Such changes can happen
>   in the future, and for people who use a rolling-release distribution and
>   use locale names in their .profile script, it is useful to be able to
>   add a line
>      ll_oldCC.UTF-8    ll_newCC.UTF-8
>   to the locale.alias file.

In addition to what is currently in intl/locale.alias, localedef creates
additional aliases when populating the archive, along those lines.
These aliases are currently missing from “locale -a” output, and some
people have noticed.  Without a locale archvie, this seems indeed a use
case for locale.alias.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: the purpose of locale.alias
  2023-09-11  7:57 ` Florian Weimer
@ 2023-09-12 18:55   ` Bruno Haible
  2023-09-12 19:28     ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: Bruno Haible @ 2023-09-12 18:55 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

Florian Weimer wrote:
> In addition to what is currently in intl/locale.alias, localedef creates
> additional aliases when populating the archive, along those lines.
> These aliases are currently missing from “locale -a” output, and some
> people have noticed.

You mean, the add_alias call in glibc/locale/programs/locarchive.c:1204 ?
Indeed, I see that the /usr/lib/locale/locale-archive on my system contains
aliases, equivalent to

ar_EG.ISO-8859-6 ar_EG
ar_SA.ISO-8859-6 ar_SA
de_DE.ISO-8859-1 de_DE
en_AG.UTF-8      en_AG
en_IL.UTF-8      en_IL
en_IN.UTF-8      en_IN
en_NG.UTF-8      en_NG
en_ZM.UTF-8      en_ZM
fa_IR.UTF-8      fa_IR
fr_FR.ISO-8859-1 fr_FR
zh_HK.BIG5-HKSCS zh_HK

> Without a locale archvie, this seems indeed a use
> case for locale.alias.

No, without a locale archive, this kind of aliases are automatic, due to
the directory structure on disk and the search algorithm in
glibc/intl/l10nflist.c. See this experiment:

  # localedef --no-archive -i hy_AM -f UTF-8 hy_AM
  # LC_ALL=hy_AM locale
  (OK)
  # LC_ALL=hy_AM.UTF-8 locale
  (OK)
  # LC_ALL=hy_AM.ISO-8859-1 locale
  locale: Cannot set LC_CTYPE to default locale: No such file or directory
  locale: Cannot set LC_MESSAGES to default locale: No such file or directory
  locale: Cannot set LC_ALL to default locale: No such file or directory
  ...

This shows that an alias
  hy_AM.UTF-8 hy_AM
in locale.alias is not needed.


Thanks for your feedback. I'm submitting a patch, to update the comments,
in a separate mail.

Bruno




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: the purpose of locale.alias
  2023-09-12 18:55   ` Bruno Haible
@ 2023-09-12 19:28     ` Florian Weimer
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Weimer @ 2023-09-12 19:28 UTC (permalink / raw)
  To: Bruno Haible; +Cc: libc-alpha

* Bruno Haible:

>> Without a locale archvie, this seems indeed a use
>> case for locale.alias.
>
> No, without a locale archive, this kind of aliases are automatic, due to
> the directory structure on disk and the search algorithm in
> glibc/intl/l10nflist.c. See this experiment:
>
>   # localedef --no-archive -i hy_AM -f UTF-8 hy_AM
>   # LC_ALL=hy_AM locale
>   (OK)
>   # LC_ALL=hy_AM.UTF-8 locale
>   (OK)
>   # LC_ALL=hy_AM.ISO-8859-1 locale
>   locale: Cannot set LC_CTYPE to default locale: No such file or directory
>   locale: Cannot set LC_MESSAGES to default locale: No such file or directory
>   locale: Cannot set LC_ALL to default locale: No such file or directory
>   ...
>
> This shows that an alias
>   hy_AM.UTF-8 hy_AM
> in locale.alias is not needed.

I think the alias is still missing from “locale -a”.  I'm not sure if
there's a better way of fixing that except for augmenting locale.alias.
Suggestions welcome, it's one of our permanently open downstream bugs. 8-/

Thanks,
Florian


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-12 19:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-10  8:55 the purpose of locale.alias Bruno Haible
2023-09-11  7:57 ` Florian Weimer
2023-09-12 18:55   ` Bruno Haible
2023-09-12 19:28     ` Florian Weimer

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).