Bug 20184 - API for language priority list
Summary: API for language priority list
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: locale (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-31 09:15 UTC by Daiki Ueno
Modified: 2016-06-01 07:00 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daiki Ueno 2016-05-31 09:15:19 UTC
While discussing on potentially thread-unsafe getenv() call in gettext() for LANGUAGE, Bruno Haible suggested to add an API that is equivalent to the envvar setting, in a lower layer than gettext():
https://lists.gnu.org/archive/html/bug-gettext/2016-05/msg00009.html

At first it seems a bit overkill to me though (because the only user is currently gettext()), the concept itself seems not uncommon: W3C ltli[1] defines the term "language priority list" and ICU4J provides a class LocalePriorityList[2] so multilingual applications might benefit from the API.

My current suggestion is to add the following two functions to
<locale.h> as a GNU extension:

  /* Sets the language priority list for the calling thread to LANGUAGES.

     LANGUAGES may be a colon-separated list of language codes.
     If LANGUAGES is NULL, use the one inferred from the environment
     variable 'LANGUAGE'.

     The effect of the language priority list is application
     dependent.  However, supporting applications should give
     priority to the language priority list over the locale
     settings.

     This returns an opaque string that corresponds to the current
     language priority list.  */
  const char *
  set_language_priority_list (const char *languages);

  /* Returns the language priority list for the calling thread.

     This returns NULL if the list is not set yet, or an opaque string
     that corresponds to the current language priority list.  */
  const char *
  get_language_priority_list (void);

[1] https://www.w3.org/TR/ltli/
[2] http://icu-project.org/apiref/icu4j/com/ibm/icu/util/LocalePriorityList.html