accessibility-developer-tools icon indicating copy to clipboard operation
accessibility-developer-tools copied to clipboard

Check for valid human language in HumanLangMissing?

Open alice opened this issue 10 years ago • 2 comments

This looks like it would be quite complicated, however. http://en.wikipedia.org/wiki/IETF_language_tag

alice avatar Dec 04 '14 16:12 alice

This is achievable but, if done properly, will add about 800KB - 1.5MB to the size of the library. There are ways of doing it with far less bloat but they will not be as accurate.

The bloat begins with the fact that we'd need the data in this 700KB file: http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry

Then add the code for parsing that data, then the code for the validation, then the code for handling deprecation etc...

I actually got it working by running browserify over this: https://www.npmjs.com/package/language-tags That produced a 1.4MB script that does what we need.

I also got it working with this: https://www.npmjs.com/package/bcp47 That produced a relatively tiny 4KB script BUT it was not as accurate (it uses a regex instead of loading the iana registry) and is purely a parser - for example it cannot tell you the preferred subtag to use instead of a deprecated subtag.

@alice I'd be interested to hear your thoughts on whether it would be worth loading another 1.4MB to perform this audit? It may be possible to get it a little smaller by writing a custom layer on top of the iana registry that only does precisely what is required but, due to the size of the registry itself, I estimate it would still come out the best part of 1MB.

@chenglo Sorry if I'm treading on your territory here - I got curious about this one, did a whole bunch of research and thought it would be a waste to just throw away my findings.

ricksbrown avatar Aug 04 '15 10:08 ricksbrown

Hi @RickSBrown - I've cleared myself from the assignee on this one since I couldn't find a working solution. Great to see that you found an achievable solution!

chenglo avatar Aug 04 '15 15:08 chenglo