mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Translate the rest of the Context card's facts
Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
4554713f98
commit
4b350cb9ae
22 files changed
+2460
-316
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { distanceKm } from '../data/entityContext.js';
|
||||
import { codeWord, distanceKm } from '../data/entityContext.js';
|
||||
import { msg, t, tn } from '../i18n/index.js';
|
||||
import { createUsgsEarthquakeSource } from '../layers/earthquakes/source.js';
|
||||
import { createCycloneSource } from '../layers/cyclones/source.js';
|
||||
@@ -46,7 +46,17 @@ const perimeters = () =>
|
||||
snapshot('perimeters', () => createWfigsPerimeterSource().getSnapshot());
|
||||
const fires = () => snapshot('fires', () => createFirmsSource().getSnapshot());
|
||||
|
||||
const COMPASS = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
|
||||
// English compass points, which the UI shows through t().
|
||||
const COMPASS = [
|
||||
msg('N'),
|
||||
msg('NE'),
|
||||
msg('E'),
|
||||
msg('SE'),
|
||||
msg('S'),
|
||||
msg('SW'),
|
||||
msg('W'),
|
||||
msg('NW'),
|
||||
];
|
||||
/** The compass point from one spot to another, like "NE". */
|
||||
export function compassPoint(from, to) {
|
||||
const rad = Math.PI / 180;
|
||||
@@ -78,6 +88,16 @@ function perimeterMiddle(row) {
|
||||
return { lat: lat / ring.length, lon: lon / ring.length };
|
||||
}
|
||||
|
||||
/** A storm as "Hurricane Melissa": its class in words when the code has them. */
|
||||
function stormTitle(storm) {
|
||||
const word = codeWord('classification', storm.classification);
|
||||
if (!word)
|
||||
return [storm.classification, storm.name].filter(Boolean).join(' ');
|
||||
return storm.name
|
||||
? t('{kind} {name}', { kind: t(word), name: storm.name })
|
||||
: t(word);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hazards within a radius of a spot, nearest first within each kind:
|
||||
* `[{kind, icon, title, detail, distanceKm, at}]`. Every kind uses the same
|
||||
@@ -121,7 +141,7 @@ export async function hazardsNear(lat, lon, radiusKm = 250) {
|
||||
add({
|
||||
kind: 'storm',
|
||||
icon: 'cyclone',
|
||||
title: [storm.classification, storm.name].filter(Boolean).join(' '),
|
||||
title: stormTitle(storm),
|
||||
detail: storm.windKt ? t('{n} kt winds', { n: storm.windKt }) : '',
|
||||
time: Date.parse(storm.positionAt) || null,
|
||||
at,
|
||||
|
||||
@@ -10,6 +10,69 @@ import {
|
||||
searchEntities,
|
||||
viewSummary,
|
||||
} from '../../data/entityContext.js';
|
||||
import { formatDate, formatNumber, t } from '../../i18n/index.js';
|
||||
|
||||
const FACT_DATE = Object.freeze({
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
timeZone: 'UTC',
|
||||
});
|
||||
|
||||
/**
|
||||
* Words from entityContext (a fact's, an insight's or a warning's `words`) in
|
||||
* the active language, or `fallback` (its English as given) when it has none.
|
||||
* @param {?{text?: string, values?: object, context?: string, fixed?: number, date?: number}} words
|
||||
* @param {string} [fallback]
|
||||
* @returns {string}
|
||||
*/
|
||||
export function sayWords(words, fallback = '') {
|
||||
if (!words) return fallback;
|
||||
if (words.date !== undefined) return formatDate(words.date, FACT_DATE);
|
||||
const digits =
|
||||
words.fixed === undefined
|
||||
? { maximumFractionDigits: 2 }
|
||||
: {
|
||||
minimumFractionDigits: words.fixed,
|
||||
maximumFractionDigits: words.fixed,
|
||||
};
|
||||
const values = {};
|
||||
for (const [name, value] of Object.entries(words.values || {}))
|
||||
values[name] =
|
||||
typeof value === 'number'
|
||||
? formatNumber(value, digits)
|
||||
: value && typeof value === 'object'
|
||||
? sayWords(value)
|
||||
: value;
|
||||
if (words.context) values.context = words.context;
|
||||
return t(words.text, values);
|
||||
}
|
||||
|
||||
/** A fact's or insight's value in the active language. */
|
||||
export const factValue = (fact) => sayWords(fact?.words, fact?.value ?? '');
|
||||
|
||||
/**
|
||||
* A fact's label in the active language. Labels whose plain English means
|
||||
* something else elsewhere in the catalog take a context here.
|
||||
*/
|
||||
export function factLabel(fact) {
|
||||
if (fact?.label === 'Country') return t('Country', { context: 'place' });
|
||||
return t(fact?.label || '', fact?.labelValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* A figure split for a tile, so its number can lead: `{number, unit}` in the
|
||||
* active language. A value that does not start with its number shows whole.
|
||||
*/
|
||||
export function factFigure(fact) {
|
||||
const words = fact?.words;
|
||||
if (words?.text?.startsWith('{n}') && typeof words.values?.n === 'number')
|
||||
return {
|
||||
number: sayWords({ ...words, text: '{n}' }),
|
||||
unit: sayWords({ ...words, values: { ...words.values, n: '' } }).trim(),
|
||||
};
|
||||
return { number: factValue(fact), unit: '' };
|
||||
}
|
||||
|
||||
/** How often an open card re-reads its item, so moving things stay current. */
|
||||
const REFRESH_MS = 2000;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { formatNumber, t } from '../../../i18n/index.js';
|
||||
|
||||
// A height as a filled graph (an aircraft's altitude, the camera's height):
|
||||
// each reading since it opened, left to right. The scale fits the readings (never less than about
|
||||
@@ -36,10 +36,14 @@ watch(
|
||||
);
|
||||
|
||||
const feet = (m) => Math.round((m * 3.28084) / 100) * 100;
|
||||
const number = (value) => value.toLocaleString('en-US');
|
||||
const number = (value) => formatNumber(value, { maximumFractionDigits: 1 });
|
||||
const metric = (m) =>
|
||||
m >= 100_000 ? `${number(Math.round(m / 1000))} km` : m >= 1000 ? `${(m / 1000).toFixed(1)} km` : `${number(Math.round(m))} m`;
|
||||
const shown = (m) => (props.unit === 'metric' ? metric(m) : `${number(feet(m))} ft`);
|
||||
m >= 100_000
|
||||
? t('{n} km', { n: number(Math.round(m / 1000)) })
|
||||
: m >= 1000
|
||||
? t('{n} km', { n: formatNumber(m / 1000, { minimumFractionDigits: 1, maximumFractionDigits: 1 }) })
|
||||
: t('{n} m', { n: number(Math.round(m)) });
|
||||
const shown = (m) => (props.unit === 'metric' ? metric(m) : t('{n} ft', { n: number(feet(m)) }));
|
||||
|
||||
const graph = computed(() => {
|
||||
const list = readings.value;
|
||||
@@ -68,7 +72,7 @@ const graph = computed(() => {
|
||||
const line = points.map(([px, py], index) => `${index ? 'L' : 'M'}${px.toFixed(2)} ${py.toFixed(2)}`).join(' ');
|
||||
const moved = last.m - first.m;
|
||||
const change = props.unit === 'metric' ? (Math.abs(moved) >= Math.max(1, last.m * 0.005) ? moved : 0) : feet(last.m) - feet(first.m);
|
||||
const changeText = props.unit === 'metric' ? metric(Math.abs(moved)) : `${number(Math.abs(change))} ft`;
|
||||
const changeText = props.unit === 'metric' ? metric(Math.abs(moved)) : t('{n} ft', { n: number(Math.abs(change)) });
|
||||
const minutes = Math.floor((last.at - first.at) / 60_000);
|
||||
return {
|
||||
line,
|
||||
@@ -78,7 +82,7 @@ const graph = computed(() => {
|
||||
top: shown(log ? 10 ** top : top),
|
||||
bottom: shown(log ? 10 ** bottom : bottom),
|
||||
trend: change > 0 ? 'up' : change < 0 ? 'down' : 'level',
|
||||
change: change ? `${change > 0 ? '+' : '−'}${changeText}` : t('Level'),
|
||||
change: change ? `${change > 0 ? '+' : '−'}${changeText}` : t('Level', { context: 'altitude' }),
|
||||
since: minutes >= 1 ? t('Last {n} min', { n: minutes }) : props.unit === 'metric' ? t('Just now') : t('Since selected'),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<script setup>
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useEntityCardStore } from '../../stores/entityCard.js';
|
||||
import { formatNumber, t } from '../../../i18n/index.js';
|
||||
import { factFigure, factLabel, factValue, sayWords, useEntityCardStore } from '../../stores/entityCard.js';
|
||||
import AltitudeGraph from './AltitudeGraph.vue';
|
||||
import { contextNeedle, contextSearchText, matchesContextSearch } from '../../contextSearch.js';
|
||||
import CctvPreview from './CctvPreview.vue';
|
||||
import { useCctvStore } from '../../stores/cctv.js';
|
||||
import SpotConditions from './SpotConditions.vue';
|
||||
import { shownLayerName } from '../../layerNames.js';
|
||||
import { countryName, nearestCity } from '../../../data/wikidataCities.js';
|
||||
|
||||
// The Context panel's card for one thing on the map: what it is, its facts,
|
||||
@@ -19,6 +20,7 @@ const { card, lost, tick } = storeToRefs(store);
|
||||
const { frame: cctvFrame } = storeToRefs(useCctvStore());
|
||||
const shownTitle = computed(() => {
|
||||
const current = card.value;
|
||||
if (current?.titleWords) return sayWords(current.titleWords, current.title);
|
||||
if (current?.layerId !== 'cctv') return current?.title;
|
||||
const f = cctvFrame.value;
|
||||
if (!f || f.cameraId !== current.identity?.id) return current.title;
|
||||
@@ -64,7 +66,9 @@ const position = computed(() => {
|
||||
});
|
||||
|
||||
const distance = (km) =>
|
||||
km < 1 ? t('{n} m', { n: Math.round(km * 1000) }) : t('{n} km', { n: km < 10 ? km.toFixed(1) : Math.round(km) });
|
||||
km < 1
|
||||
? t('{n} m', { n: formatNumber(Math.round(km * 1000)) })
|
||||
: t('{n} km', { n: formatNumber(km < 10 ? Number(km.toFixed(1)) : Math.round(km)) });
|
||||
|
||||
const source = computed(() => {
|
||||
void tick.value;
|
||||
@@ -95,11 +99,6 @@ const restFacts = computed(() => {
|
||||
return (card.value?.facts || []).filter((fact) => !shown.has(fact.field));
|
||||
});
|
||||
|
||||
// A figure split into its number and unit, so the number can lead.
|
||||
function splitValue(value) {
|
||||
const match = String(value).match(/^([-−+]?[\d.,]+|M [\d.]+)\s*(.*)$/);
|
||||
return match ? { number: match[1], unit: match[2] } : { number: String(value), unit: '' };
|
||||
}
|
||||
|
||||
// The line under the name: who runs it and what it is. The layer is already
|
||||
// named on the line above the title.
|
||||
@@ -107,14 +106,15 @@ const subtitle = computed(() => {
|
||||
const current = card.value;
|
||||
if (!current) return '';
|
||||
const cls = current.aircraftClass;
|
||||
return [current.operator, cls && cls[0].toUpperCase() + cls.slice(1)].filter(Boolean).join(' · ');
|
||||
const clsName = current.aircraftClassName ? t(current.aircraftClassName) : cls && cls[0].toUpperCase() + cls.slice(1);
|
||||
return [current.operator, clsName].filter(Boolean).join(' · ');
|
||||
});
|
||||
// The details grid leaves out what the header already says.
|
||||
// The Context search narrows them to the ones whose name or value holds its
|
||||
// text, and looks through every fact, the headline ones included.
|
||||
const gridFacts = computed(() =>
|
||||
contextNeedle.value
|
||||
? (card.value?.facts || []).filter((fact) => matchesContextSearch(t(fact.label), fact.value))
|
||||
? (card.value?.facts || []).filter((fact) => matchesContextSearch(factLabel(fact), factValue(fact), fact.value))
|
||||
: restFacts.value.filter((fact) => !(card.value?.operator && fact.field === 'operator') && !(card.value?.aircraftClass && fact.field === 'aircraftClass')),
|
||||
);
|
||||
|
||||
@@ -140,7 +140,11 @@ const routeProgress = computed(() => {
|
||||
const speedKmh = Number.isFinite(current.speedMps) ? current.speedMps * 3.6 : null;
|
||||
const hours = speedKmh && speedKmh > 80 ? left / speedKmh : null;
|
||||
const eta =
|
||||
hours === null ? null : hours >= 1 ? `${Math.floor(hours)} h ${Math.round((hours % 1) * 60)} min` : `${Math.max(1, Math.round(hours * 60))} min`;
|
||||
hours === null
|
||||
? null
|
||||
: hours >= 1
|
||||
? t('{h} h {m} min', { h: Math.floor(hours), m: Math.round((hours % 1) * 60) })
|
||||
: t('{n} min', { n: Math.max(1, Math.round(hours * 60)) });
|
||||
return {
|
||||
share: Math.min(1, Math.max(0, share)),
|
||||
flown: distance(flown),
|
||||
@@ -192,7 +196,8 @@ const kindLine = computed(() => {
|
||||
if (!current) return '';
|
||||
const layer = current.layerName || '';
|
||||
const plain = (words) => words.toLowerCase().replace(/s\b/g, '');
|
||||
return plain(layer).includes(plain(current.kind)) ? layer : `${kindLabel.value} · ${layer}`;
|
||||
const shown = shownLayerName(layer, current.layerId);
|
||||
return plain(layer).includes(plain(current.kind)) ? shown : `${kindLabel.value} · ${shown}`;
|
||||
});
|
||||
|
||||
// A new item starts at the top of the panel, not wherever the last one was
|
||||
@@ -220,8 +225,8 @@ watch(
|
||||
<span class="material-symbols-outlined entity-hero__glyph" aria-hidden="true">{{ card.icon }}</span>
|
||||
<div v-if="tiles.length" class="entity-hero__figures">
|
||||
<div v-for="fact in tiles" :key="fact.field" class="entity-hero__figure">
|
||||
<strong>{{ splitValue(fact.value).number }}<small v-if="splitValue(fact.value).unit">{{ splitValue(fact.value).unit }}</small></strong>
|
||||
<span>{{ t(fact.label) }}</span>
|
||||
<strong>{{ factFigure(fact).number }}<small v-if="factFigure(fact).unit">{{ factFigure(fact).unit }}</small></strong>
|
||||
<span>{{ factLabel(fact) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span v-else class="entity-hero__kind">{{ kindLabel }}</span>
|
||||
@@ -247,7 +252,7 @@ watch(
|
||||
|
||||
<div v-if="card.warnings?.length" class="entity-card__warning" role="alert">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">warning</span>
|
||||
<span>{{ card.warnings.join(' · ') }}</span>
|
||||
<span>{{ card.warnings.map((warning, index) => sayWords(card.warningWords?.[index], warning)).join(' · ') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="card.route" class="entity-card__route" :class="{ 'entity-card__route--unverified': !card.route.verified, 'entity-card__route--progress': routeProgress }">
|
||||
@@ -276,8 +281,8 @@ watch(
|
||||
|
||||
<div v-if="tiles.length && heroKind !== 'none' && !contextNeedle" class="entity-card__tiles" :style="{ gridTemplateColumns: `repeat(${tiles.length}, minmax(0, 1fr))` }">
|
||||
<div v-for="fact in tiles" :key="fact.field" class="entity-card__tile">
|
||||
<span>{{ t(fact.label) }}</span>
|
||||
<strong>{{ splitValue(fact.value).number }}<small v-if="splitValue(fact.value).unit">{{ splitValue(fact.value).unit }}</small></strong>
|
||||
<span>{{ factLabel(fact) }}</span>
|
||||
<strong>{{ factFigure(fact).number }}<small v-if="factFigure(fact).unit">{{ factFigure(fact).unit }}</small></strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -286,8 +291,8 @@ watch(
|
||||
<h4>{{ contextNeedle ? t('Matching details') : t('Details') }}</h4>
|
||||
<dl class="entity-card__facts">
|
||||
<div v-for="fact in gridFacts" :key="fact.field" class="entity-card__fact">
|
||||
<dt>{{ t(fact.label) }}</dt>
|
||||
<dd>{{ fact.value }}</dd>
|
||||
<dt>{{ factLabel(fact) }}</dt>
|
||||
<dd>{{ factValue(fact) }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { onLocaleChange, t } from '../../../i18n/index.js';
|
||||
import { formatNumber, onLocaleChange, t } from '../../../i18n/index.js';
|
||||
import { compassName, hazardsNear, regionalBrief, weatherLook } from '../../spotConditions.js';
|
||||
import { distanceKm } from '../../../data/entityContext.js';
|
||||
import { CONTEXT_RADIUS_STEPS, contextRadiusKm, setContextRadiusKm } from '../../contextRadius.js';
|
||||
import { contextNeedle, matchesContextSearch } from '../../contextSearch.js';
|
||||
import UiSlider from '../../kit/UiSlider.js';
|
||||
import { useEntityCardStore } from '../../stores/entityCard.js';
|
||||
import { sayWords, useEntityCardStore } from '../../stores/entityCard.js';
|
||||
import { useOmnibarStore } from '../../stores/omnibar.js';
|
||||
import { shownLayerName } from '../../layerNames.js';
|
||||
|
||||
@@ -44,7 +44,7 @@ let readingHazards = 0;
|
||||
let settle = null;
|
||||
|
||||
const radiusKm = contextRadiusKm;
|
||||
const radiusText = computed(() => `${radiusKm.value.toLocaleString()} km`);
|
||||
const radiusText = computed(() => t('{n} km', { n: formatNumber(radiusKm.value) }));
|
||||
const radiusIndex = computed(() => Math.max(0, CONTEXT_RADIUS_STEPS.indexOf(radiusKm.value)));
|
||||
const pickRadius = (index) => setContextRadiusKm(CONTEXT_RADIUS_STEPS[index]);
|
||||
|
||||
@@ -101,7 +101,7 @@ const alerts = computed(() => {
|
||||
void tick.value;
|
||||
return store
|
||||
.alertsAt(props.lat, props.lon, { radiusKm: radiusKm.value, limit: searching.value ? 40 : 4 })
|
||||
.filter((alert) => matchesContextSearch(alert.title, alert.text));
|
||||
.filter((alert) => matchesContextSearch(alert.title, sayWords(alert.words, alert.text), alert.text));
|
||||
});
|
||||
const shownHazards = computed(() =>
|
||||
hazards.value.filter((hazard) => matchesContextSearch(hazard.title, hazard.detail, hazardLayers.value[hazard.kind]?.name)).slice(0, searching.value ? 12 : 5),
|
||||
@@ -142,18 +142,25 @@ const weatherFacts = computed(() => {
|
||||
if (!now) return [];
|
||||
const facts = [];
|
||||
if (Number.isFinite(now.windKph)) {
|
||||
const from = Number.isFinite(now.windDirectionDeg)
|
||||
? ` ${compassName(now.windDirectionDeg)}`
|
||||
: '';
|
||||
facts.push({ label: t('Wind'), value: `${round(now.windKph)} km/h${from}` });
|
||||
const speed = t('{n} km/h', { n: formatNumber(round(now.windKph)) });
|
||||
facts.push({
|
||||
label: t('Wind'),
|
||||
value: Number.isFinite(now.windDirectionDeg) ? t('{speed} {direction}', { speed, direction: t(compassName(now.windDirectionDeg)) }) : speed,
|
||||
});
|
||||
}
|
||||
if (Number.isFinite(now.cloudCoverPct)) facts.push({ label: t('Cloud'), value: `${round(now.cloudCoverPct)}%` });
|
||||
if (Number.isFinite(now.cloudCoverPct)) facts.push({ label: t('Cloud'), value: t('{n}%', { n: formatNumber(round(now.cloudCoverPct)) }) });
|
||||
if (Number.isFinite(now.visibilityM))
|
||||
facts.push({
|
||||
label: t('Visibility'),
|
||||
value: now.visibilityM >= 10_000 ? `${round(now.visibilityM / 1000)} km` : `${(now.visibilityM / 1000).toFixed(1)} km`,
|
||||
value: t('{n} km', {
|
||||
n: formatNumber(now.visibilityM >= 10_000 ? round(now.visibilityM / 1000) : Number((now.visibilityM / 1000).toFixed(1))),
|
||||
}),
|
||||
});
|
||||
if (Number.isFinite(now.precipitationMm))
|
||||
facts.push({
|
||||
label: t('Rain'),
|
||||
value: t('{n} mm', { n: formatNumber(now.precipitationMm, { minimumFractionDigits: 1, maximumFractionDigits: 1 }) }),
|
||||
});
|
||||
if (Number.isFinite(now.precipitationMm)) facts.push({ label: t('Rain'), value: `${now.precipitationMm.toFixed(1)} mm` });
|
||||
return facts;
|
||||
});
|
||||
|
||||
@@ -161,7 +168,8 @@ const articles = computed(() =>
|
||||
props.entity ? [] : (brief.value?.articles || []).filter((article) => matchesContextSearch(article.title, article.domain)).slice(0, 3),
|
||||
);
|
||||
|
||||
const distance = (km) => (km < 10 ? `${km.toFixed(1)} km` : `${Math.round(km).toLocaleString()} km`);
|
||||
const distance = (km) =>
|
||||
t('{n} km', { n: km < 10 ? formatNumber(km, { minimumFractionDigits: 1, maximumFractionDigits: 1 }) : formatNumber(Math.round(km)) });
|
||||
function ago(ms) {
|
||||
if (!Number.isFinite(ms)) return '';
|
||||
const minutes = Math.max(0, Math.round((Date.now() - ms) / 60_000));
|
||||
@@ -300,7 +308,7 @@ const sources = computed(() => {
|
||||
<span class="spot-conditions__row-dot" aria-hidden="true"></span>{{ hazardLayers[hazard.kind].name }}
|
||||
</span>
|
||||
</span>
|
||||
<span class="spot-conditions__row-meta">{{ distance(hazard.distanceKm) }} {{ hazard.direction }}</span>
|
||||
<span class="spot-conditions__row-meta">{{ distance(hazard.distanceKm) }} {{ t(hazard.direction) }}</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -319,7 +327,7 @@ const sources = computed(() => {
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ alert.icon }}</span>
|
||||
<span class="spot-conditions__row-main">
|
||||
<span class="spot-conditions__row-title">{{ alert.title }}</span>
|
||||
<span class="spot-conditions__row-detail">{{ alert.text }}</span>
|
||||
<span class="spot-conditions__row-detail">{{ sayWords(alert.words, alert.text) }}</span>
|
||||
</span>
|
||||
<span class="spot-conditions__row-meta">{{ distance(alert.distanceKm) }}</span>
|
||||
</button>
|
||||
@@ -339,7 +347,7 @@ const sources = computed(() => {
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ item.icon }}</span>
|
||||
<span class="spot-conditions__row-main">
|
||||
<span class="spot-conditions__row-title">{{ item.title }}</span>
|
||||
<span class="spot-conditions__row-detail">{{ item.layerName }}</span>
|
||||
<span class="spot-conditions__row-detail">{{ shownLayerName(item.layerName, item.layerId) }}</span>
|
||||
</span>
|
||||
<span class="spot-conditions__row-meta">{{ distance(item.distanceKm) }}</span>
|
||||
</button>
|
||||
|
||||
@@ -201,7 +201,7 @@ const dial = computed(() => {
|
||||
shadow,
|
||||
day: elevation > 0,
|
||||
elevation: Math.round(elevation),
|
||||
direction: compass[Math.round(bearing / 45) % 8],
|
||||
direction: t(compass[Math.round(bearing / 45) % 8]),
|
||||
shine,
|
||||
clock,
|
||||
gnomon: {
|
||||
@@ -310,7 +310,7 @@ const caption = computed(() =>
|
||||
/>
|
||||
<text v-for="(line, i) in dial.hours" :key="`t${line.h}`" :x="line.label.x" :y="line.label.y + 2.6">{{ ROMAN[i] }}</text>
|
||||
</g>
|
||||
<text :x="dial.poleLabel.x" :y="dial.poleLabel.y + 3" class="sun-dial__pole">{{ dial.poleText }}</text>
|
||||
<text :x="dial.poleLabel.x" :y="dial.poleLabel.y + 3" class="sun-dial__pole">{{ t(dial.poleText) }}</text>
|
||||
|
||||
<!-- The shadow, then the gnomon standing over it. -->
|
||||
<polygon v-if="dial.shadow" :points="dial.shadow" fill="#000" opacity="0.6" filter="url(#sun-dial-shadow)" />
|
||||
@@ -356,7 +356,7 @@ const caption = computed(() =>
|
||||
:x="c.x * 20"
|
||||
:y="c.y * 20 + 2.3"
|
||||
:class="['sun-dial__compass-label', { north: c.k === 'N' }]"
|
||||
>{{ c.k }}</text>
|
||||
>{{ t(c.k) }}</text>
|
||||
</g>
|
||||
</svg>
|
||||
<figcaption>{{ caption }}</figcaption>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { contextNeedle, contextSearchText, matchesContextSearch } from '../../contextSearch.js';
|
||||
import { t, tn } from '../../../i18n/index.js';
|
||||
import { formatNumber, t, tn } from '../../../i18n/index.js';
|
||||
import { citiesAround, countryName, nearestCity } from '../../../data/wikidataCities.js';
|
||||
import { useEntityCardStore } from '../../stores/entityCard.js';
|
||||
import { useOmnibarStore } from '../../stores/omnibar.js';
|
||||
@@ -179,16 +179,16 @@ function breakdownOf(layerId, loaded) {
|
||||
if (!found) return null;
|
||||
const basis = globeView.value
|
||||
? loaded !== null && loaded > found.total
|
||||
? t('Of {n} read, {total} loaded', { n: found.total.toLocaleString(), total: loaded.toLocaleString() })
|
||||
: t('Of all {n}', { n: found.total.toLocaleString() })
|
||||
: t('Of {n} in view', { n: found.total.toLocaleString() });
|
||||
? t('Of {n} read, {total} loaded', { n: formatNumber(found.total), total: formatNumber(loaded) })
|
||||
: t('Of all {n}', { n: formatNumber(found.total) })
|
||||
: t('Of {n} in view', { n: formatNumber(found.total) });
|
||||
return {
|
||||
basis,
|
||||
splits: found.splits.map((split) => ({
|
||||
title: t(split.title),
|
||||
parts: split.parts.map((part, index) => ({
|
||||
label: t(part.label),
|
||||
count: part.count.toLocaleString(),
|
||||
count: formatNumber(part.count),
|
||||
share: `${((part.count / found.total) * 100).toFixed(1)}%`,
|
||||
color: SPLIT_COLORS[index % SPLIT_COLORS.length],
|
||||
})),
|
||||
@@ -268,7 +268,9 @@ function turnOn(layer) {
|
||||
}
|
||||
|
||||
const distance = (km) =>
|
||||
km < 1 ? t('{n} m', { n: Math.round(km * 1000) }) : t('{n} km', { n: km < 10 ? km.toFixed(1) : Math.round(km) });
|
||||
km < 1
|
||||
? t('{n} m', { n: formatNumber(Math.round(km * 1000)) })
|
||||
: t('{n} km', { n: formatNumber(km < 10 ? Number(km.toFixed(1)) : Math.round(km)) });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -293,7 +295,7 @@ const distance = (km) =>
|
||||
<div class="view-context__world-grid">
|
||||
<component :is="tile.on ? 'div' : 'button'" v-for="tile in worldTiles" :key="tile.id" :type="tile.on ? undefined : 'button'" class="view-context__world-tile" :class="{ 'is-off': !tile.on }" :title="tile.on ? undefined : t('Turn on {name}', { name: tile.name })" @click="tile.on ? undefined : turnOn(tile)">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ tile.icon }}</span>
|
||||
<strong>{{ tile.on ? (tile.count === null ? '…' : tile.count.toLocaleString()) : t('Off') }}</strong>
|
||||
<strong>{{ tile.on ? (tile.count === null ? '…' : formatNumber(tile.count)) : t('Off') }}</strong>
|
||||
<span>{{ tile.name }}</span>
|
||||
</component>
|
||||
</div>
|
||||
@@ -312,7 +314,7 @@ const distance = (km) =>
|
||||
<span class="view-context__live-main">
|
||||
<span class="view-context__live-name">{{ layer.name }}</span>
|
||||
<span class="view-context__live-meta">
|
||||
<template v-if="layer.total !== null">{{ t('{n} loaded', { n: layer.total.toLocaleString() }) }} · </template>{{ t('{n} in view', { n: layer.inView }) }}<template v-if="layer.updated"> · {{ layer.updated }}</template>
|
||||
<template v-if="layer.total !== null">{{ t('{n} loaded', { n: formatNumber(layer.total) }) }} · </template>{{ t('{n} in view', { n: layer.inView }) }}<template v-if="layer.updated"> · {{ layer.updated }}</template>
|
||||
</span>
|
||||
</span>
|
||||
<span class="view-context__live-state" :class="`view-context__live-state--${layer.state.tone}`">{{ layer.state.text }}</span>
|
||||
@@ -352,7 +354,7 @@ const distance = (km) =>
|
||||
<div v-for="group in groups" :key="group.layerId" class="view-context__group">
|
||||
<h4>
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ group.icon }}</span>
|
||||
<span>{{ group.layerName }}</span>
|
||||
<span>{{ shownLayerName(group.layerName, group.layerId) }}</span>
|
||||
<span class="view-context__count">{{ group.count }}</span>
|
||||
</h4>
|
||||
<ul>
|
||||
|
||||
Reference in new issue
Block a user