Broadcast when the language changes

This is left open to future additions, by naming it 'locale', and having
the language just be an object field.

Side note, maybe we should have a LocaleService for this?
This commit is contained in:
Sam Atkins 2024-04-08 14:04:44 +01:00
parent 59cdb6e8c6
commit 84a31b3520

View File

@ -722,7 +722,14 @@ window.mutate_user_preferences = function(user_preferences_delta) {
window.update_user_preferences = function(user_preferences) { window.update_user_preferences = function(user_preferences) {
window.user_preferences = user_preferences; window.user_preferences = user_preferences;
localStorage.setItem('user_preferences', JSON.stringify(user_preferences)); localStorage.setItem('user_preferences', JSON.stringify(user_preferences));
window.locale = user_preferences.language ?? 'en'; const language = user_preferences.language ?? 'en';
window.locale = language;
// Broadcast locale change to apps
const broadcastService = globalThis.services.get('broadcast');
broadcastService.sendBroadcast('localeChanged', {
language: language,
}, { sendToNewAppInstances: true });
} }
window.sendWindowWillCloseMsg = function(iframe_element) { window.sendWindowWillCloseMsg = function(iframe_element) {