diff --git a/.changeset/35425-one-language-list.md b/.changeset/35425-one-language-list.md
new file mode 100644
index 00000000000..db247a1eb1a
--- /dev/null
+++ b/.changeset/35425-one-language-list.md
@@ -0,0 +1,16 @@
+---
+'@object-ui/i18n': patch
+'@object-ui/app-shell': patch
+'@object-ui/console': patch
+---
+
+feat(i18n): the sign-in page and the in-app language menu offer one list, every interface language
+
+Clause-②: yes (widening) — @object-ui/i18n adds `appContentLanguages` to the i18n context and the locale key `console.localeSwitcher.appContentDefault` in all eleven packs; `offerableLanguages` is never `null` any more; nothing removed
+Metadata-protocol: none
+
+The in-app language menu used to list only the languages the app declares (four on HotCRM), while the sign-in page, which has no session to ask the app with, listed all eleven interface languages. A language picked on the sign-in page (German, Korean) was then missing from the menu after sign-in.
+
+Both now list all eleven, as does the profile page's language card. A language the app's own content is not translated into stays selectable: the interface shows in it, and object, field and view names show in the deployment's default language. The menu row of such a language carries one muted line, "App content shows in the default language", and the profile card shows the same line under the picker when one is chosen. The sign-in page marks nothing, because nothing has been read about the app there.
+
+`offerableLanguages` on `useObjectTranslation()` is now every platform locale table language whatever the app ships. The app's list (`loadLocales`) feeds the new `appContentLanguages`: the table languages it covers, or `null` when not known (in flight, signed out, failed, or naming no table language). `GET /api/v1/i18n/locales` is unchanged and no language pack is added. The organization's default-language setting keeps the app's declared list.
diff --git a/ui/apps/console/src/pages/system/ProfilePage.tsx b/ui/apps/console/src/pages/system/ProfilePage.tsx
index e29db123425..db62d455d90 100644
--- a/ui/apps/console/src/pages/system/ProfilePage.tsx
+++ b/ui/apps/console/src/pages/system/ProfilePage.tsx
@@ -581,8 +581,11 @@ interface LanguageCardProps {
* ## What is offered, and what happens when the write route is not there
*
* The option list is `offerableLanguages` — the i18n provider's own answer
- * (the platform locale table ∩ the deployment's published locales, as table
- * tags), which is what `LocaleSwitcher` renders too. ⛔ No second list is introduced here.
+ * (every platform locale table language, as table tags, objectstack#35425),
+ * which is what `LocaleSwitcher` renders too. ⛔ No second list is introduced here.
+ * A chosen language the deployment's own content is not translated into
+ * (outside the provider's `appContentLanguages`, when that is known) carries
+ * the same one-line hint the globe menu shows on that row.
* A stored tag that is not in that set is prepended so the control shows the
* truth rather than rendering blank.
*
@@ -598,7 +601,7 @@ interface LanguageCardProps {
* card's own "hidden ... rather than rendering a control that answers 403".
*/
function LanguageCard({ userId }: LanguageCardProps) {
- const { t, offerableLanguages } = useObjectTranslation();
+ const { t, offerableLanguages, appContentLanguages } = useObjectTranslation();
const adapter = useAdapter();
const perms = usePermissions();
@@ -645,7 +648,7 @@ function LanguageCard({ userId }: LanguageCardProps) {
}, [adapter, userId]);
const codes = useMemo(() => {
- const offered = offerableLanguages ?? [];
+ const offered = offerableLanguages;
// A stored tag the deployment no longer publishes is still this account's
// truth; showing it beats a select whose value matches no option.
return stored && stored.length > 0 && !offered.includes(stored)
@@ -653,7 +656,16 @@ function LanguageCard({ userId }: LanguageCardProps) {
: [...offered];
}, [offerableLanguages, stored]);
- if (!adapter || !rowRead || offerableLanguages === null) return null;
+ if (!adapter || !rowRead) return null;
+
+ // The globe menu's hint, for the language chosen here: only when the app's
+ // list is known and leaves that language out. "Use the deployment default"
+ // is never marked — it IS the default language — and neither is a stored
+ // tag outside the table (`th`), which the app list is never read for.
+ const choiceInDefault =
+ offerableLanguages.includes(choice) &&
+ appContentLanguages !== null &&
+ !appContentLanguages.includes(choice);
const writable = resolveFieldAffordance('editFormFields', perms, 'sys_user', 'locale');
const dirty = choice !== (stored ?? USE_DEPLOYMENT_DEFAULT);
@@ -753,6 +765,13 @@ function LanguageCard({ userId }: LanguageCardProps) {
invalid={!!fieldError}
describedBy={fieldError ? 'profile-language-error' : undefined}
/>
+ {choiceInDefault && (
+
+ {t('console.localeSwitcher.appContentDefault', {
+ defaultValue: 'App content shows in the default language',
+ })}
+
+ )}
{fieldError && (
{fieldError}
diff --git a/ui/apps/console/src/pages/system/__tests__/ProfilePage.access.test.tsx b/ui/apps/console/src/pages/system/__tests__/ProfilePage.access.test.tsx
index 7f9f2dca81e..7a8302469bb 100644
--- a/ui/apps/console/src/pages/system/__tests__/ProfilePage.access.test.tsx
+++ b/ui/apps/console/src/pages/system/__tests__/ProfilePage.access.test.tsx
@@ -50,7 +50,7 @@ vi.mock('@object-ui/fields', async (importOriginal) => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal>()),
- useObjectTranslation: () => ({ t: translate, offerableLanguages: ['en', 'zh'] }),
+ useObjectTranslation: () => ({ t: translate, offerableLanguages: ['en', 'zh'], appContentLanguages: null }),
}));
vi.mock('@object-ui/react', async (importOriginal) => ({
diff --git a/ui/apps/console/src/pages/system/__tests__/ProfilePage.appLock-29748.test.tsx b/ui/apps/console/src/pages/system/__tests__/ProfilePage.appLock-29748.test.tsx
index 06bb75472db..797553b417c 100644
--- a/ui/apps/console/src/pages/system/__tests__/ProfilePage.appLock-29748.test.tsx
+++ b/ui/apps/console/src/pages/system/__tests__/ProfilePage.appLock-29748.test.tsx
@@ -54,7 +54,7 @@ vi.mock('@object-ui/fields', async (importOriginal) => ({
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal>()),
- useObjectTranslation: () => ({ t: translate, language: 'en', offerableLanguages: ['en'] }),
+ useObjectTranslation: () => ({ t: translate, language: 'en', offerableLanguages: ['en'], appContentLanguages: null }),
}));
vi.mock('@object-ui/react', async (importOriginal) => ({
diff --git a/ui/apps/console/src/pages/system/__tests__/ProfilePage.language.test.tsx b/ui/apps/console/src/pages/system/__tests__/ProfilePage.language.test.tsx
index 6d91d25ed2e..406d9b9ed34 100644
--- a/ui/apps/console/src/pages/system/__tests__/ProfilePage.language.test.tsx
+++ b/ui/apps/console/src/pages/system/__tests__/ProfilePage.language.test.tsx
@@ -58,12 +58,13 @@ import { describe, expect, it, vi, beforeEach } from 'vitest';
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { normaliseClientError } from '@object-ui/data-objectstack';
-const { user, updateUser, findOne, update, offerable, writable } = vi.hoisted(() => ({
+const { user, updateUser, findOne, update, offerable, appContent, writable } = vi.hoisted(() => ({
user: { value: { id: 'usr_1', name: 'Ada', email: 'ada@example.com' } as Record | null },
updateUser: vi.fn(async () => {}),
findOne: vi.fn<(resource: string, id: string) => Promise>(async () => ({ id: 'usr_1' })),
update: vi.fn<(resource: string, id: string, data: unknown) => Promise>(async () => ({})),
- offerable: { value: ['en', 'zh', 'ja'] as readonly string[] | null },
+ offerable: { value: ['en', 'zh', 'ja'] as readonly string[] },
+ appContent: { value: null as readonly string[] | null },
writable: { value: true },
}));
@@ -98,6 +99,7 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({
String(options?.[name] ?? ''),
),
offerableLanguages: offerable.value,
+ appContentLanguages: appContent.value,
}),
}));
@@ -149,6 +151,7 @@ describe('ProfilePage — my language (objectui#7501)', () => {
vi.clearAllMocks();
user.value = { id: 'usr_1', name: 'Ada', email: 'ada@example.com' };
offerable.value = ['en', 'zh', 'ja'];
+ appContent.value = null;
writable.value = true;
findOne.mockResolvedValue({ id: 'usr_1' });
update.mockResolvedValue({});
@@ -276,6 +279,7 @@ describe('ProfilePage — a stored spelling of a table language (objectstack#305
beforeEach(() => {
vi.clearAllMocks();
user.value = { id: 'usr_1', name: 'Ada', email: 'ada@example.com' };
+ appContent.value = null;
writable.value = true;
update.mockResolvedValue({});
});
@@ -304,4 +308,39 @@ describe('ProfilePage — a stored spelling of a table language (objectstack#305
expect(await listed(select)).toHaveLength(4);
expect(select).toHaveTextContent('ไทย');
});
+
+ it('says the app content shows in the default language for a chosen language the app does not ship (objectstack#35425)', async () => {
+ offerable.value = ['en', 'zh-Hans', 'ja'];
+ appContent.value = ['en', 'zh-Hans'];
+ findOne.mockResolvedValue({ id: 'usr_1', locale: 'en' });
+ const select = await renderProfile();
+
+ // A shipped language, and the deployment default: no hint.
+ expect(screen.queryByTestId('profile-language-app-content-default')).not.toBeInTheDocument();
+ await pick(select, 'Use the deployment default');
+ expect(screen.queryByTestId('profile-language-app-content-default')).not.toBeInTheDocument();
+
+ // 日本語 is offered (every table language is) but the app ships no `ja`.
+ await pick(select, '日本語');
+ expect(screen.getByTestId('profile-language-app-content-default')).toHaveTextContent(
+ 'App content shows in the default language',
+ );
+ });
+
+ it('marks nothing while the app list is not known', async () => {
+ offerable.value = ['en', 'zh-Hans', 'ja'];
+ findOne.mockResolvedValue({ id: 'usr_1', locale: 'ja' });
+ await renderProfile();
+
+ expect(screen.queryByTestId('profile-language-app-content-default')).not.toBeInTheDocument();
+ });
+
+ it('does not mark a stored tag outside the table', async () => {
+ appContent.value = ['en'];
+ offerable.value = ['en', 'zh-Hans'];
+ findOne.mockResolvedValue({ id: 'usr_1', locale: 'th' });
+ await renderProfile();
+
+ expect(screen.queryByTestId('profile-language-app-content-default')).not.toBeInTheDocument();
+ });
});
diff --git a/ui/apps/console/src/pages/system/__tests__/ProfilePage.pageHeader-12553.test.tsx b/ui/apps/console/src/pages/system/__tests__/ProfilePage.pageHeader-12553.test.tsx
index 3c9f8e53157..af5fe1fea76 100644
--- a/ui/apps/console/src/pages/system/__tests__/ProfilePage.pageHeader-12553.test.tsx
+++ b/ui/apps/console/src/pages/system/__tests__/ProfilePage.pageHeader-12553.test.tsx
@@ -49,7 +49,7 @@ vi.mock('@object-ui/fields', async (importOriginal) => ({
/** Each call site's key, so the pin names the pack key it reads. */
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal>()),
- useObjectTranslation: () => ({ t: (key: string) => `«${key}»`, offerableLanguages: ['en'] }),
+ useObjectTranslation: () => ({ t: (key: string) => `«${key}»`, offerableLanguages: ['en'], appContentLanguages: null }),
}));
vi.mock('@object-ui/react', async (importOriginal) => ({
diff --git a/ui/apps/console/src/pages/system/__tests__/ProfilePage.sharedSelect-11865.test.tsx b/ui/apps/console/src/pages/system/__tests__/ProfilePage.sharedSelect-11865.test.tsx
index 9e53b8be751..f27e4760668 100644
--- a/ui/apps/console/src/pages/system/__tests__/ProfilePage.sharedSelect-11865.test.tsx
+++ b/ui/apps/console/src/pages/system/__tests__/ProfilePage.sharedSelect-11865.test.tsx
@@ -66,6 +66,7 @@ vi.mock('@object-ui/i18n', async (importOriginal) => ({
useObjectTranslation: () => ({
t: (key: string, options?: Record) => String(options?.defaultValue ?? key),
offerableLanguages: offerable.value,
+ appContentLanguages: null,
}),
}));
diff --git a/ui/packages/app-shell/src/layout/LocaleSwitcher.tsx b/ui/packages/app-shell/src/layout/LocaleSwitcher.tsx
index f4ae5f0c643..d933f849f3f 100644
--- a/ui/packages/app-shell/src/layout/LocaleSwitcher.tsx
+++ b/ui/packages/app-shell/src/layout/LocaleSwitcher.tsx
@@ -5,8 +5,14 @@
* Uses the i18n context to change language at runtime.
*
* The menu is not a list of its own (objectui#4039): it renders whatever the
- * i18n provider says is offerable — the platform locale table ∩ the app's own
- * locale list, as table tags (objectstack#30514). This file owns only the *labels*, because the native
+ * i18n provider says is offerable — every language of the platform locale
+ * table, as table tags, on the sign-in page and in the app alike
+ * (objectstack#35425, which reversed the narrowing to the app's own locale
+ * list). A language the app's own content is not translated into stays
+ * selectable and carries one muted line saying that content shows in the
+ * default language; the provider's `appContentLanguages` says which those are,
+ * and a page that does not know (signed out) marks none. This file owns the
+ * *labels* and that hint, because the native
* names are the one piece of that no API response supplies:
* `GET /api/v1/i18n/locales` returns descriptors whose `label` is the code
* echoed back (`toLocaleDescriptors` in @objectstack/spec), so a server label
@@ -76,19 +82,12 @@ export function localeLabel(code: string): string {
}
export function LocaleSwitcher() {
- const { t, language, offerableLanguages } = useObjectTranslation();
+ const { t, language, offerableLanguages, appContentLanguages } = useObjectTranslation();
// ⛔ Not the i18n context's bare `changeLanguage`: while signed in the switch
// has to reach `sys_user.locale`, or the globe and the profile page go on
// naming two settings (objectui#10059). Signed out it IS the bare switch.
const selectLanguage = useLanguageSelection();
- // Still asking the app which locales it ships. Render nothing rather than a
- // fallback list that would be replaced a tick later — the same idiom the
- // sibling menus in this folder use for data they do not have yet
- // (`AppSwitcher`, `WorkspaceSwitcher`), and it keeps the ten from flashing
- // past on an app that only ships two.
- if (offerableLanguages === null) return null;
-
// The entries are table tags (`zh-Hans`); the session may be running in a
// stored spelling of one (`zh-CN`). Compare through the same resolution the
// provider builds the entries with, so that session ticks 简体中文.
@@ -113,18 +112,39 @@ export function LocaleSwitcher() {
{t('console.localeSwitcher.label')}
- {/* 44 px rows below `md`, as the top bar's menus (objectstack#29075). */}
-
- {offerableLanguages.map((code) => (
- pick(code)}
- className="gap-2"
- >
- {localeLabel(code)}
- {current === code && ✓}
-
- ))}
+ {/* 44 px rows below `md`, as the top bar's menus (objectstack#29075). The
+ width is bounded so a long hint (de, ru) wraps instead of widening the
+ menu past a phone screen. */}
+
+ {offerableLanguages.map((code) => {
+ // Marked only when the app's list is known and leaves this language
+ // out; "not known" marks nothing rather than every row.
+ const appContentInDefault =
+ appContentLanguages !== null && !appContentLanguages.includes(code);
+ return (
+ pick(code)}
+ className="gap-2"
+ >
+
+ {localeLabel(code)}
+ {appContentInDefault && (
+
+ {t('console.localeSwitcher.appContentDefault')}
+
+ )}
+
+ {current === code && ✓}
+
+ );
+ })}
);
diff --git a/ui/packages/app-shell/src/layout/__tests__/LocaleSwitcher.appLocales.test.tsx b/ui/packages/app-shell/src/layout/__tests__/LocaleSwitcher.appLocales.test.tsx
index c67aa4b446d..33422f412bd 100644
--- a/ui/packages/app-shell/src/layout/__tests__/LocaleSwitcher.appLocales.test.tsx
+++ b/ui/packages/app-shell/src/layout/__tests__/LocaleSwitcher.appLocales.test.tsx
@@ -1,23 +1,18 @@
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
/**
- * LocaleSwitcher — the menu is the app's locale list, not a constant
- * (objectui#4039, migrated from objectstack#5418).
+ * LocaleSwitcher — one language list on the sign-in page and in the app
+ * (objectstack#35425, maintainer ruling option A).
*
- * The switcher used to build its items from a module-level `LANGUAGES` array:
- * exactly the ten codes `@object-ui/i18n` ships packs for, never asking the app
- * which locales it actually has. That failed in both directions at once —
- * an app shipping `th` could not offer it from the console at all, and an app
- * shipping only `en`+`zh` still listed all ten, so picking 日本語 handed the
- * user a half-translated UI its author never opted into.
- *
- * The ruling on the card is INTERSECTION, narrowed by ruling F of
- * objectstack#29349 (objectstack#30514): (the platform locale table) ∩ (the
- * app's `/api/v1/i18n/locales` response, read through the table's read
- * aliases). Each entry is a table tag with the table's own label, two
- * spellings of one language are one entry, and a code the table does not
- * name (`th`) is not offered. The table's tags survive alone as the
- * offline/no-backend fallback.
+ * The menu used to be (the platform locale table) ∩ (the app's
+ * `/api/v1/i18n/locales` answer), per ruling F of objectstack#29349
+ * (objectstack#30514). The sign-in page has no session to ask the app with,
+ * so it listed the whole table, and a language picked there (German, Korean)
+ * was missing from the menu after sign-in. Now both list every table
+ * language. The app's own list decides only which rows carry the hint that
+ * the app's content shows in the default language. Each entry is a table
+ * tag with the table's own label, and a code the table does not name (`th`)
+ * is still not offered.
*/
import '@testing-library/jest-dom/vitest';
@@ -33,7 +28,7 @@ vi.mock('@object-ui/components', async (importOriginal) => ({
DropdownMenu: (p: any) => {p.children}
,
DropdownMenuTrigger: (p: any) => {p.children}
,
DropdownMenuContent: (p: any) => {p.children}
,
- DropdownMenuItem: ({ onClick, children }: any) => {children}
,
+ DropdownMenuItem: ({ onClick, children }: any) => {children}
,
}));
vi.mock('lucide-react', async (importOriginal) => ({
...(await importOriginal>()),
@@ -44,11 +39,10 @@ import { PLATFORM_LOCALES, PLATFORM_LOCALE_TAGS } from '@objectstack/spec/system
import { LocaleSwitcher, localeLabel } from '../LocaleSwitcher';
/**
- * The eight built-in native names an app shipping only `en`+`zh-Hans` must NOT
- * show: every platform locale table language but English and Chinese, named as
- * the menu names them (from the table's own labels).
+ * Every platform locale table language but English and Chinese, named as the
+ * menu names them (from the table's own labels).
*/
-const PHANTOM_LABELS = PLATFORM_LOCALE_TAGS
+const NOT_EN_OR_ZH_LABELS = PLATFORM_LOCALE_TAGS
.filter((tag) => tag !== 'en' && !tag.startsWith('zh-'))
.map(localeLabel);
@@ -76,15 +70,94 @@ beforeEach(() => {
window.localStorage.clear();
});
-describe('LocaleSwitcher — menu composed from the app locale list', () => {
+/** The hint a row carries when the app's content is not translated into it. */
+const HINT = 'App content shows in the default language';
+
+/** The menu row (the item) a language label sits in. */
+function rowOf(label: string): HTMLElement {
+ const item = screen.getByText(label).closest('[data-row]');
+ if (!(item instanceof HTMLElement)) throw new Error(`no menu row for ${label}`);
+ return item;
+}
+
+describe('LocaleSwitcher — every table language, the app list marks the hint', () => {
+ it('lists all eleven table languages for an app that ships four', async () => {
+ mountConsole({ locales: async () => ['en', 'zh-CN', 'ja-JP', 'es-ES'] });
+
+ // HotCRM's declaration. Before objectstack#35425 the menu stopped at
+ // these four; the sign-in page listed eleven.
+ await waitFor(() => expect(screen.getAllByText(HINT)).toHaveLength(7));
+ for (const label of BUILT_IN_PACK_LABELS) expect(screen.getAllByText(label)).toHaveLength(1);
+ });
+
+ it('marks exactly the languages the app ships no translation for', async () => {
+ mountConsole({ locales: async () => ['en', 'zh-CN', 'ja-JP', 'es-ES'] });
+
+ await waitFor(() => expect(screen.getAllByText(HINT)).toHaveLength(7));
+ for (const shipped of ['English', '简体中文', '日本語', 'Español']) {
+ expect(rowOf(shipped).textContent, shipped).not.toContain(HINT);
+ }
+ for (const label of NOT_EN_OR_ZH_LABELS.filter((l) => !['日本語', 'Español'].includes(l))) {
+ expect(rowOf(label).textContent, label).toContain(HINT);
+ }
+ });
+
+ it('keeps a language picked on the sign-in page selectable and ticked after sign-in', async () => {
+ // Picked signed out (no app list), then the signed-in page load asks the
+ // app, which does not ship German.
+ window.localStorage.setItem(LOCALE_STORAGE_KEY, 'de');
+ mountConsole({ locales: async () => ['en', 'zh-CN'] });
+
+ // The hint reads in the interface language: German here.
+ await waitFor(() =>
+ expect(rowOf('Deutsch').textContent).toContain('App-Inhalte erscheinen in der Standardsprache'),
+ );
+ expect(rowOf('Deutsch').textContent).toContain('✓');
+ expect(window.localStorage.getItem(LOCALE_STORAGE_KEY)).toBe('de');
+ });
+
+ it('marks nothing while the app list is not known: signed out, in flight, failed or empty', async () => {
+ let answer: (codes: string[]) => void = () => {};
+ const pending = new Promise((resolve) => { answer = resolve; });
+ mountConsole({ locales: () => pending });
+
+ // In flight: the whole list at once (nothing to wait for), no hint yet.
+ for (const label of BUILT_IN_PACK_LABELS) expect(screen.getByText(label)).toBeInTheDocument();
+ expect(screen.queryByText(HINT)).not.toBeInTheDocument();
+
+ // Signed out, the console's loader answers `[]` without a request.
+ answer([]);
+ await Promise.resolve();
+ expect(screen.queryByText(HINT)).not.toBeInTheDocument();
+ for (const label of BUILT_IN_PACK_LABELS) expect(screen.getByText(label)).toBeInTheDocument();
+ });
+
+ it('marks nothing when the endpoint fails', async () => {
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
+ mountConsole({ locales: async () => { throw new Error('ECONNREFUSED'); } });
+
+ await waitFor(() => expect(warn).toHaveBeenCalled());
+ for (const label of BUILT_IN_PACK_LABELS) expect(screen.getByText(label)).toBeInTheDocument();
+ expect(screen.queryByText(HINT)).not.toBeInTheDocument();
+ warn.mockRestore();
+ });
+
+ it('marks nothing for an app answer that names no table language', async () => {
+ mountConsole({ locales: async () => ['th'] });
+
+ // "I don't know", as an empty answer: a hint on all eleven would claim
+ // the app is translated into none of them.
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ expect(screen.queryByText(HINT)).not.toBeInTheDocument();
+ expect(screen.queryByText('ไทย')).not.toBeInTheDocument();
+ });
+
it('does not offer an app locale the platform locale table does not name', async () => {
mountConsole({ locales: async () => ['en', 'zh-Hans', 'th'] });
// `th` has no Console pack, no Studio catalogue, no platform bundle and no
- // built-in email: offering it would offer an incomplete language, which
- // ruling F rules out. The app's other entries stay.
- await waitFor(() => expect(screen.getByText('English')).toBeInTheDocument());
- expect(screen.getByText('简体中文')).toBeInTheDocument();
+ // built-in email: offering it would offer an incomplete language.
+ await waitFor(() => expect(screen.getAllByText(HINT)).toHaveLength(9));
expect(screen.queryByText('ไทย')).not.toBeInTheDocument();
});
@@ -95,33 +168,20 @@ describe('LocaleSwitcher — menu composed from the app locale list', () => {
loader: false,
});
- await waitFor(() => expect(screen.getByText('English')).toBeInTheDocument());
+ await waitFor(() => expect(screen.getAllByText(HINT)).toHaveLength(10));
expect(screen.queryByText('ไทย')).not.toBeInTheDocument();
});
- it.each([
- ['app-crm / app-showcase', ['en', 'zh-CN'], ['English', '简体中文']],
- ['app-todo', ['en', 'zh-CN', 'ja-JP'], ['English', '简体中文', '日本語']],
- ['HotCRM sales', ['en', 'zh-CN', 'ja-JP', 'es-ES'], ['English', '简体中文', '日本語', 'Español']],
- ])('reads a %s declaration in stored spellings as table entries, with table labels', async (_app, declared, labels) => {
- mountConsole({ locales: async () => declared });
-
- await waitFor(() => expect(screen.getByText('English')).toBeInTheDocument());
- // Each table row once, never the CLDR name of the stored spelling
- // (中文(中国), 日本語 (日本), Español de España).
- for (const label of labels) expect(screen.getAllByText(label)).toHaveLength(1);
- expect(screen.queryByText('中文(中国)')).not.toBeInTheDocument();
- expect(screen.queryByText('日本語 (日本)')).not.toBeInTheDocument();
- expect(screen.queryByText('Español de España')).not.toBeInTheDocument();
- });
-
- it('lists a stored spelling beside its own table tag as ONE entry', async () => {
- mountConsole({ locales: async () => ['en', 'zh-CN', 'zh-Hans'] });
+ it('reads stored spellings as table entries: one row each, table labels, not marked', async () => {
+ mountConsole({ locales: async () => ['en', 'zh-CN', 'zh-Hans', 'ja-JP'] });
- await waitFor(() => expect(screen.getByText('English')).toBeInTheDocument());
- // One pack, one entry.
- expect(screen.getAllByText('简体中文')).toHaveLength(1);
+ await waitFor(() => expect(screen.getAllByText(HINT)).toHaveLength(8));
+ for (const label of ['English', '简体中文', '日本語']) {
+ expect(screen.getAllByText(label)).toHaveLength(1);
+ expect(rowOf(label).textContent, label).not.toContain(HINT);
+ }
expect(screen.queryByText('中文(中国)')).not.toBeInTheDocument();
+ expect(screen.queryByText('日本語 (日本)')).not.toBeInTheDocument();
});
it('ticks the table entry for a session running in a stored spelling', async () => {
@@ -130,47 +190,8 @@ describe('LocaleSwitcher — menu composed from the app locale list', () => {
mountConsole({ locales: async () => ['en', 'zh-CN'] });
await waitFor(() => expect(screen.getByText('简体中文')).toBeInTheDocument());
- expect(screen.getByText('简体中文').textContent).toContain('✓');
- expect(screen.getByText('English').textContent).not.toContain('✓');
- });
-
- it('names a regional app locale, capitalized like the built-in labels', async () => {
- mountConsole({ locales: async () => ['en', 'pt-BR'] });
-
- // The exact CLDR string moves with ICU versions; what this pins is that a
- // regional tag gets a real display name (not the bare code) and that it
- // does not arrive lowercase next to `English`.
- await waitFor(() => expect(screen.queryByText('English')).toBeInTheDocument());
- const item = screen.getByText((text) => text.startsWith('Portugu'));
- expect(item.textContent).not.toBe('pt-BR');
- });
-
- it('shows ONLY what the app ships — the phantom eight are gone', async () => {
- mountConsole({ locales: async () => ['en', 'zh-Hans'] });
-
- await waitFor(() => expect(screen.getByText('English')).toBeInTheDocument());
- expect(screen.getByText('简体中文')).toBeInTheDocument();
- for (const phantom of PHANTOM_LABELS) {
- expect(screen.queryByText(phantom)).not.toBeInTheDocument();
- }
- });
-
- it('falls back to the built-in packs when the endpoint fails', async () => {
- mountConsole({ locales: async () => { throw new Error('ECONNREFUSED'); } });
-
- // No backend is not "this app ships nothing" — the switcher must stay
- // usable, offering everything this renderer can produce on its own.
- await waitFor(() => expect(screen.getByText('English')).toBeInTheDocument());
- for (const label of BUILT_IN_PACK_LABELS) {
- expect(screen.getByText(label)).toBeInTheDocument();
- }
- });
-
- it('falls back to the built-in packs when the app answers with nothing usable', async () => {
- mountConsole({ locales: async () => [] });
-
- await waitFor(() => expect(screen.getByText('English')).toBeInTheDocument());
- expect(screen.getByText('日本語')).toBeInTheDocument();
+ expect(rowOf('简体中文').textContent).toContain('✓');
+ expect(rowOf('English').textContent).not.toContain('✓');
});
it('keeps the built-in native names rather than re-deriving them', async () => {
@@ -183,36 +204,17 @@ describe('LocaleSwitcher — menu composed from the app locale list', () => {
expect(screen.getByText('Русский')).toBeInTheDocument();
});
- it('renders nothing until the app has answered — no flash of the fallback ten', async () => {
- let answer: (codes: string[]) => void = () => {};
- const pending = new Promise((resolve) => { answer = resolve; });
- const { container } = mountConsole({ locales: () => pending });
-
- // In flight: not the ten, not two, nothing at all. The sibling menus in
- // this folder (AppSwitcher, WorkspaceSwitcher) do the same with data they
- // do not have yet.
- expect(container.firstChild).toBeNull();
- expect(screen.queryByText('English')).not.toBeInTheDocument();
-
- answer(['en', 'zh-Hans']);
-
- await waitFor(() => expect(screen.getByText('English')).toBeInTheDocument());
- expect(screen.queryByText('日本語')).not.toBeInTheDocument();
- });
-
- it('offers the built-in packs when no locale endpoint is wired at all', async () => {
+ it('offers the table languages, unmarked, when no locale endpoint is wired at all', () => {
render(
,
);
- // An app that never wires `loadLocales` keeps exactly today's menu, with
- // no blank frame in front of it.
- expect(screen.getByText('English')).toBeInTheDocument();
for (const label of BUILT_IN_PACK_LABELS) {
expect(screen.getByText(label)).toBeInTheDocument();
}
+ expect(screen.queryByText(HINT)).not.toBeInTheDocument();
});
});
diff --git a/ui/packages/i18n/src/__tests__/provider-app-locale-restore.test.tsx b/ui/packages/i18n/src/__tests__/provider-app-locale-restore.test.tsx
index 08195b1660a..27c86a08914 100644
--- a/ui/packages/i18n/src/__tests__/provider-app-locale-restore.test.tsx
+++ b/ui/packages/i18n/src/__tests__/provider-app-locale-restore.test.tsx
@@ -20,6 +20,12 @@
* platform locale table's languages, so an out-of-table app locale like `th`
* is no longer offered: it still boots on the loader's credit, and the
* self-heal then reverts and purges it once the app's list lands.
+ *
+ * objectstack#35425 (maintainer ruling option A) widened the menu back to
+ * every table language whatever the app ships, so the sign-in page and the
+ * in-app menu offer one list. The app's list now feeds `appContentLanguages`,
+ * the languages a menu does NOT mark as "app content shows in the default
+ * language".
*/
import { describe, it, expect, beforeEach } from 'vitest';
import { renderHook, act, waitFor } from '@testing-library/react';
@@ -59,7 +65,8 @@ describe('app-locale restore (lockstep with the switcher)', () => {
const { result } = mountConsole();
expect(result.current.language).toBe('th');
- await waitFor(() => expect(result.current.offerableLanguages).toEqual(['en', 'zh-Hans']));
+ await waitFor(() => expect(result.current.appContentLanguages).toEqual(['en', 'zh-Hans']));
+ expect(result.current.offerableLanguages).not.toContain('th');
await waitFor(() => expect(result.current.language).toBe('en'));
expect(window.localStorage.getItem(LOCALE_STORAGE_KEY)).toBeNull();
});
@@ -69,11 +76,25 @@ describe('app-locale restore (lockstep with the switcher)', () => {
const { result } = mountConsole({}, ['en', 'zh-CN']);
- await waitFor(() => expect(result.current.offerableLanguages).toEqual(['en', 'zh-Hans']));
+ await waitFor(() => expect(result.current.appContentLanguages).toEqual(['en', 'zh-Hans']));
expect(result.current.language).toBe('zh-CN');
expect(window.localStorage.getItem(LOCALE_STORAGE_KEY)).toBe('zh-CN');
});
+ it('keeps a stored table language the app ships no translation for (objectstack#35425)', async () => {
+ // Picked on the sign-in page, where no app list is read; the signed-in
+ // page load then learns the app ships only `en` + `zh-CN`. The pick
+ // stands: the interface renders in German, the app content in the default.
+ window.localStorage.setItem(LOCALE_STORAGE_KEY, 'de');
+
+ const { result } = mountConsole({}, ['en', 'zh-CN']);
+
+ await waitFor(() => expect(result.current.appContentLanguages).toEqual(['en', 'zh-Hans']));
+ expect(result.current.offerableLanguages).toContain('de');
+ expect(result.current.language).toBe('de');
+ expect(window.localStorage.getItem(LOCALE_STORAGE_KEY)).toBe('de');
+ });
+
it('restores it in the BOOTSTRAP language, not as a late correction', () => {
window.localStorage.setItem(LOCALE_STORAGE_KEY, 'th');
@@ -168,35 +189,83 @@ describe('app-locale restore (lockstep with the switcher)', () => {
});
});
-describe('offerableLanguages — the intersection the switcher renders', () => {
- it('is the platform locale table ∩ the app list, as table tags in the app order', async () => {
+describe('offerableLanguages — every table language, whatever the app ships', () => {
+ it('is the platform locale table for an app that ships four (objectstack#35425)', async () => {
+ const { result } = mountConsole({}, ['en', 'zh-CN', 'ja-JP', 'es-ES']);
+
+ await waitFor(() => expect(result.current.appContentLanguages).not.toBeNull());
+ expect(result.current.offerableLanguages).toEqual(PLATFORM_LOCALE_TAGS);
+ });
+
+ it('is the table while the app list is in flight, with nothing to wait for', () => {
+ const { result } = mountConsole({ loadLocales: () => new Promise(() => {}) });
+
+ expect(result.current.offerableLanguages).toEqual(PLATFORM_LOCALE_TAGS);
+ });
+
+ it('is the table when no locale list is wired (control)', () => {
+ const { result } = mountConsole({}, null);
+
+ expect(result.current.offerableLanguages).toEqual(PLATFORM_LOCALE_TAGS);
+ });
+});
+
+describe('appContentLanguages — the table languages the app list covers', () => {
+ it('is the table ∩ the app list, as table tags in the app order', async () => {
// `zh` and `zh-CN` are two spellings of `zh-Hans`: one entry. `th` lands
- // on no table tag: not offered, although the loader could fetch it.
+ // on no table tag: not a menu language, so not in this list either.
const { result } = mountConsole({}, ['ja-JP', 'en', 'zh', 'zh-CN', 'th']);
- await waitFor(() => expect(result.current.offerableLanguages).toEqual(['ja', 'en', 'zh-Hans']));
+ await waitFor(() => expect(result.current.appContentLanguages).toEqual(['ja', 'en', 'zh-Hans']));
});
it('reads region variants through the table, as the pack that serves them', async () => {
const { result } = mountConsole({}, ['de-AT', 'zh-TW', 'en-GB']);
- await waitFor(() => expect(result.current.offerableLanguages).toEqual(['de', 'zh-Hant', 'en']));
+ await waitFor(() => expect(result.current.appContentLanguages).toEqual(['de', 'zh-Hant', 'en']));
});
- it('falls back to the table when the app lists no table language', async () => {
- const { result } = mountConsole({}, ['th']);
+ it('is null ("not known") when the app lists no table language', async () => {
+ const calls = { n: 0 };
+ const { result } = mountConsole({
+ loadLocales: async () => {
+ calls.n += 1;
+ return ['th'];
+ },
+ });
- await waitFor(() => expect(result.current.offerableLanguages).not.toBeNull());
- expect(result.current.offerableLanguages).toEqual(PLATFORM_LOCALE_TAGS);
+ await waitFor(() => expect(calls.n).toBe(1));
+ await act(async () => {});
+ expect(result.current.appContentLanguages).toBeNull();
+ });
+
+ it('is null when the app answers with nothing (signed out, failed read)', async () => {
+ const calls = { n: 0 };
+ const { result } = mountConsole({
+ loadLocales: async () => {
+ calls.n += 1;
+ return [];
+ },
+ });
+
+ await waitFor(() => expect(calls.n).toBe(1));
+ await act(async () => {});
+ expect(result.current.appContentLanguages).toBeNull();
+ });
+
+ it('is null while the app list is in flight', () => {
+ const { result } = mountConsole({ loadLocales: () => new Promise(() => {}) });
+
+ expect(result.current.appContentLanguages).toBeNull();
});
- it('offers the table tags when no locale list is wired (control)', () => {
+ it('is null when no locale list is wired (control)', () => {
const { result } = mountConsole({}, null);
- expect(result.current.offerableLanguages).toEqual(PLATFORM_LOCALE_TAGS);
+ expect(result.current.appContentLanguages).toBeNull();
});
- it('drops an app locale this renderer cannot produce', async () => {
+ it('drops an app locale outside the table even with no loader', async () => {
const wrapper = ({ children }: { children: React.ReactNode }) =>
React.createElement(I18nProvider, {
config: { defaultLanguage: 'en', detectBrowserLanguage: false },
@@ -205,15 +274,7 @@ describe('offerableLanguages — the intersection the switcher renders', () => {
});
const { result } = renderHook(() => useObjectTranslation(), { wrapper });
- // No loader and no `config.resources`: `th` is in the app's list but this
- // renderer has no way to produce a single string of it.
- await waitFor(() => expect(result.current.offerableLanguages).toEqual(['en', 'zh-Hans']));
- });
-
- it('is null while the app list is in flight', () => {
- const { result } = mountConsole({ loadLocales: () => new Promise(() => {}) });
-
- expect(result.current.offerableLanguages).toBeNull();
+ await waitFor(() => expect(result.current.appContentLanguages).toEqual(['en', 'zh-Hans']));
});
it('asks the app exactly once, under StrictMode and re-renders alike', async () => {
@@ -238,7 +299,7 @@ describe('offerableLanguages — the intersection the switcher renders', () => {
);
const { result, rerender } = renderHook(() => useObjectTranslation(), { wrapper });
- await waitFor(() => expect(result.current.offerableLanguages).toEqual(['en', 'zh-Hans']));
+ await waitFor(() => expect(result.current.appContentLanguages).toEqual(['en', 'zh-Hans']));
rerender();
rerender();
expect(calls.n).toBe(1);
diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts
index 70a4c7e894a..ebe56058cf2 100644
--- a/ui/packages/i18n/src/locales/ar.ts
+++ b/ui/packages/i18n/src/locales/ar.ts
@@ -3074,6 +3074,7 @@ const ar = {
},
localeSwitcher: {
label: "اللغة",
+ appContentDefault: "يظهر محتوى التطبيق باللغة الافتراضية",
},
system: {
aiApprovals: {
diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts
index 81b8f851b37..22cfe0d42de 100644
--- a/ui/packages/i18n/src/locales/de.ts
+++ b/ui/packages/i18n/src/locales/de.ts
@@ -2771,6 +2771,7 @@ const de = {
},
localeSwitcher: {
label: "Sprache",
+ appContentDefault: "App-Inhalte erscheinen in der Standardsprache",
},
system: {
aiApprovals: {
diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts
index 1a63ec0f0f7..132f593f95c 100644
--- a/ui/packages/i18n/src/locales/en.ts
+++ b/ui/packages/i18n/src/locales/en.ts
@@ -3378,6 +3378,7 @@ const en = {
},
localeSwitcher: {
label: 'Language',
+ appContentDefault: 'App content shows in the default language',
},
system: {
aiApprovals: {
diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts
index 71762c6c7df..bd3809a3358 100644
--- a/ui/packages/i18n/src/locales/es.ts
+++ b/ui/packages/i18n/src/locales/es.ts
@@ -2848,6 +2848,7 @@ const es = {
},
localeSwitcher: {
label: "Idioma",
+ appContentDefault: "El contenido de la app se muestra en el idioma predeterminado",
},
system: {
aiApprovals: {
diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts
index fde7dfa7138..72b424f3066 100644
--- a/ui/packages/i18n/src/locales/fr.ts
+++ b/ui/packages/i18n/src/locales/fr.ts
@@ -2844,6 +2844,7 @@ const fr = {
},
localeSwitcher: {
label: "Langue",
+ appContentDefault: "Le contenu de l'app s'affiche dans la langue par défaut",
},
system: {
aiApprovals: {
diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts
index 75dc47b0292..d7dce14b25e 100644
--- a/ui/packages/i18n/src/locales/ja.ts
+++ b/ui/packages/i18n/src/locales/ja.ts
@@ -2773,6 +2773,7 @@ const ja = {
},
localeSwitcher: {
label: "言語",
+ appContentDefault: "アプリの内容は既定の言語で表示されます",
},
system: {
aiApprovals: {
diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts
index 5a8ad411f98..456fd7ab02d 100644
--- a/ui/packages/i18n/src/locales/ko.ts
+++ b/ui/packages/i18n/src/locales/ko.ts
@@ -2771,6 +2771,7 @@ const ko = {
},
localeSwitcher: {
label: "언어",
+ appContentDefault: "앱 콘텐츠는 기본 언어로 표시됩니다",
},
system: {
aiApprovals: {
diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts
index 3ec8dd1bd9f..b55defefbb5 100644
--- a/ui/packages/i18n/src/locales/pt-BR.ts
+++ b/ui/packages/i18n/src/locales/pt-BR.ts
@@ -2843,6 +2843,7 @@ const pt = {
},
localeSwitcher: {
label: "Idioma",
+ appContentDefault: "O conteúdo do app aparece no idioma padrão",
},
system: {
aiApprovals: {
diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts
index 82b51bd8d2a..e19d71ce020 100644
--- a/ui/packages/i18n/src/locales/ru.ts
+++ b/ui/packages/i18n/src/locales/ru.ts
@@ -2930,6 +2930,7 @@ const ru = {
},
localeSwitcher: {
label: "Язык",
+ appContentDefault: "Содержимое приложения показывается на языке по умолчанию",
},
system: {
aiApprovals: {
diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts
index 9d781b40d28..7901d32de2b 100644
--- a/ui/packages/i18n/src/locales/zh-Hans.ts
+++ b/ui/packages/i18n/src/locales/zh-Hans.ts
@@ -2874,6 +2874,7 @@ const zh = {
},
localeSwitcher: {
label: '语言',
+ appContentDefault: '应用内容显示为默认语言',
},
system: {
aiApprovals: {
diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts
index 482bc439061..954bb719563 100644
--- a/ui/packages/i18n/src/locales/zh-Hant.ts
+++ b/ui/packages/i18n/src/locales/zh-Hant.ts
@@ -2874,6 +2874,7 @@ const zhHant = {
},
localeSwitcher: {
label: '語言',
+ appContentDefault: '應用內容顯示為預設語言',
},
system: {
aiApprovals: {
diff --git a/ui/packages/i18n/src/provider.tsx b/ui/packages/i18n/src/provider.tsx
index c7299ca5eca..5173012c6f3 100644
--- a/ui/packages/i18n/src/provider.tsx
+++ b/ui/packages/i18n/src/provider.tsx
@@ -486,19 +486,32 @@ interface I18nContextValue {
/** The underlying i18next instance */
i18n: I18nInstance;
/**
- * The languages a switcher may offer: the platform locale table ∩ the
- * app's own locale list (objectui#4039, ruling F of objectstack#29349), as
- * table tags (`zh-Hans`, never `zh-CN`), de-duplicated, in the app's order.
- * A code that lands on no table tag is not offered. Computed here because
- * only the provider knows both sides.
+ * The languages a switcher may offer: every language of the platform locale
+ * table, as table tags (`zh-Hans`, never `zh-CN`), in the table's order.
*
- * `null` means "still asking the app". Consumers render nothing (or a
- * skeleton) rather than a list they will have to retract a tick later.
- * Without {@link I18nProviderProps.loadLocales} wiring, or when the app's
- * answer names no table language, this is the offline fallback: the table's
- * tags.
+ * The sign-in page, the in-app menu and the profile page's language card all
+ * offer this one list (maintainer ruling on objectstack#35425, option A). It
+ * is no longer narrowed to the app's own locale list: a language the app
+ * ships no translation for is still selectable — the interface renders in
+ * it, the app's own content falls back to the deployment's default language
+ * — and {@link I18nContextValue.appContentLanguages} says which those are.
+ * Never `null`: the list does not wait on the app's answer any more.
*/
- offerableLanguages: readonly string[] | null;
+ offerableLanguages: readonly string[];
+ /**
+ * The table languages the app's own locale list covers (objectui#4039), as
+ * table tags, de-duplicated, in the app's order: the languages in which the
+ * app's content (object, field and view labels) is translated too. A menu
+ * marks every other offered language with a hint that the app's content
+ * shows in the default language (objectstack#35425).
+ *
+ * `null` means "not known": still asking, no
+ * {@link I18nProviderProps.loadLocales} wiring, a signed-out page (the
+ * console asks only with a session), a failed read, or an answer that names
+ * no table language. Mark nothing then: a hint on every row would claim a
+ * fact nobody has read.
+ */
+ appContentLanguages: readonly string[] | null;
}
const ObjectI18nContext = createContext(null);
@@ -806,31 +819,33 @@ export function I18nProvider({
});
}, [loadLocales]);
- const offerableLanguages = useMemo(() => {
- // No wiring at all: the platform locale table is the whole truth. An entry
- // in `config.resources` overlays a table language or names one outside the
- // table, and neither adds a menu entry (see `offeredTableTags`).
- if (!hasLocaleLoader) return BUILT_IN_LANGUAGE_CODES;
- if (appLocales === null) return null;
- const offerable = offeredTableTags(appLocales);
- // An app that answers with no table language leaves the user with no way
- // to switch at all — strictly worse than the offline fallback, so the
- // fallback wins.
- return offerable.length > 0 ? offerable : BUILT_IN_LANGUAGE_CODES;
+ // Every table language, whatever the app ships (objectstack#35425): the
+ // sign-in page and the in-app menu offer one list, so a language picked
+ // before sign-in is still there after it. A stable identity, so a reader
+ // keying an effect on it does not re-run.
+ const offerableLanguages: readonly string[] = BUILT_IN_LANGUAGE_CODES;
+
+ // Which of those the app's own content is translated into. `[]` (asked and
+ // got nothing usable) and an answer naming no table language are both "I
+ // don't know", the same reading the offered list used to give them.
+ const appContentLanguages = useMemo(() => {
+ if (!hasLocaleLoader || !appLocales) return null;
+ const covered = offeredTableTags(appLocales);
+ return covered.length > 0 ? covered : null;
}, [hasLocaleLoader, appLocales]);
// Self-heal: a stored language accepted on the loader's credit alone is
// adjudicated once the app's real list lands — against what the menu
- // OFFERS, not the raw list, so a locale the app lists but the platform
- // locale table does not name (`th`) is reverted and purged like one the app
- // dropped (objectstack#30514). Without this, widening the restore validation
+ // OFFERS (every table language, objectstack#35425), not the raw list, so a
+ // locale the app lists but the platform locale table does not name (`th`) is
+ // reverted and purged (objectstack#30514). Without this, widening the restore validation
// would reintroduce exactly what it was written to stop — one stale entry
// locking the UI to a locale with no translations. Scoped to our own
// optimism: only the bootstrap language, only while the user has not moved
// on, and never on an empty/failed answer.
useEffect(() => {
const provisional = bootstrap.provisional;
- if (!provisional || !appLocales || appLocales.length === 0 || !offerableLanguages) return;
+ if (!provisional || !appLocales || appLocales.length === 0) return;
if (offerableLanguages.includes(provisional)) return;
if ((i18nInstance.language || '') !== provisional) return;
const revertTo = config?.defaultLanguage || config?.fallbackLanguage || 'en';
@@ -895,8 +910,9 @@ export function I18nProvider({
direction,
i18n: i18nInstance,
offerableLanguages,
+ appContentLanguages,
}),
- [language, direction, i18nInstance, loadLanguage, offerableLanguages],
+ [language, direction, i18nInstance, loadLanguage, offerableLanguages, appContentLanguages],
);
return React.createElement(
@@ -994,12 +1010,15 @@ export function useObjectTranslation(ns?: string) {
/** The underlying i18next instance */
i18n,
/**
- * Languages a switcher may offer (objectui#4039). `null` while the app's
- * locale list is in flight. Outside a provider there is nobody to ask, so
- * the built-in packs are the answer — not `null`, which would leave a
- * standalone switcher permanently blank.
+ * Languages a switcher may offer: every platform locale table language
+ * (objectstack#35425), inside a provider or not.
*/
offerableLanguages: context ? context.offerableLanguages : BUILT_IN_LANGUAGE_CODES,
+ /**
+ * The table languages the app's own content is translated into, or `null`
+ * when not known. Outside a provider there is nobody to ask: `null`.
+ */
+ appContentLanguages: context ? context.appContentLanguages : null,
};
}