Skip to content

Commit d59b3ed

Browse files
committed
New config.json variable to set the ACS default language
1 parent b744824 commit d59b3ed

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

server/src/main/java/org/apache/cloudstack/gui/theme/GuiThemeServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class GuiThemeServiceImpl implements GuiThemeService {
6060

6161
protected Logger logger = LogManager.getLogger(getClass());
6262

63-
private static final List<String> ALLOWED_PRIMITIVE_PROPERTIES = List.of("appTitle", "footer", "loginFooter", "logo", "minilogo", "banner");
63+
private static final List<String> ALLOWED_PRIMITIVE_PROPERTIES = List.of("appTitle", "footer", "loginFooter", "logo", "minilogo", "banner", "defaultLanguage");
6464

6565
private static final List<String> ALLOWED_ERROR_PROPERTIES = List.of("403", "404", "500");
6666

ui/public/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,6 @@
117117
"message": "🤔 <strong>Sample Announcement</strong>: New Feature Available: Check out our latest dashboard improvements! <a href='/features'>Learn more</a>",
118118
"startDate": "2025-06-01T00:00:00Z",
119119
"endDate": "2025-07-16T00:00:00Z"
120-
}
120+
},
121+
"defaultLanguage": "en"
121122
}

ui/src/components/header/TranslationMenu.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import moment from 'moment'
5353
import 'moment/locale/zh-cn'
5454
import { loadLanguageAsync } from '@/locales'
55+
import { vueProps } from '@/vue-app'
5556
5657
moment.locale('en')
5758
@@ -63,7 +64,7 @@ export default {
6364
}
6465
},
6566
mounted () {
66-
this.language = this.$localStorage.get('LOCALE') || 'en'
67+
this.language = this.$localStorage.get('LOCALE') || vueProps.$config?.defaultLanguage || 'en'
6768
this.setLocale(this.language)
6869
},
6970
methods: {

ui/src/utils/guiTheme.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import { vueProps } from '@/vue-app'
1919
import { getAPI } from '@/api'
20+
import { loadLanguageAsync } from '../locales'
2021

2122
export async function applyCustomGuiTheme (accountid, domainid) {
2223
await fetch('config.json').then(response => response.json()).then(config => {
@@ -69,6 +70,7 @@ async function applyDynamicCustomization (response) {
6970
vueProps.$config.logo = jsonConfig?.logo ?? vueProps.$config.logo
7071
vueProps.$config.minilogo = jsonConfig?.minilogo ?? vueProps.$config.minilogo
7172
vueProps.$config.banner = jsonConfig?.banner ?? vueProps.$config.banner
73+
vueProps.$config.defaultLanguage = vueProps.$localStorage.get('LOCALE') ?? jsonConfig?.defaultLanguage ?? vueProps.$config.defaultLanguage
7274

7375
if (jsonConfig?.error) {
7476
vueProps.$config.error[403] = jsonConfig?.error[403] ?? vueProps.$config.error[403]
@@ -85,6 +87,9 @@ async function applyDynamicCustomization (response) {
8587
vueProps.$config.favicon = jsonConfig?.favicon ?? vueProps.$config.favicon
8688
vueProps.$config.css = response?.css ?? null
8789

90+
vueProps.$localStorage.set('LOCALE', vueProps.$config.defaultLanguage)
91+
loadLanguageAsync(vueProps.$config.defaultLanguage)
92+
8893
await applyStaticCustomization(vueProps.$config.favicon, vueProps.$config.css)
8994
}
9095

0 commit comments

Comments
 (0)