Skip to content

Commit 1e1f82c

Browse files
committed
feat: conditional page reloading and module rename
1 parent 1c310d3 commit 1e1f82c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/i18n/LanguageManager.js renamed to src/i18n/languageManager.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ export async function setSessionLanguage(languageCode) {
7070
*
7171
* @param {string} languageCode - The selected language locale code (e.g., 'en', 'es', 'ar').
7272
* Should be a valid ISO language code supported by the platform.
73+
* @param {boolean} [forceReload=false] - Whether to force a page reload after changing the language.
7374
* @returns {Promise} - A promise that resolves when all operations complete.
7475
*
7576
*/
76-
export async function changeUserSessionLanguage(languageCode) {
77+
export async function changeUserSessionLanguage(
78+
languageCode,
79+
forceReload = false,
80+
) {
7781
const cookies = getCookies();
7882
const cookieName = getConfig().LANGUAGE_PREFERENCE_COOKIE_NAME;
7983
cookies.set(cookieName, languageCode);
@@ -91,9 +95,7 @@ export async function changeUserSessionLanguage(languageCode) {
9195
logError(error);
9296
}
9397

94-
// Force page reload to ensure complete translation application.
95-
// While some translations update via the publish event, many sections
96-
// of the platform are not configured to receive these events or
97-
// handle translations dynamically, requiring a full reload for consistency.
98-
window.location.reload();
98+
if (forceReload) {
99+
window.location.reload();
100+
}
99101
}

0 commit comments

Comments
 (0)