Changing js.browser_update text doesn't apply on no JS views

AI-generated summary

The discussion is about an issue where changing the js.browser_update text in Discourse’s customization settings does not apply the changes on views rendered without JavaScript, such as in older browsers like IE10.

The root cause is that the browser update message is initially rendered server-side, and any customizations made through the js.browser_update setting rely on JavaScript to apply those changes client-side. Older browsers that don’t support JavaScript will continue to show the default English message.

Some key points:

  • Falco explains that JavaScript text customizations don’t run on plain HTML views without JS, which is expected behavior.
  • zcuric thought the browser update message should be customizable since it’s set in an ERB template, but Falco notes that globals like I18n have been removed.
  • Jonathan5 sees the same issue and wonders if there’s a workaround for this specific message.
  • ted clarifies that very old browsers may fail to apply client-side translations, falling back to the default English message hard-coded in the JS file.

The consensus is that there’s no easy solution since the initial render is server-side, and the team hopes users will eventually upgrade from those older browsers.

  1. Change js.browser_update in Customise > Text.

  2. Open Discourse in IE10

  3. Default message is shown instead of customised one

AFAIK JS text customizations run in Javascript. Since our mode for old browsers is plain HTML without Javascript, anything JS won’t run in there. This behavior is expected.

It’s set here. https://github.com/discourse/discourse/blob/master/vendor/assets/javascripts/browser-update.js.erb#L29

So it should be applicable. :man_shrugging:

Oh, that won’t work anymore as we are removing all globals, with I18n being the one that was removed last week.

It may work after a rebuild @zcuric.

Not working unfortunately. We did a release today and rebuild the app, same thing.

I have the same problem. I thought when I first changed js.browser_update it did display on an old browser (but I’m not 100% sure now), but today I see that it shows the original text. Is there any way round this… maybe treating this particular message differently, as mostly when this message is displayed Javascript won’t be on? Maybe a short plugin?

The reason you saw this work on one browser, and then not on another, might be because some really old browsers can’t support the client-side translation, while others can.

We first try to run the translation, and if it doesn’t work, we fall back to a hard-coded instance of the default message in English:

https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/scripts/browser-update.js#L50

Unfortunately there’s not much more we can do about this. Hopefully people will be off those browsers at some point.