Language tags are complicated. If my page is set to lang="en-US", and I add dictionary entries for the following languages, what happens?
en
en-us (lowercase)
en-GB
en-asdf
en-US-x-lolcat
en-US-oed
en-Latn
en-Brai
Exact string matching is generally not the correct approach for this sort of thing.
We struggled with this in various AI-related APIs (see webmachinelearning/translation-api#11) and ended up with some of the specification infrastructure in https://webmachinelearning.github.io/writing-assistance-apis/#supporting-language-tags and https://webmachinelearning.github.io/writing-assistance-apis/#supporting-language-availability , which might be helpful.
Language tags are complicated. If my page is set to
lang="en-US", and I add dictionary entries for the following languages, what happens?enen-us(lowercase)en-GBen-asdfen-US-x-lolcaten-US-oeden-Latnen-BraiExact string matching is generally not the correct approach for this sort of thing.
We struggled with this in various AI-related APIs (see webmachinelearning/translation-api#11) and ended up with some of the specification infrastructure in https://webmachinelearning.github.io/writing-assistance-apis/#supporting-language-tags and https://webmachinelearning.github.io/writing-assistance-apis/#supporting-language-availability , which might be helpful.