squizlabs / HTML_CodeSniffer

HTML_CodeSniffer is a client-side JavaScript application that checks a HTML document or source code, and detects violations of a defined coding standard. Comes with standards that cover the three conformance levels of the W3C's Web Content Accessibility Guidelines (WCAG) 2.0 and the U.S. Section 508 legislation.
https://squizlabs.github.io/HTML_CodeSniffer/
BSD 3-Clause "New" or "Revised" License
1.12k stars 246 forks source link

WIP: Make sure to throw an error when no translation is found #281

Closed esbenam closed 4 years ago

esbenam commented 4 years ago

What does this PR solve? It propagates the translation error when a translation isn't found for a given key (or if the language doesn't exist).

My colleague and I ran into this issue today while running pa11y where a missing translation resulted in an Uncaught TypeError: Cannot read property 'replace' of undefined from this package. I think this should take care of it, so we would get the right error propagated instead :)

My colleague created a minimal-reproduction-repo where you can see the error. If you use npm link to link HTML_CodeSniffer to this branch instead you can see the actual translation error getting propagated.

The weird thing though is that the specific key (1_3_5_H98.InvalidAutoComplete_Text) it complained about isn't missing in the translation file (en.js). I haven't had the time to look into that bit, but this get us halfway there :)