-
Is there a way to obtain all supported locales for a certain Expanded question: The ECMA-402 specification requires, in all its "Service Constructors", a way to filter a list of locales and return the subset of locales that are supported by the Service Constructor (e.g. Intl.Collator.supportedLocalesOf). However, to implement this algorithm, you would need the full list of supported locales for a specific SC, as shown by the Is there an API providing this functionality in ICU4X or, alternatively, plans for implementing a similar interface? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Please note that ECMA-402 never actually exposes the set of available locales, only the supportedLocalesOf function. The ICU4X data provider follows the same model; it can answer whether or not a locale is supported, but it doesn't give you the full list. It doesn't do this because there's no such thing as a list of supported locales; the set is unbounded due to locale fallback. Therefore, please perform data requests for each locale in the list, and use that to determine whether or not to include the locale in the output list. You can either perform direct lookup (no fallback), in which case you can check for DataErrorKind::MissingLocale, or lookup with fallback, in which case you can check whether the DataResponseMetadata is "und" or not. |
Beta Was this translation helpful? Give feedback.
See also #58 and #1092
Please note that ECMA-402 never actually exposes the set of available locales, only the supportedLocalesOf function. The ICU4X data provider follows the same model; it can answer whether or not a locale is supported, but it doesn't give you the full list. It doesn't do this because there's no such thing as a list of supported locales; the set is unbounded due to locale fallback.
Therefore, please perform data requests for each locale in the list, and use that to determine whether or not to include the locale in the output list. You can either perform direct lookup (no fallback), in which case you can check for DataErrorKind::MissingLocale, or lookup with fallback, i…