Desktop-only notice: "English" is the locale the sentence is translated into, so a caller passing an empty locale no longer gets the English name in an Arabic sentence

This commit is contained in:
Doxa Maps 2026-10-01 12:54:14 +00:00
parent 06a5d188b8
commit a1396fd2c7
2 changed files with 8 additions and 2 deletions

View file

@ -77,6 +77,8 @@ export function checkGating({ metas, leaves, spaSrc, spaLocales, libLocales, loa
if (!/useScreenGate\(config\)/.test(loaderSrc)) errs.push('ProfileLoader no longer applies the phone rule (useScreenGate)')
// (f2) the map's English name only in an English sentence: in any other locale the notice uses the unnamed one
if (!/props\.label && english\.value/.test(noticeSrc || '') || !/messages\.desktopOnlyNoticeUnnamed/.test(noticeSrc || '')) errs.push('LargerScreenNotice puts the English map name into a non-English sentence (it must use desktopOnlyNoticeUnnamed outside English)')
// (f3) and "English" is the locale the words come out in (tStatic's order), not an empty prop read as English
if (!/props\.locale \|\| getRuntimeLocale\(\) \|\| detectLocale\(\)/.test(noticeSrc || '')) errs.push('LargerScreenNotice decides "English" from the locale prop alone: a caller passing \'\' gets an Arabic sentence with the English name')
if (!/hasAttribute\('data-doxa-gallery'\)/.test(gateSrc)) errs.push('the phone rule no longer stays quiet inside the Gallery (data-doxa-gallery)')
// (g) every flagged profile's element actually applies the rule
for (const m of metas) {
@ -177,6 +179,7 @@ if (process.argv.includes('--self-test')) {
['(e) the desktop-only sentence stops naming the map', { ...real, libLocales: { ...real.libLocales, zh: { ...real.libLocales.zh, desktopOnlyNotice: '仅支持桌面端' } } }, 1],
['(e) the unnamed sentence names the map', { ...real, libLocales: { ...real.libLocales, ar: { ...real.libLocales.ar, desktopOnlyNoticeUnnamed: '{label} يعمل على الحاسوب فقط' } } }, 1],
['(f2) the English name goes back into every locale', { ...real, noticeSrc: real.noticeSrc.replace('props.label && english.value', 'props.label') }, 1],
['(f3) an empty-locale caller counts as English (the old logic)', { ...real, noticeSrc: real.noticeSrc.replace('props.locale || getRuntimeLocale() || detectLocale() || \'en\'', 'props.locale || \'en\'') }, 1],
['(f) ProfileLoader stops blocking', { ...real, loaderSrc: real.loaderSrc.replace('v-else-if="blockedOnThisScreen"', 'v-else-if="false"') }, 1],
['(g) a flagged composite drops its own gate', { ...real, mounts: { ...real.mounts, 'dashboard-plus-grid/dashboard-plus-grid': { viaLoader: false, ownGate: false } } }, 1],
]

View file

@ -25,7 +25,7 @@
<script setup>
import { computed } from 'vue'
import { tStatic } from '@map/i18n/index.js'
import { tStatic, getRuntimeLocale, detectLocale } from '@map/i18n/index.js'
const props = defineProps({
mode: { type: String, required: true },
@ -46,7 +46,10 @@ const dismissText = computed(() => T('messages.noticeDismiss', 'Dismiss'))
// put inside an Arabic or Hindi sentence it read "Wall of People Groups يعمل على الحاسوب فقط…". So the named
// sentence is for an English reader (or a label the host localized itself), and every other locale gets the
// same sentence without a name (messages.desktopOnlyNoticeUnnamed): the page around it already names the map.
const english = computed(() => String(props.locale || 'en').split(/[-_]/)[0].toLowerCase() === 'en')
// English is decided by the locale the sentence is ACTUALLY translated into: the same order tStatic resolves
// (the prop when a caller passes one, then the host's runtime locale, then the page's own). A caller that passes
// '' (dashboard-plus-grid reading ?lang= itself) must not count as English while its words come out in Arabic.
const english = computed(() => String(props.locale || getRuntimeLocale() || detectLocale() || 'en').split(/[-_]/)[0].toLowerCase() === 'en')
// Split on the placeholder rather than replacing it, so the name can sit in its own <bdi>: a Latin map
// name inside a right-to-left sentence must not take the sentence's direction.
const blockParts = computed(() => (props.label && english.value