From d59b3ed321074841f05c44968ae30884e85c25bb Mon Sep 17 00:00:00 2001 From: Henrique Sato Date: Wed, 18 Mar 2026 16:11:35 -0300 Subject: [PATCH] New config.json variable to set the ACS default language --- .../org/apache/cloudstack/gui/theme/GuiThemeServiceImpl.java | 2 +- ui/public/config.json | 3 ++- ui/src/components/header/TranslationMenu.vue | 3 ++- ui/src/utils/guiTheme.js | 5 +++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/apache/cloudstack/gui/theme/GuiThemeServiceImpl.java b/server/src/main/java/org/apache/cloudstack/gui/theme/GuiThemeServiceImpl.java index 1cb80e3dc8d3..6fb6a1235f74 100644 --- a/server/src/main/java/org/apache/cloudstack/gui/theme/GuiThemeServiceImpl.java +++ b/server/src/main/java/org/apache/cloudstack/gui/theme/GuiThemeServiceImpl.java @@ -60,7 +60,7 @@ public class GuiThemeServiceImpl implements GuiThemeService { protected Logger logger = LogManager.getLogger(getClass()); - private static final List ALLOWED_PRIMITIVE_PROPERTIES = List.of("appTitle", "footer", "loginFooter", "logo", "minilogo", "banner"); + private static final List ALLOWED_PRIMITIVE_PROPERTIES = List.of("appTitle", "footer", "loginFooter", "logo", "minilogo", "banner", "defaultLanguage"); private static final List ALLOWED_ERROR_PROPERTIES = List.of("403", "404", "500"); diff --git a/ui/public/config.json b/ui/public/config.json index 3d50f9811850..81d3938a5dee 100644 --- a/ui/public/config.json +++ b/ui/public/config.json @@ -117,5 +117,6 @@ "message": "🤔 Sample Announcement: New Feature Available: Check out our latest dashboard improvements! Learn more", "startDate": "2025-06-01T00:00:00Z", "endDate": "2025-07-16T00:00:00Z" - } + }, + "defaultLanguage": "en" } diff --git a/ui/src/components/header/TranslationMenu.vue b/ui/src/components/header/TranslationMenu.vue index 4cd369d3bf6f..f68d9e3849d1 100644 --- a/ui/src/components/header/TranslationMenu.vue +++ b/ui/src/components/header/TranslationMenu.vue @@ -52,6 +52,7 @@ import moment from 'moment' import 'moment/locale/zh-cn' import { loadLanguageAsync } from '@/locales' +import { vueProps } from '@/vue-app' moment.locale('en') @@ -63,7 +64,7 @@ export default { } }, mounted () { - this.language = this.$localStorage.get('LOCALE') || 'en' + this.language = this.$localStorage.get('LOCALE') || vueProps.$config?.defaultLanguage || 'en' this.setLocale(this.language) }, methods: { diff --git a/ui/src/utils/guiTheme.js b/ui/src/utils/guiTheme.js index b1a7209fd270..0b7bf7369774 100644 --- a/ui/src/utils/guiTheme.js +++ b/ui/src/utils/guiTheme.js @@ -17,6 +17,7 @@ import { vueProps } from '@/vue-app' import { getAPI } from '@/api' +import { loadLanguageAsync } from '../locales' export async function applyCustomGuiTheme (accountid, domainid) { await fetch('config.json').then(response => response.json()).then(config => { @@ -69,6 +70,7 @@ async function applyDynamicCustomization (response) { vueProps.$config.logo = jsonConfig?.logo ?? vueProps.$config.logo vueProps.$config.minilogo = jsonConfig?.minilogo ?? vueProps.$config.minilogo vueProps.$config.banner = jsonConfig?.banner ?? vueProps.$config.banner + vueProps.$config.defaultLanguage = vueProps.$localStorage.get('LOCALE') ?? jsonConfig?.defaultLanguage ?? vueProps.$config.defaultLanguage if (jsonConfig?.error) { vueProps.$config.error[403] = jsonConfig?.error[403] ?? vueProps.$config.error[403] @@ -85,6 +87,9 @@ async function applyDynamicCustomization (response) { vueProps.$config.favicon = jsonConfig?.favicon ?? vueProps.$config.favicon vueProps.$config.css = response?.css ?? null + vueProps.$localStorage.set('LOCALE', vueProps.$config.defaultLanguage) + loadLanguageAsync(vueProps.$config.defaultLanguage) + await applyStaticCustomization(vueProps.$config.favicon, vueProps.$config.css) }