Skip to content

OF-3137: setup page: select locale from browser#3050

Open
stokito wants to merge 7 commits into
igniterealtime:mainfrom
stokito:OF-3137_setup_locale
Open

OF-3137: setup page: select locale from browser#3050
stokito wants to merge 7 commits into
igniterealtime:mainfrom
stokito:OF-3137_setup_locale

Conversation

@stokito
Copy link
Copy Markdown
Member

@stokito stokito commented Oct 14, 2025

https://igniterealtime.atlassian.net/browse/OF-3137

During the Openfire set up the list of languages can be simplified and improved.
Currently during installation the language selector is always pre-selected on English. The server may have another locale, but the best way would be to set same locale as a user browser.
Also it would be better to make list of supported locales easier to modify.

@stokito stokito changed the title OF-3137: setup page select locale from browser OF-3137: setup page: select locale from browser Oct 14, 2025
@stokito stokito force-pushed the OF-3137_setup_locale branch from b7077cc to ea657d4 Compare November 27, 2025 08:59
@stokito stokito force-pushed the OF-3137_setup_locale branch from ea657d4 to 3718b94 Compare December 2, 2025 19:17
@akrherz akrherz requested a review from Copilot May 7, 2026 18:53
@akrherz akrherz added this to the 5.1.0 milestone May 7, 2026
@akrherz
Copy link
Copy Markdown
Member

akrherz commented May 7, 2026

@stokito Sorry that this PR has languished. Have requested AI review and lets see about getting it considered for Openfire 5.1

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates Openfire setup/admin locale selection to prefer the user’s browser locale and centralizes the list of supported locales.

Changes:

  • Add supported-locale registry and “best match” selection logic in LocaleUtils.
  • Update setup and server-locale JSPs to render locale choices from the supported-locale registry (and preselect based on browser locale in setup).
  • Adjust default locale configuration and add/extend unit tests.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
xmppserver/src/main/java/org/jivesoftware/util/LocaleUtils.java Adds supported locale registry and browser-locale matching helper; minor RTL check simplification.
xmppserver/src/main/webapp/setup/index.jsp Uses supported locales + browser locale matching to preselect setup language; removes hardcoded locale list.
xmppserver/src/main/webapp/server-locale.jsp Uses supported locales map to render language selection and display current language name.
xmppserver/src/test/java/org/jivesoftware/util/LocaleUtilsTest.java Adds unit test coverage for the new locale matching logic.
distribution/src/conf/openfire.xml Changes default configured locale value to empty.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +278 to +305
// build lang codes haystack "pt_BR pt_PT pt_ "
String localesList = "";
while (requestLocales.hasMoreElements()){
Locale locale = requestLocales.nextElement();
localesList += locale.getLanguage() + "_" + locale.getCountry() + " ";
}
int bestMatchPos = Integer.MAX_VALUE;
String matchedLocale = null;
for (Map.Entry<String, String> entry : supportedLocales.entrySet()) {
// first match by lang and country, if no then try to match by only language
String localeCode = entry.getKey(); // e.g. pt_BR
int matchPos = localesList.indexOf(localeCode + " ");
if (matchPos < 0) {
// match by lang only i.e, no country
String lang = substringBefore(localeCode, "_");
matchPos = localesList.indexOf(lang + "_ ");
if (matchPos < 0) {
continue;
}
}
if (matchPos < bestMatchPos) {
bestMatchPos = matchPos;
matchedLocale = localeCode;
}
}
if (matchedLocale != null) {
return matchedLocale;
}
Comment on lines +279 to +283
String localesList = "";
while (requestLocales.hasMoreElements()){
Locale locale = requestLocales.nextElement();
localesList += locale.getLanguage() + "_" + locale.getCountry() + " ";
}
* Get list of locales (code: name) that the web admin has translations for.
*/
public static Map<String, String> getSupportedLocales() {
return supportedLocales;
<div class="jive-contentBox">
<p>
<b><fmt:message key="locale.current" />:</b> <%= locale.getDisplayName(locale) %> /
<b><fmt:message key="locale.current" />:</b> ${locales[locale]} /
Comment on lines +25 to 26
<locale></locale>

Comment on lines +20 to +23
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
Comment on lines +40 to +47
public void bestMatchingSupportedLocale() {
Enumeration<Locale> reqLocales = Collections.enumeration(asList(
new Locale("pt", "BR"),
new Locale("pt", "PT"),
new Locale("pt")
));
String preferredLocale = LocaleUtils.bestMatchingSupportedLocale(reqLocales);
assertThat(preferredLocale, is("pt_BR"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants