LocaleMatcher: add option to turn off default locale

Description

Currently, the LocaleMatcher always has a default locale, either an explicit one or implicitly the first of the supported locales. (Exception: default=null if there is neither)

Also, build() sorts the supported locales by 1. equivalent to the default 2. equivalent to a “paradigm locale” (a few favored locales from CLDR languageMatch data) 3. the rest.

Some callers never want to see a default locale; they just want to know if there is no good match.

We should add a builder option for turning this off. If there is no good match, return null for the best supported locale. In addition, with no default at all, build() should skip sorting the default locale to the front of the matcher's internal list of supported locales.

Note that this cannot be done by calling Builder.setDefaultLocale(null): “Sets the default locale; if null, or if it is not set explicitly, then the first supported locale is used as the default locale.”

The new setter could be called setNoDefaultLocale() or setNullDefaultLocale().

Fixed

Assignee

Markus Scherer

Reporter

Markus Scherer

Components

Labels

None

Reviewer

None

Priority

major

Time Needed

Hours

Fix versions

Configure