Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

Show language endonyms across web and native pickers (#3887)

Amruth Pillai0eca2768b295
diff --git a/apps/mobile/app/(tabs)/settings/preferences.tsx b/apps/mobile/app/(tabs)/settings/preferences.tsx
index fba89fbe2..4f84759c3 100644
--- a/apps/mobile/app/(tabs)/settings/preferences.tsx
+++ b/apps/mobile/app/(tabs)/settings/preferences.tsx
@@ -4,10 +4,11 @@ import { useLingui } from "@lingui/react/macro";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useState } from "react";
import { DevSettings, View, useWindowDimensions } from "react-native";
+import { filterOptions } from "@reactive-resume/utils/string";
import { timezoneSchema } from "@reactive-resume/utils/timezone";
import { client, orpc } from "@/api/client";
import { SettingsGroup, SettingsPage } from "@/features/settings/layout";
-import { localeMap } from "@/features/settings/locale-names";
+import { getLocaleOptions } from "@/features/settings/locale-names";
import { useProfile } from "@/features/settings/queries";
import { getDeviceLocale, getLocalePreference, selectableLocales, setLocalePreference } from "@/i18n";
import { timeZones } from "@/lib/timezones";
@@ -62,11 +63,9 @@ export default function PreferencesScreen() {
},
onError: () => showToast({ message: t`Couldn't save the timezone. Try again.` }),
});
- const languageName = (value: Locale) => i18n._(localeMap[value]);
- const languages = selectableLocales.map((value) => ({ value, label: languageName(value) }));
- const matchingLanguages = languages.filter(({ value, label }) =>
- `${value} ${label}`.toLowerCase().includes(search.trim().toLowerCase()),
- );
+ const languages = getLocaleOptions(i18n, selectableLocales);
+ const languageName = (value: Locale) => languages.find((option) => option.value === value)?.label ?? value;
+ const matchingLanguages = filterOptions(languages, search);
const zones = [
...new Set(["UTC", deviceTimezone, ...(profile.data ? [profile.data.timezone] : []), ...timeZones]),
].sort();
@@ -179,11 +178,11 @@ export default function PreferencesScreen() {
disabled={changingLanguage}
onPress={() => void chooseLanguage(null)}
/>
- {matchingLanguages.map(({ value, label }) => (
+ {matchingLanguages.map(({ value, label, description }) => (
<ListRow
key={value}
title={label}
- subtitle={value}
+ subtitle={description}
selected={locale === value}
disabled={changingLanguage}
onPress={() => void chooseLanguage(value)}
diff --git a/apps/mobile/scripts/translation-copy.test.mjs b/apps/mobile/scripts/translation-copy.test.mjs
index 745d1d5c9..d14a57f2a 100644
--- a/apps/mobile/scripts/translation-copy.test.mjs
+++ b/apps/mobile/scripts/translation-copy.test.mjs
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
import { createRequire } from "node:module";
import { test } from "node:test";
import { fileURLToPath } from "node:url";
+import { filterOptions } from "@reactive-resume/utils/string";
const root = fileURLToPath(new URL("../../..", import.meta.url));
const serverRequire = createRequire(`${root}/apps/server/package.json`);
@@ -9,7 +10,7 @@ const { buildSync } = createRequire(serverRequire.resolve("tsx"))("esbuild");
const jsx = (type, props) => ({ type, props });
const tag = (parts, ...values) => parts.reduce((text, part, index) => text + part + (values[index] ?? ""), "");
-function fixture(locale = "en-US") {
+function fixture(locale = "en-US", uiLocale = "en-US") {
let state = [];
let cursor = 0;
let scope = "account-a";
@@ -39,7 +40,19 @@ function fixture(locale = "en-US") {
},
},
"react-native": { View: "View" },
- "@lingui/react/macro": { useLingui: () => ({ t: tag, i18n: { _: (descriptor) => descriptor.message } }) },
+ "@lingui/react/macro": {
+ useLingui: () => ({
+ t: tag,
+ i18n: {
+ _: (descriptor) =>
+ uiLocale === "de-DE"
+ ? ({ French: "Französisch", English: "Englisch", German: "Deutsch" }[descriptor.message] ??
+ descriptor.message)
+ : descriptor.message,
+ },
+ }),
+ },
+ "@lingui/core/macro": { msg: (parts, ...values) => ({ message: tag(parts, ...values) }) },
"expo-router": { useRouter: () => ({ replace: (href) => calls.push(["navigate", href]) }) },
"@/api/client": {
client: {
@@ -63,13 +76,6 @@ function fixture(locale = "en-US") {
},
}),
},
- "@/features/settings/locale-names": {
- localeMap: {
- "en-US": { message: "English" },
- "de-DE": { message: "German" },
- "fr-FR": { message: "French" },
- },
- },
"@/features/share/document": {
flushResume: async (id) => {
calls.push(["flush", id]);
@@ -173,6 +179,17 @@ test("native language copy excludes the source locale and rechecks the saved loc
assert.deepEqual(f.calls, [["flush", "source"]]);
});
+test("native translation picker shows the endonym and retains hidden search names", () => {
+ const f = fixture("en-US", "de-DE");
+ const picker = f.nodes(f.render()).find((node) => node.type === "SelectSheet").props;
+ const french = picker.options.find((option) => option.value === "fr-FR");
+ assert.equal(french.label, "Français");
+ assert.equal(french.description, "Französisch");
+ for (const query of ["Français", "French", "Französisch", "fr-FR"]) {
+ assert.deepEqual(filterOptions(picker.options, query), [french]);
+ }
+});
+
test("native language selection follows a late-loaded source and retains only compatible user choices", () => {
const f = fixture(null);
const picker = () => f.nodes(f.render()).find((node) => node.type === "SelectSheet").props;
diff --git a/apps/mobile/src/features/assistant/translate-resume.tsx b/apps/mobile/src/features/assistant/translate-resume.tsx
index b5c3efebe..f7d1d9962 100644
--- a/apps/mobile/src/features/assistant/translate-resume.tsx
+++ b/apps/mobile/src/features/assistant/translate-resume.tsx
@@ -9,7 +9,7 @@ import { client } from "@/api/client";
import { getAccountScope } from "@/auth/session";
import { useResumeStore } from "@/draft";
import { useDocumentOperations } from "@/features/documents/queries";
-import { localeMap } from "@/features/settings/locale-names";
+import { getLocaleOptions, localeMap } from "@/features/settings/locale-names";
import { flushResume } from "@/features/share/document";
import { selectableLocales } from "@/i18n";
import { routes } from "@/routes";
@@ -66,9 +66,7 @@ export function TranslateResume({ resumeId, onClose }: TranslateResumeProps) {
<SelectSheet
label={t`Language`}
value={locale}
- options={selectableLocales
- .filter((code) => code !== sourceLocale)
- .map((code) => ({ value: code, label: i18n._(localeMap[code]) }))}
+ options={getLocaleOptions(i18n, selectableLocales).filter(({ value }) => value !== sourceLocale)}
disabled={operations.busy}
searchable
onChange={setChosenLocale}
diff --git a/apps/mobile/src/features/design/picker.tsx b/apps/mobile/src/features/design/picker.tsx
index cdae59f2a..d95c416f1 100644
--- a/apps/mobile/src/features/design/picker.tsx
+++ b/apps/mobile/src/features/design/picker.tsx
@@ -3,7 +3,13 @@ import { useState } from "react";
import { FlatList, Pressable, View } from "react-native";
import { Icon, TextField, Text, useTheme } from "@/ui";
-export type PickerOption = { value: string; label: string; detail?: string | undefined };
+export type PickerOption = {
+ value: string;
+ label: string;
+ detail?: string | undefined;
+ description?: string | undefined;
+ keywords?: readonly string[] | undefined;
+};
export type PickerSpec = {
title: string;
@@ -21,7 +27,11 @@ export function Picker({ title, value, options, onPick, onDone }: PickerProps) {
const [query, setQuery] = useState("");
const needle = query.trim().toLowerCase();
const shown = needle
- ? options.filter((option) => `${option.label} ${option.detail ?? ""}`.toLowerCase().includes(needle))
+ ? options.filter((option) =>
+ `${option.label} ${option.description ?? ""} ${option.detail ?? ""} ${option.keywords?.join(" ") ?? ""}`
+ .toLowerCase()
+ .includes(needle),
+ )
: options;
return (
@@ -66,9 +76,16 @@ export function Picker({ title, value, options, onPick, onDone }: PickerProps) {
backgroundColor: pressed ? colors.press : selected ? colors.selectedFill : "transparent",
})}
>
- <Text variant="body" numberOfLines={1} style={{ flex: 1 }}>
- {item.label}
- </Text>
+ <View style={{ flex: 1, minWidth: 0, gap: space.s0 }}>
+ <Text variant="body" numberOfLines={1}>
+ {item.label}
+ </Text>
+ {item.description ? (
+ <Text variant="callout" color="ink3">
+ {item.description}
+ </Text>
+ ) : null}
+ </View>
{item.detail ? (
<Text variant="mono" color="ink3">
{item.detail}
diff --git a/apps/mobile/src/features/design/style-groups.tsx b/apps/mobile/src/features/design/style-groups.tsx
index ed1dbc1fa..a441ffb72 100644
--- a/apps/mobile/src/features/design/style-groups.tsx
+++ b/apps/mobile/src/features/design/style-groups.tsx
@@ -3,7 +3,6 @@ import type { PickerSpec } from "./picker";
import type { DensityId, FontPairingId, MarginId } from "./presets";
import type { MessageDescriptor } from "@lingui/core";
import type { EntryHeader, ResumeData } from "@reactive-resume/schema/resume/data";
-import type { Locale } from "@reactive-resume/utils/locale";
import { msg } from "@lingui/core/macro";
import { useLingui } from "@lingui/react/macro";
import { useState } from "react";
@@ -29,7 +28,7 @@ import {
matchMargins,
rgbaToHex,
} from "./presets";
-import { localeMap } from "@/features/settings/locale-names";
+import { getLocaleOptions } from "@/features/settings/locale-names";
import { selectableLocales } from "@/i18n";
import { Button, Icon, IconButton, Segmented, Text, haptics, listLayout, useTheme } from "@/ui";
@@ -503,7 +502,8 @@ export function PageGroup({ data, write, disabled, pick }: GroupProps) {
const { colors, radius, space, size } = useTheme();
const { page } = data.metadata;
const margins = matchMargins(data.metadata);
- const languageName = (code: string) => (code in localeMap ? i18n._(localeMap[code as Locale]) : code);
+ const languageOptions = getLocaleOptions(i18n, selectableLocales);
+ const languageName = (code: string) => languageOptions.find((option) => option.value === code)?.label ?? code;
const set = (key: string, mutate: (value: ResumeData["metadata"]["page"]) => void) =>
write(key, (draft) => mutate(draft.metadata.page), true);
@@ -543,7 +543,7 @@ export function PageGroup({ data, write, disabled, pick }: GroupProps) {
pick({
title: t`Language`,
value: page.locale,
- options: selectableLocales.map((code) => ({ value: code, label: languageName(code), detail: code })),
+ options: languageOptions,
onPick: (locale) =>
set("locale", (draft) => {
draft.locale = locale;
@@ -563,9 +563,6 @@ export function PageGroup({ data, write, disabled, pick }: GroupProps) {
opacity: disabled ? 0.45 : 1,
}}
>
- <Text variant="mono" color="ink3">
- {page.locale}
- </Text>
<Text variant="body" numberOfLines={1} style={{ flex: 1 }}>
{languageName(page.locale)}
</Text>
diff --git a/apps/mobile/src/features/letters/design.tsx b/apps/mobile/src/features/letters/design.tsx
index 41b74dcbc..3fb7986b1 100644
--- a/apps/mobile/src/features/letters/design.tsx
+++ b/apps/mobile/src/features/letters/design.tsx
@@ -25,6 +25,7 @@ import { relinkLetter } from "./save";
import { relinked } from "./write";
import { useLetterStore } from "@/draft";
import { applyTextSize } from "@/features/design/presets";
+import { getLocaleOptions } from "@/features/settings/locale-names";
import { selectableLocales } from "@/i18n";
import { routes } from "@/routes";
import { Button, IconButton, ListRow, Segmented, SelectSheet, Switch, Text, TextField, useTheme } from "@/ui";
@@ -260,17 +261,13 @@ type LetterLanguageFieldProps = { letter: LetterDocument; disabled: boolean };
/** The letter's language, independent of whether its design follows the resume. Write and Design both offer it. */
export function LetterLanguageField({ letter, disabled }: LetterLanguageFieldProps) {
const { t, i18n } = useLingui();
- const languageName = new Intl.DisplayNames([i18n.locale], { type: "language" });
return (
<SelectSheet
label={t`Language`}
value={letter.style.metadata.page.locale}
disabled={disabled}
- options={selectableLocales.map((code) => ({
- value: code,
- label: languageName.of(code) ?? code,
- description: code,
- }))}
+ options={getLocaleOptions(i18n, selectableLocales)}
+ searchable
onChange={(value) =>
useLetterStore.getState().update((draft) => void (draft.style.metadata.page.locale = value), {
coalesceKey: "locale",
diff --git a/apps/mobile/src/features/settings/locale-names.ts b/apps/mobile/src/features/settings/locale-names.ts
index 290f8b9db..0a923f6c4 100644
--- a/apps/mobile/src/features/settings/locale-names.ts
+++ b/apps/mobile/src/features/settings/locale-names.ts
@@ -1,6 +1,20 @@
-import type { MessageDescriptor } from "@lingui/core";
+import type { I18n, MessageDescriptor } from "@lingui/core";
import type { Locale } from "@reactive-resume/utils/locale";
import { msg } from "@lingui/core/macro";
+import { getLanguageName } from "@reactive-resume/utils/locale";
+
+export function getLocaleOptions(i18n: I18n, locales: readonly Locale[]) {
+ return locales.map((value) => {
+ const label = getLanguageName(value);
+ const translated = i18n._(localeMap[value]);
+ return {
+ value,
+ label,
+ description: translated === label ? undefined : translated,
+ keywords: [value, translated, getLanguageName(value, "en-US")],
+ };
+ });
+}
export const localeMap = {
"af-ZA": msg`Afrikaans`,
diff --git a/apps/mobile/src/features/write/resume-language.tsx b/apps/mobile/src/features/write/resume-language.tsx
index 09a3c32ed..229d6661b 100644
--- a/apps/mobile/src/features/write/resume-language.tsx
+++ b/apps/mobile/src/features/write/resume-language.tsx
@@ -1,10 +1,9 @@
-import type { Locale } from "@reactive-resume/utils/locale";
import { useLingui } from "@lingui/react/macro";
import { useState } from "react";
import { Pressable, View } from "react-native";
import { edit } from "./hooks";
import { Picker } from "@/features/design/picker";
-import { localeMap } from "@/features/settings/locale-names";
+import { getLocaleOptions } from "@/features/settings/locale-names";
import { selectableLocales } from "@/i18n";
import { Icon, Sheet, Text, useTheme } from "@/ui";
@@ -18,7 +17,8 @@ export function ResumeLanguage({ locale, locked }: ResumeLanguageProps) {
const { t, i18n } = useLingui();
const { colors, space } = useTheme();
const [open, setOpen] = useState(false);
- const languageName = (code: string) => (code in localeMap ? i18n._(localeMap[code as Locale]) : code);
+ const options = getLocaleOptions(i18n, selectableLocales);
+ const languageName = (code: string) => options.find((option) => option.value === code)?.label ?? code;
const label = t({
comment: "Label beside the picker for the language a resume's headings and dates print in",
message: "Resume language",
@@ -48,7 +48,7 @@ export function ResumeLanguage({ locale, locked }: ResumeLanguageProps) {
<Picker
title={label}
value={locale}
- options={selectableLocales.map((code) => ({ value: code, label: languageName(code), detail: code }))}
+ options={options}
onPick={(next) =>
edit((draft) => {
draft.metadata.page.locale = next;
diff --git a/apps/mobile/src/ui/fields.tsx b/apps/mobile/src/ui/fields.tsx
index e0f855985..0c2dbe32a 100644
--- a/apps/mobile/src/ui/fields.tsx
+++ b/apps/mobile/src/ui/fields.tsx
@@ -209,6 +209,7 @@ export type SelectOption<T extends string> = {
value: T;
label: string;
description?: string | undefined;
+ keywords?: readonly string[] | undefined;
icon?: IconName | undefined;
};
diff --git a/apps/web/src/features/assistant/translate-resume.tsx b/apps/web/src/features/assistant/translate-resume.tsx
index c3cc19fdc..cc701c1b8 100644
--- a/apps/web/src/features/assistant/translate-resume.tsx
+++ b/apps/web/src/features/assistant/translate-resume.tsx
@@ -15,12 +15,13 @@ import {
DialogHeader,
DialogTitle,
} from "@reactive-resume/ui/components/dialog";
-import { NativeSelect } from "@reactive-resume/ui/components/native-select";
import { toast } from "@reactive-resume/ui/components/toast";
import { handToAssistant } from "./handoff";
+import { Combobox } from "@/components/ui/combobox";
+import { getLocaleOptions } from "@/features/locale/locale-options";
import { savePendingChanges, useResumeStore } from "@/features/resume/builder/draft";
import { getResumeErrorMessage } from "@/libs/error-message";
-import { localeMap, selectableLocales } from "@/libs/locale";
+import { localeMap } from "@/libs/locale";
import { client, orpc } from "@/libs/orpc/client";
type TranslateResumeProps = { resumeId: string; onClose: () => void };
@@ -86,20 +87,13 @@ export function TranslateResume({ resumeId, onClose }: TranslateResumeProps) {
<label htmlFor={languageId}>
<Trans>Language</Trans>
</label>
- <NativeSelect
+ <Combobox
id={languageId}
value={locale}
disabled={busy}
- onChange={(event) => setChosenLocale(event.target.value as Locale)}
- >
- {selectableLocales
- .filter((code) => code !== sourceLocale)
- .map((code) => (
- <option key={code} value={code}>
- {i18n._(localeMap[code])}
- </option>
- ))}
- </NativeSelect>
+ onValueChange={setChosenLocale}
+ options={getLocaleOptions().filter(({ value }) => value !== sourceLocale)}
+ />
<DialogFooter>
<Button disabled={busy || !sourceLocale || locale === sourceLocale} onClick={() => void create()}>
<Trans>Create language copy</Trans>
diff --git a/apps/web/src/features/command-palette/pages/preferences/language.tsx b/apps/web/src/features/command-palette/pages/preferences/language.tsx
index cb715fe83..6d9e1be16 100644
--- a/apps/web/src/features/command-palette/pages/preferences/language.tsx
+++ b/apps/web/src/features/command-palette/pages/preferences/language.tsx
@@ -1,18 +1,15 @@
-import { useLingui } from "@lingui/react";
import { Trans } from "@lingui/react/macro";
import { CommandItem } from "@reactive-resume/ui/components/command";
import { BaseCommandGroup } from "../base";
-import { changeLocale, localeMap, selectableLocales } from "@/libs/locale";
+import { getLocaleOptions } from "@/features/locale/locale-options";
+import { changeLocale } from "@/libs/locale";
export function LanguageCommandPage() {
- const { i18n } = useLingui();
-
return (
<BaseCommandGroup page="language" heading={<Trans>Language</Trans>}>
- {selectableLocales.map((value) => (
- <CommandItem key={value} onSelect={() => changeLocale(value)}>
- <span className="font-mono text-xs text-ink-3">{value}</span>
- {i18n.t(localeMap[value])}
+ {getLocaleOptions().map(({ value, label, keywords }) => (
+ <CommandItem key={value} value={value} keywords={keywords} onSelect={() => changeLocale(value)}>
+ {label}
</CommandItem>
))}
</BaseCommandGroup>
diff --git a/apps/web/src/features/homepage/sections.tsx b/apps/web/src/features/homepage/sections.tsx
index 33468a59b..092d89f76 100644
--- a/apps/web/src/features/homepage/sections.tsx
+++ b/apps/web/src/features/homepage/sections.tsx
@@ -6,7 +6,7 @@ import { useQuery } from "@tanstack/react-query";
import { useEffect, useState } from "react";
import { templateSchema } from "@reactive-resume/schema/templates";
import { Icon } from "@reactive-resume/ui/components/icon";
-import { isRTL, supportedLocales } from "@reactive-resume/utils/locale";
+import { getLanguageName, isRTL, supportedLocales } from "@reactive-resume/utils/locale";
import { cn } from "@reactive-resume/utils/style";
import { prefersReducedMotion, SCENE, useLanding } from "./scroll";
import { CtaLink, Doodle, labelClass } from "./ui";
@@ -185,26 +185,6 @@ export function Languages() {
);
}
-// Languages more than one locale shares are told apart by region or script; the rest go by the language alone.
-const nameVariants: Record<string, string> = { "zh-CN": "zh-Hans", "zh-TW": "zh-Hant" };
-const sharedLanguages = new Set(["en", "pt", "zh"]);
-// Chromium ships no locale data for these, so it would name them in English; the names are the platform's own (CLDR).
-const unlistedNames: Record<string, string> = { km: "ខ្មែរ", ne: "नेपाली", or: "ଓଡ଼ିଆ", sq: "shqip" };
-
-/**
- * A locale's name in its own language ("Deutsch", "日本語"), from the platform's locale data. `exact` tells locales of
- * one language apart ("British English"); without it, it's the language alone ("English").
- */
-function ownLanguageName(locale: string, exact = true) {
- const language = locale.split("-")[0] ?? locale;
- const code = exact && sharedLanguages.has(language) ? (nameVariants[locale] ?? locale) : language;
- const name =
- (Intl.DisplayNames.supportedLocalesOf([locale]).length === 0 ? unlistedNames[language] : undefined) ??
- new Intl.DisplayNames([locale], { type: "language" }).of(code) ??
- locale;
- return name.charAt(0).toLocaleUpperCase(locale) + name.slice(1);
-}
-
/**
* The homepage in `locale`, back at the Languages scene, keeping the rest of the address. English is named too, so
* it overrides a saved choice; the server points its canonical address at the plain one.
@@ -220,7 +200,7 @@ type LanguageDoorwayProps = { className?: string; nameClassName?: string };
/** The current language, in its own name, leading to the Languages scene: the header's and the footer's way there. */
export function LanguageDoorway({ className, nameClassName }: LanguageDoorwayProps) {
const { i18n } = useLingui();
- const name = ownLanguageName(i18n.locale, false);
+ const name = getLanguageName(i18n.locale, i18n.locale, false);
return (
<a href="#languages" title={t`Change language`} className={cn("flex items-center", className)}>
<Icon name="translate" size={16} />
@@ -242,7 +222,7 @@ function LanguageIndex() {
<nav aria-labelledby="languages-title" className="max-w-[46em]">
<ul className="font-display text-[clamp(17px,1.4vw,21px)] leading-normal text-balance text-ink-2">
{supportedLocales.map((locale, index) => {
- const name = ownLanguageName(locale);
+ const name = getLanguageName(locale);
const dir = isRTL(locale) ? "rtl" : undefined;
return (
<li key={locale} className="inline">
diff --git a/apps/web/src/features/locale/locale-options.tsx b/apps/web/src/features/locale/locale-options.tsx
index 681776751..884d75b42 100644
--- a/apps/web/src/features/locale/locale-options.tsx
+++ b/apps/web/src/features/locale/locale-options.tsx
@@ -1,24 +1,28 @@
import { i18n } from "@lingui/core";
+import { getLanguageName, isRTL, languageTag } from "@reactive-resume/utils/locale";
import { localeMap, selectableLocales } from "@/libs/locale";
export const getLocaleOptions = () => {
return selectableLocales.map((value) => {
const label = localeMap[value];
- const name = i18n.t(label);
+ const translated = i18n.t(label);
+ const name = getLanguageName(value);
return {
value,
label: (
- <span className="flex items-center gap-x-2">
- <span className="font-mono text-xs text-ink-3">{value}</span>
- {name}
+ <span className="flex flex-wrap items-center gap-x-1">
+ <bdi lang={languageTag(value)} dir={isRTL(value) ? "rtl" : "ltr"}>
+ {name}
+ </bdi>
+ {name !== translated && <span className="text-ink-3"> · {translated}</span>}
</span>
),
// Shown in the collapsed trigger (a ReactNode label would otherwise fall back to the ISO code).
textValue: name,
// Match against the translated name, the ISO code, and the untranslated English name so
// the list stays searchable regardless of the active UI locale.
- keywords: [name, value.toLowerCase(), label.message].filter((keyword): keyword is string => Boolean(keyword)),
+ keywords: [name, translated, value, getLanguageName(value, "en-US")],
};
});
};
diff --git a/apps/web/src/features/user/dropdown-menu.tsx b/apps/web/src/features/user/dropdown-menu.tsx
index 208de9033..c4d4d0c2c 100644
--- a/apps/web/src/features/user/dropdown-menu.tsx
+++ b/apps/web/src/features/user/dropdown-menu.tsx
@@ -19,11 +19,12 @@ import {
} from "@reactive-resume/ui/components/dropdown-menu";
import { Icon } from "@reactive-resume/ui/components/icon";
import { toast } from "@reactive-resume/ui/components/toast";
+import { getLocaleOptions } from "@/features/locale/locale-options";
import { useTheme } from "@/features/theme/provider";
import { clearAccountData } from "@/libs/auth/clear-account-data";
import { authClient } from "@/libs/auth/client";
import { getReadableErrorMessage } from "@/libs/error-message";
-import { changeLocale, localeMap, selectableLocales } from "@/libs/locale";
+import { changeLocale } from "@/libs/locale";
import { isTheme } from "@/libs/theme";
type Props = {
@@ -90,9 +91,9 @@ export function UserDropdownMenu({ children }: Props) {
</DropdownMenuSubTrigger>
<DropdownMenuSubContent className="max-h-[400px] overflow-y-auto">
<DropdownMenuRadioGroup value={i18n.locale} onValueChange={changeLocale}>
- {selectableLocales.map((value) => (
+ {getLocaleOptions().map(({ value, label }) => (
<DropdownMenuRadioItem key={value} value={value}>
- {i18n.t(localeMap[value])}
+ {label}
</DropdownMenuRadioItem>
))}
</DropdownMenuRadioGroup>
diff --git a/docs/guides/changing-appearance-and-language.mdx b/docs/guides/changing-appearance-and-language.mdx
index 1c10a6439..c88d26b26 100644
--- a/docs/guides/changing-appearance-and-language.mdx
+++ b/docs/guides/changing-appearance-and-language.mdx
@@ -52,7 +52,7 @@ The Android and iPhone apps follow your device's preferred languages until you c
</Step>
<Step title="Choose a language under Language">
- Open the picker and choose from more than 50 languages. You can type to filter the list.
+ Open the picker and choose from more than 50 languages. Each language appears in its own name, with its name in the current interface language below or beside it when different. For example, a German interface shows **Français · Französisch**. Search by either name, its English name, or a language code such as `fr-FR`.
</Step>
</Steps>
@@ -62,6 +62,13 @@ You can also change it from your name in the sidebar (**Language**), or with <kb
Before you sign in, choose a language on the homepage: the language name in the header and footer leads to the languages section, which lists every language in its own name. Each name opens the homepage in that language, and the choice carries over when you create an account.
+<Frame caption="Language names stay recognizable in a foreign-language interface">
+ <img
+ src="/images/guides/changing-appearance-and-language/language-endonyms.png"
+ alt="Public language picker in a German interface showing Français with Französisch as the secondary name and no visible ISO code"
+ />
+</Frame>
+
Account emails, such as email verification, password resets and email change approvals, use the language you last used Reactive Resume in, on the website or in the app. A new account starts in the language you signed up in. The links and how long they stay valid are the same in every language.
What you write keeps its own direction. In a right-to-left language such as Arabic, a German or English description, title or salary still reads left to right, each paragraph from its first letter, and Arabic text reads right to left inside an English interface.
diff --git a/docs/images/guides/changing-appearance-and-language/language-endonyms.png b/docs/images/guides/changing-appearance-and-language/language-endonyms.png
new file mode 100644
index 000000000..965aec43c
Binary files /dev/null and b/docs/images/guides/changing-appearance-and-language/language-endonyms.png differ
diff --git a/packages/utils/src/locale.ts b/packages/utils/src/locale.ts
index 284e3c9ab..970487eb1 100644
--- a/packages/utils/src/locale.ts
+++ b/packages/utils/src/locale.ts
@@ -99,6 +99,24 @@ export function getPreferredLocale(languages: readonly string[]): Locale {
/** A locale as a BCP 47 language tag for hreflang and `inLanguage`: "sr-SP" isn't a valid region, so it's "sr". */
export const languageTag = (locale: Locale) => (locale === "sr-SP" ? "sr" : locale);
+const nameVariants: Record<string, string> = { "zh-CN": "zh-Hans", "zh-TW": "zh-Hant" };
+const sharedLanguages = new Set(["en", "pt", "zh"]);
+// Chromium lacks locale data for these; keep their CLDR names instead of falling back to English.
+const unlistedNames: Record<string, string> = { km: "ខ្មែរ", ne: "नेपाली", or: "ଓଡ଼ିଆ", sq: "shqip" };
+
+/** A language's name, in its own language by default; exact names distinguish supported regions and scripts. */
+export function getLanguageName(locale: string, displayLocale = locale, exact = true) {
+ const language = locale.split("-")[0] ?? locale;
+ const code = exact && sharedLanguages.has(language) ? (nameVariants[locale] ?? locale) : language;
+ const name =
+ (displayLocale === locale && Intl.DisplayNames.supportedLocalesOf([locale]).length === 0
+ ? unlistedNames[language]
+ : undefined) ??
+ new Intl.DisplayNames([displayLocale], { type: "language" }).of(code) ??
+ locale;
+ return name.charAt(0).toLocaleUpperCase(displayLocale) + name.slice(1);
+}
+
/** hreflang alternates for a page: every real locale plus x-default. */
export function getLocaleAlternates(pageUrl: string) {
const alternates = supportedLocales.map((locale) => ({
diff --git a/packages/utils/src/string.test.ts b/packages/utils/src/string.test.ts
index 3bfaf699c..7045d5062 100644
--- a/packages/utils/src/string.test.ts
+++ b/packages/utils/src/string.test.ts
@@ -42,6 +42,14 @@ describe("filterOptions", () => {
expect(filterOptions(options, "d")).toEqual([]);
});
+ it("finds native language choices through hidden English and translated names", () => {
+ const french = { value: "fr-FR", label: "Français", keywords: ["French", "Französisch", "fr-FR"] };
+ for (const query of ["francais", "French", "franzosisch", "FR-FR"]) {
+ expect(filterOptions([french, ...options], query)).toContain(french);
+ }
+ expect(filterOptions([french], "Japanese")).toEqual([]);
+ });
+
it("matches independently of a Turkish runtime's default casing", () => {
const lower = String.prototype.toLocaleLowerCase;
const locale = vi.spyOn(String.prototype, "toLocaleLowerCase").mockImplementation(function (this: string) {
diff --git a/packages/utils/src/string.ts b/packages/utils/src/string.ts
index 1266fc939..dce5f0c21 100644
--- a/packages/utils/src/string.ts
+++ b/packages/utils/src/string.ts
@@ -80,11 +80,19 @@ const fold = (text: string) =>
.replace(/[̀-ͯ]/g, "")
.toLowerCase();
-/** The options whose label contains the query, ignoring case and accents, or whose value is the whole query. */
-export function filterOptions<T extends { value: string; label: string }>(options: readonly T[], query: string): T[] {
+/** Match labels and hidden search keywords loosely, or a value exactly, ignoring case and accents. */
+export function filterOptions<T extends { value: string; label: string; keywords?: readonly string[] | undefined }>(
+ options: readonly T[],
+ query: string,
+): T[] {
const needle = fold(query.trim());
if (!needle) return [...options];
- return options.filter((option) => fold(option.label).includes(needle) || fold(option.value) === needle);
+ return options.filter(
+ (option) =>
+ fold(option.label).includes(needle) ||
+ fold(option.value) === needle ||
+ option.keywords?.some((keyword) => fold(keyword).includes(needle)),
+ );
}
export function stripHtml(html: string | undefined): string {
diff --git a/tests/e2e/specs/assistant.spec.ts b/tests/e2e/specs/assistant.spec.ts
index aefb49c03..2a888b1f3 100644
--- a/tests/e2e/specs/assistant.spec.ts
+++ b/tests/e2e/specs/assistant.spec.ts
@@ -377,7 +377,7 @@ test("language copy keeps the source and waits for Send and review before saving
// Assistant discovery opens the same copy picker as the document menu; cancel creates/sends nothing.
await page.getByRole("button", { name: "Translate into…", exact: true }).click();
const dialog = page.getByRole("dialog", { name: "Translate into…" });
- await expect(dialog.getByLabel("Language")).toHaveValue("de-DE");
+ await expect(dialog.getByLabel("Language")).toHaveText("Deutsch");
await dialog.getByRole("button", { name: "Close", exact: true }).click();
expect(stub.requests).toHaveLength(calls);
await page.getByRole("button", { name: "Close the assistant" }).click();
@@ -426,8 +426,11 @@ test("language copy keeps the source and waits for Send and review before saving
expect(JSON.parse(await resumeJson(page, copyId)).data.basics.name).toBe("Priya Raman");
expect(JSON.parse(await resumeJson(page, sourceId))).toEqual(source);
await page.getByRole("button", { name: "Translate into…", exact: true }).click();
- await expect(dialog.getByLabel("Language")).toHaveValue("en-US");
- await expect(dialog.getByLabel("Language").locator('option[value="de-DE"]')).toHaveCount(0);
+ await expect(dialog.getByLabel("Language")).toHaveText(/^(American English|English \(United States\))$/);
+ await dialog.getByLabel("Language").click();
+ await expect(page.getByRole("listbox")).toBeVisible();
+ await expect(page.getByRole("option", { name: /Deutsch/ })).toHaveCount(0);
+ await page.keyboard.press("Escape");
await dialog.getByRole("button", { name: "Close", exact: true }).click();
});
diff --git a/tests/e2e/specs/first-visit-language.spec.ts b/tests/e2e/specs/first-visit-language.spec.ts
index 46422c26a..2d6a557b3 100644
--- a/tests/e2e/specs/first-visit-language.spec.ts
+++ b/tests/e2e/specs/first-visit-language.spec.ts
@@ -27,6 +27,36 @@ test("explicit language wins and the saved choice survives navigation", async ({
await expect(page.locator("html")).toHaveAttribute("lang", "ja-JP");
});
+test("a foreign-language picker shows endonyms and keeps translated names and codes searchable", async ({
+ page,
+ context,
+}, info) => {
+ await page.goto("/ats-checker?locale=de-DE&campaign=endonyms");
+ await expect(page.getByRole("heading", { level: 1 })).toBeFocused();
+ await page.getByRole("combobox", { name: "Sprache ändern", exact: true }).click();
+ await expect(page.getByRole("listbox")).toBeVisible();
+ const french = page.getByRole("option").filter({ hasText: "Français" });
+ await expect(french).toHaveText(/Français\s*·\s*Französisch/);
+ await expect(french).not.toContainText("fr-FR");
+ await expect(french.locator('[lang="fr-FR"]')).toHaveText("Français");
+ await french.scrollIntoViewIfNeeded();
+ await page
+ .getByRole("listbox")
+ .screenshot({ path: info.outputPath("language-endonyms.png"), animations: "disabled" });
+ const search = page.getByRole("combobox").last();
+ for (const query of ["Français", "Französisch", "French", "fr-FR"]) {
+ await search.fill(query);
+ await expect(page.getByRole("option")).toHaveCount(1);
+ await expect(french).toBeVisible();
+ }
+ await french.click();
+ await expect(page.locator("html")).toHaveAttribute("lang", "fr-FR");
+ expect(new URL(page.url()).searchParams.get("campaign")).toBe("endonyms");
+ expect((await context.cookies()).find((cookie) => cookie.name === "locale")?.value).toBe("fr-FR");
+ await page.reload();
+ await expect(page.locator("html")).toHaveAttribute("lang", "fr-FR");
+});
+
test("shared homepage HTML ignores Accept-Language while private unavailable pages honor explicit choice", async ({
request,
}) => {
diff --git a/tests/e2e/specs/rx100-career-ai.spec.ts b/tests/e2e/specs/rx100-career-ai.spec.ts
index 98156b80d..b8955bd85 100644
--- a/tests/e2e/specs/rx100-career-ai.spec.ts
+++ b/tests/e2e/specs/rx100-career-ai.spec.ts
@@ -183,7 +183,10 @@ test("a letter starts in the posting's language and its Language control keeps t
await page.goto(`/builder/letter/${letter.id}?mode=design`);
await page.locator('section[aria-labelledby="letter-design-language"] button').first().click();
- await page.getByRole("option", { name: /fr-FR/ }).click();
+ await expect(page.getByRole("listbox")).toBeVisible();
+ const french = page.getByRole("option", { name: /^Français/ });
+ await expect(french).not.toContainText("fr-FR");
+ await french.click();
await expect(async () => {
const after = await (await page.request.get(`/api/openapi/cover-letters/${letter.id}`)).json();
expect(after.style.metadata.page.locale).toBe("fr-FR");