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

Don't throw an error when missing a translation - just log #283

Closed esbenam closed 4 years ago

esbenam commented 4 years ago

This is a suggestion

If an error is thrown the whole program breaks. This combined with the fact that some keys are missing across different translations makes it a fairly inconvenient issue.

With this in place the program would finish with logs warning about the missing keys.

Right now I think the only key missing in translation.en is 4_1_2_attribute. If that is added this implementation could fallback to using the english translation as default (so it would still give somewhat valuable information to the user). It could also just return the key that was passed to getTranslation - that way the user would always get some useful information no matter what. That could easily be included in this pull request.

I don't know what the text for 4_1_2_attribute should be but would be happy to include that as well.

ironikart commented 4 years ago

I'm merging this one because I agree that we shouldn't be throwing an error here. I would be more confident about throwing an error if the code base had better testing. Adding an issue #284 for this missing translation key.