@@ -83,9 +83,9 @@ import {
8383 LOCALE_STORAGE_KEY ,
8484 readStoredLanguage ,
8585 resolveBootstrapLanguage ,
86- resolveBuiltInLanguage ,
8786 useObjectTranslation ,
8887} from '@object-ui/i18n' ;
88+ import { resolveLocaleAmong } from '@objectstack/spec/system' ;
8989import { useAdapter , useDataInvalidation , extractWriteErrorMessage } from '@object-ui/react' ;
9090import { ObjectStackAdapter } from '@object-ui/data-objectstack' ;
9191import { useAfterFirstPaint } from './sharedUserFeeds.js' ;
@@ -373,24 +373,26 @@ const LOCALE_FIELD = 'locale';
373373 * locales ∩ what this renderer can resolve) — the same list the globe menu and
374374 * the profile card render, deliberately not a second opinion about what ships.
375375 *
376- * The match order is the server 's `resolveLocale` (`packages/core `
377- * `fallbacks/memory-i18n.ts `), the one the platform 's i18n routes already
378- * resolve a requested locale with , so the console and the server agree on
379- * which language a stored tag means:
376+ * The match order IS the platform 's one locale ladder, `resolveLocaleAmong `
377+ * (`@objectstack/spec/system `), which the server 's `resolveLocale` and every
378+ * i18n route run too , so the console and the server agree on which language a
379+ * stored tag means:
380380 *
381381 * 1. exact tag (`pt-BR` → `pt-BR`; a real `pt-BR` still beats `pt`);
382382 * 2. the same tag in any case (`zh-cn` → `zh-CN`) — a row written before the
383383 * server door folded case is served as stored, never migrated;
384- * 3. the first offered code the platform locale table reads as the same
385- * language (`zh-TW` → `zh-Hant`, `zh-HK` → `zh-TW`, `zh` → `zh-CN`,
386- * `pt` → `pt-BR`; objectstack#30511). The table's read aliases are how a
387- * row stored before the table keeps its meaning, and the one step the
388- * server's order lacks: without it a base-language match hands a
389- * Traditional row (`zh-TW`) the first `zh` variant offered, which is the
390- * Simplified pack;
384+ * 3. the same platform locale table language, through the table's read
385+ * aliases (`zh-TW` → `zh-Hant`, `zh-HK` → `zh-TW`, `zh` → `zh-CN`,
386+ * `pt` → `pt-BR`): a row stored before the table keeps its meaning, and a
387+ * Traditional row is never handed the first Simplified variant offered;
391388 * 4. the base language (`zh-CN` → `zh`, `en-GB` → `en`), case-insensitively;
392- * 5. the first offered variant of that base language (`es` → `es-MX`,
393- * `zh-Hans-CN` → `zh-CN`), in the order the list offers them.
389+ * 5. the first offered variant of that base language (`es` → `es-MX`), in
390+ * the order the list offers them — after step 3, so a variant the table
391+ * reads as the language itself (`es-ES`) is taken first.
392+ *
393+ * The table's read aliases name the script-subtag spellings too
394+ * (`zh-Hant-TW`, `zh-Hans-CN`), so step 3 reads them by script; a code the
395+ * table does not name is not guessed at, here as on the server.
394396 *
395397 * A match answers the OFFERED spelling, never the stored one: the list is what
396398 * the provider can switch to.
@@ -404,26 +406,7 @@ export function pickRenderableLocale(
404406 offerable : readonly string [ ] | null ,
405407) : string | null {
406408 if ( ! offerable || offerable . length === 0 ) return null ;
407- // 1. Exact.
408- if ( offerable . includes ( tag ) ) return tag ;
409- // 2. Case-insensitive.
410- const lower = tag . toLowerCase ( ) ;
411- const caseMatch = offerable . find ( ( code ) => code . toLowerCase ( ) === lower ) ;
412- if ( caseMatch ) return caseMatch ;
413- // 3. The same language, as the platform locale table reads both tags.
414- const pack = resolveBuiltInLanguage ( tag ) ;
415- if ( pack !== null ) {
416- const sameLanguage = offerable . find ( ( code ) => resolveBuiltInLanguage ( code ) === pack ) ;
417- if ( sameLanguage ) return sameLanguage ;
418- }
419- // 4. Base language.
420- const base = lower . split ( '-' ) [ 0 ] ;
421- if ( ! base ) return null ;
422- const baseMatch = offerable . find ( ( code ) => code . toLowerCase ( ) === base ) ;
423- if ( baseMatch ) return baseMatch ;
424- // 5. Variant of the base language — first offered wins.
425- const variantMatch = offerable . find ( ( code ) => code . split ( '-' ) [ 0 ] . toLowerCase ( ) === base ) ;
426- return variantMatch ?? null ;
409+ return resolveLocaleAmong ( tag , offerable ) ?? null ;
427410}
428411
429412/**
0 commit comments