Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix: place Hindi and Arabic last

Ruben Lütkeaa828f8f7a49
diff --git a/jarvis/ui/web/frontend/src/lib/languageNames.ts b/jarvis/ui/web/frontend/src/lib/languageNames.ts
index 9091070b10..e0acc51ab5 100644
--- a/jarvis/ui/web/frontend/src/lib/languageNames.ts
+++ b/jarvis/ui/web/frontend/src/lib/languageNames.ts
@@ -46,9 +46,8 @@ const FALLBACK_NAMES: Readonly<Record<string, string>> = {
* Curated order for the short language band shown above the complete list.
*
* The product's three interface languages lead, followed by Chinese and other
- * frequently selected European languages. Hindi and Arabic remain available
- * at the end of the shortcut band, and every backend language is still present
- * in the complete alphabetical list below it.
+ * frequently selected European languages. Every backend language remains
+ * available in the complete list below it.
*/
export const COMMON_LANGUAGE_CODES: readonly string[] = [
"en",
@@ -64,10 +63,26 @@ export const COMMON_LANGUAGE_CODES: readonly string[] = [
"no",
"da",
"fi",
- "hi",
- "ar",
];
+/** Languages deliberately kept out of the shortcut band and at the list end. */
+const TRAILING_LANGUAGE_CODES: readonly string[] = ["hi", "ar"];
+
+function compareLanguageOptions(
+ a: { code: string; label: string },
+ b: { code: string; label: string },
+ collator: Intl.Collator,
+): number {
+ const aTrailing = TRAILING_LANGUAGE_CODES.indexOf(a.code);
+ const bTrailing = TRAILING_LANGUAGE_CODES.indexOf(b.code);
+ if (aTrailing >= 0 || bTrailing >= 0) {
+ if (aTrailing < 0) return -1;
+ if (bTrailing < 0) return 1;
+ return aTrailing - bTrailing;
+ }
+ return collator.compare(a.label, b.label);
+}
+
// One instance per UI language: constructing an Intl formatter is not free, and
// this runs once per option in a ~100-row list.
const displayNamesCache = new Map<string, Intl.DisplayNames | null>();
@@ -195,7 +210,7 @@ export function sortedLanguageOptions(
const rest = codes
.filter((c) => c !== "auto")
.map((code) => ({ code, label: languageName(code, uiLanguage) }))
- .sort((a, b) => collator.compare(a.label, b.label));
+ .sort((a, b) => compareLanguageOptions(a, b, collator));
return [
...auto.map((code) => ({ code, label: languageName(code, uiLanguage, autoLabel) })),
...rest,
@@ -260,7 +275,7 @@ export function groupedLanguageOptions(
const all = codes
.filter((c) => c !== "auto")
.map((code) => decorate(code))
- .sort((a, b) => collator.compare(a.label, b.label));
+ .sort((a, b) => compareLanguageOptions(a, b, collator));
const groups: LanguageOptionGroup[] = [];
if (lead.length) groups.push({ id: "", options: lead });
diff --git a/jarvis/ui/web/frontend/src/views/settings/LanguagesGroup.test.tsx b/jarvis/ui/web/frontend/src/views/settings/LanguagesGroup.test.tsx
index e824ac8a45..fa03d4daee 100644
--- a/jarvis/ui/web/frontend/src/views/settings/LanguagesGroup.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/LanguagesGroup.test.tsx
@@ -77,15 +77,17 @@ describe("LanguagesGroup (Languages folded into Settings)", () => {
);
// ~100 alphabetical entries put Afrikaans, Albanian, Amharic and Armenian
// on the first screen and everything most people speak below the fold.
- // The shortcut band keeps the requested leading order, retains Hindi and
- // Arabic at its end, and still repeats every shortcut in the complete A-Z
- // band so the feature remains a convenience rather than a restricted list.
+ // The shortcut band keeps the requested leading order. Hindi and Arabic do
+ // not appear there; they remain available only at the very end of the full
+ // list.
const firstAll = values.indexOf("af");
expect(firstAll).toBeGreaterThan(0);
expect(values.slice(1, 5)).toEqual(["en", "de", "es", "zh"]);
const commonBand = values.slice(1, firstAll);
- expect(commonBand.slice(-2)).toEqual(["hi", "ar"]);
- for (const code of ["en", "de", "es", "zh", "fr", "hi", "ar"]) {
+ expect(commonBand).not.toContain("hi");
+ expect(commonBand).not.toContain("ar");
+ expect(values.slice(-2)).toEqual(["hi", "ar"]);
+ for (const code of ["en", "de", "es", "zh", "fr"]) {
expect(values.indexOf(code)).toBeLessThan(firstAll);
expect(values.lastIndexOf(code)).toBeGreaterThan(firstAll);
}