SFDigitalServices/sfgov

Translations don't properly set the "lang" attribute

shawnbot opened this issue · 1 comments

It looks like there are some localization-related things happening in either our JavaScript or Google Translate that are fighting with the way that formio-sfds is told which language it should be using. The expectation right now is that the closest element with a lang attribute determines this, which used to work until recently. However, I'm now seeing a DOM that looks like this after I've chosen Spanish in the language selector:

<article role="article"
  class="[...] sfgov-translate-lang-es" lang="en">
  <div class="[...] sfgov-translate-lang-es">

This bit in our JS appears to be coming up with the right class to add:

this.addElementTranslationClass = function(translationVal) {
var elementClass = 'sfgov-translate-lang-' + translationVal;
$('body').find('*').not('script, noscript, link, style, iframe, .goog-te-combo').addClass(elementClass);
}

...but the lang attribute is still en. I don't know where the lang attribute is getting set, and I didn't find anything our JS that does that; so maybe Google Translate is doing it? 🤷

/cc @aekong

JIRA ticket here: https://sfgovdt.jira.com/browse/SG-1110

Closing!