If there is no translation for a text string Drupal displays the untranslated string, or the text string from another fallback language. In both situations the text is in another language and so we need for wcag2 a language attribute in the html element around the text.
The problem with trying to implement this is that when t() or format_plural() is invoked, we don't know if HTML is generated. We cannot just output HTML wrapped text if what's generated is for an email or an XML format like RSS. We don't have that information, so we'd risk breaking all emails and RSS feeds generated by the site if we'd do.
Several solutions were discussed:
1. Handle every untranslated string as an error.
2. Make a smarter t()-function, that can accept html=true/false and/or that return an array (translated yes/no, plain/html, language)
3. add invisible unicode characters to the untranslated string and replace that while html rendering with language code
Ad 1: Not a solution anymore as we now also have language fallback for t() in core
Ad 2: this is proposed by Mike in #9, Gabors answered in #10 that this is hard or impossible to tell for module developers.
There are language tags in unicode, but they are depreciated (but not forbidden). No browser and text-to-speech-software will handle this unicode characters. However, we could use this unicode character as an helper and replace it for real language tags during rendering.
The English language tag in Unicode characters would be: U+E0001, U+E0065, U+E006E
End the end tag would be: U+E007F. During html rendering we could replace them with lang="en".
- unicode language tag characters are 4-byte, and Drupal can't handle 4-byte unicode yet
- test if the language tags don't break email, rss, etc
- check if we should filter the unicode characters away in certain functions
User interface changes
We will get extra invisible unicode characters in many places. From email to RSS. Some text functions might need adjustments.
See also the discussion in the accessibility group http://groups.drupal.org/node/145894
FAILED: [[SimpleTest]]: [MySQL] 55,665 pass(es), 10 fail(s), and 0 exception(s). View
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch patch_commit_3adb7b5aa35b.patch. Unable to apply patch. See the log in the details link for more information. View
FAILED: [[SimpleTest]]: [MySQL] 50,025 pass(es), 24 fail(s), and 20 exception(s). View