Skip to content

intl: configure default locale #28099

@bnoordhuis

Description

@bnoordhuis

Right now Node.js (by omission) leaves it up to ICU to figure out the locale and configure itself accordingly.

That's problematic for a number of reasons, see e.g. #27856 (comment) - tl;dr environment variables affect the output of Date#toString(). Googling for variations of 'nodejs lc_all' suggests the issue pops up more often.

Since one of Node.js's goals is to provide a consistent experience across platforms and environments, I think it would be good to explicitly configure the locale at startup instead of leaving it to happenstance.

There are two ways to accomplish that and they're not mutually exclusive:

  1. setenv("LC_ALL", "..."); setenv("LC_MESSAGES", "..."); // etc.
  2. icu::Locale::setDefault(...)

I'm adding the semver-major label because there is some risk of breaking existing applications. (Libraries not so much since the average library already runs in a variety of environments.)

It would be good to have some discussion on the merits of both (and alternative?) approaches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.i18n-apiIssues and PRs related to the i18n implementation.semver-majorPRs that contain breaking changes and should be released in the next major version.stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions