When a l10n file contains localizations for several language codes, but not the primary subtag, and the browser reports only the primary subtag, then this library fails to map the browser's language code to a l10n file.
Primary subtag of es-ES (=letters before the first hyphen): es
Browser's language: es
This could easily be implemented by mapping primary subtags to the first language code with the same primary subtag if the localization data for the primary subtag is not specified.
Note that this operation does not always guarantee usable results, because there are language codes with identical primary subtags that are not mutually intelligible, az-Latin and az-Cyrl is given as an example by RFC 4646, section 4.2.
When a l10n file contains localizations for several language codes, but not the primary subtag, and the browser reports only the primary subtag, then this library fails to map the browser's language code to a l10n file.
For instance, in the following situation, one would expect the es-ES locale to be used because the primary subtag matches the browser's language (example from https://github.com/mozilla/pdf.js/issues/6048#issuecomment-113572161):
es-ES
es-ES
(=letters before the first hyphen):es
es
This could easily be implemented by mapping primary subtags to the first language code with the same primary subtag if the localization data for the primary subtag is not specified. Note that this operation does not always guarantee usable results, because there are language codes with identical primary subtags that are not mutually intelligible,
az-Latin
andaz-Cyrl
is given as an example by RFC 4646, section 4.2.