Translate the Context panel

Marks the Context panel's remaining strings and translates them into every locale.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-16 14:59:17 -08:00
1 parent 902689da8a
commit 4554713f98
20 files changed
+2113 -99

No files matched your search

+3 -2
View File
@@ -1,4 +1,5 @@
import { computed, ref } from 'vue';
import { msg } from '../i18n/index.js';
// Context's layer tabs: when a layer that has its own settings is on, those
// settings move out of the panel they normally live in (Visual) into a tab
@@ -42,13 +43,13 @@ export const LAYER_TABS = [
// Labels and cards the world overlay draws for the label layers.
{
id: 'labels',
label: 'Labels',
label: msg('Labels'),
icon: 'label',
when: (on) => TAB_AFFECTS.labels(on).length > 0,
},
{
id: 'aircraft',
label: '3D aircraft',
label: msg('3D aircraft'),
icon: 'flight',
when: (on) => TAB_AFFECTS.aircraft(on).length > 0,
},
+28 -21
View File
@@ -1,4 +1,5 @@
import { 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';
import { createWfigsPerimeterSource } from '../layers/perimeters/source.js';
@@ -104,8 +105,8 @@ export async function hazardsNear(lat, lon, radiusKm = 250) {
kind: 'quake',
icon: 'earthquake',
title: Number.isFinite(Number.parseFloat(quake.mag))
? `M${Number(quake.mag).toFixed(1)} earthquake`
: 'Earthquake',
? t('M{mag} earthquake', { mag: Number(quake.mag).toFixed(1) })
: t('Earthquake'),
detail: quake.place || '',
time: quake.time,
at,
@@ -121,7 +122,7 @@ export async function hazardsNear(lat, lon, radiusKm = 250) {
kind: 'storm',
icon: 'cyclone',
title: [storm.classification, storm.name].filter(Boolean).join(' '),
detail: storm.windKt ? `${storm.windKt} kt winds` : '',
detail: storm.windKt ? t('{n} kt winds', { n: storm.windKt }) : '',
time: Date.parse(storm.positionAt) || null,
at,
});
@@ -133,15 +134,15 @@ export async function hazardsNear(lat, lon, radiusKm = 250) {
add({
kind: 'wildfire',
icon: 'local_fire_department',
title: fire.name || 'Wildfire',
title: fire.name || t('Wildfire'),
detail: [
Number.isFinite(acres)
? `${Math.round(acres).toLocaleString()} acres`
? t('{n} acres', { n: Math.round(acres).toLocaleString() })
: '',
Number.isFinite(fire.containedPct)
? `${fire.containedPct}% contained`
? t('{n}% contained', { n: fire.containedPct })
: '',
fire.category === 'RX' ? 'prescribed burn' : '',
fire.category === 'RX' ? t('prescribed burn') : '',
]
.filter(Boolean)
.join(' · '),
@@ -163,8 +164,12 @@ export async function hazardsNear(lat, lon, radiusKm = 250) {
add({
kind: 'hotspots',
icon: 'local_fire_department',
title: `${hits.length} satellite fire ${hits.length === 1 ? 'hit' : 'hits'}`,
detail: 'last day',
title: tn(
hits.length,
'{count} satellite fire hit',
'{count} satellite fire hits',
),
detail: t('last day'),
time: null,
at: nearest,
});
@@ -179,19 +184,21 @@ export async function hazardsNear(lat, lon, radiusKm = 250) {
export function weatherLook(code) {
const value = Number(code);
if (!Number.isFinite(value))
return { label: 'Conditions unknown', icon: 'partly_cloudy_day' };
if (value === 0) return { label: 'Clear', icon: 'sunny' };
if (value <= 2) return { label: 'Partly cloudy', icon: 'partly_cloudy_day' };
if (value === 3) return { label: 'Overcast', icon: 'cloud' };
if (value === 45 || value === 48) return { label: 'Fog', icon: 'foggy' };
if (value >= 51 && value <= 57) return { label: 'Drizzle', icon: 'rainy' };
if (value >= 61 && value <= 67) return { label: 'Rain', icon: 'rainy' };
return { label: msg('Conditions unknown'), icon: 'partly_cloudy_day' };
if (value === 0) return { label: msg('Clear'), icon: 'sunny' };
if (value <= 2)
return { label: msg('Partly cloudy'), icon: 'partly_cloudy_day' };
if (value === 3) return { label: msg('Overcast'), icon: 'cloud' };
if (value === 45 || value === 48) return { label: msg('Fog'), icon: 'foggy' };
if (value >= 51 && value <= 57)
return { label: msg('Drizzle'), icon: 'rainy' };
if (value >= 61 && value <= 67) return { label: msg('Rain'), icon: 'rainy' };
if (value >= 71 && value <= 77)
return { label: 'Snow', icon: 'weather_snowy' };
return { label: msg('Snow'), icon: 'weather_snowy' };
if (value >= 80 && value <= 82)
return { label: 'Rain showers', icon: 'rainy' };
return { label: msg('Rain showers'), icon: 'rainy' };
if (value >= 85 && value <= 86)
return { label: 'Snow showers', icon: 'weather_snowy' };
if (value >= 95) return { label: 'Thunderstorm', icon: 'thunderstorm' };
return { label: 'Mixed conditions', icon: 'partly_cloudy_day' };
return { label: msg('Snow showers'), icon: 'weather_snowy' };
if (value >= 95) return { label: msg('Thunderstorm'), icon: 'thunderstorm' };
return { label: msg('Mixed conditions'), icon: 'partly_cloudy_day' };
}
+7 -3
View File
@@ -1,6 +1,6 @@
<script setup>
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { t } from '../../../i18n/index.js';
import { 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';
@@ -73,13 +73,16 @@ watch(
{ immediate: true },
);
// A new radius only re-filters the hazard feeds, which are already cached.
watch(radiusKm, async (km) => {
async function rereadHazards(km) {
const at = readAt || { lat: props.lat, lon: props.lon };
const mine = ++readingHazards;
const next = await hazardsNear(at.lat, at.lon, km).catch(() => []);
if (readingHazards !== mine) return;
hazards.value = next;
});
}
watch(radiusKm, (km) => void rereadHazards(km));
// Hazard rows are worded as they are read, so a new language reads them again.
const stopLocale = onLocaleChange(() => void rereadHazards(radiusKm.value));
// Warnings from the loaded layers move with their records; read them often.
const tick = ref(0);
@@ -90,6 +93,7 @@ onMounted(() => {
onBeforeUnmount(() => {
clearInterval(timer);
clearTimeout(settle);
stopLocale();
});
// The Context search narrows every list below to what holds its text.
const searching = computed(() => Boolean(contextNeedle.value));
+3 -3
View File
@@ -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 } from '../../../i18n/index.js';
import { 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';
@@ -45,8 +45,8 @@ const groups = computed(() => {
const shownTowns = computed(() => towns.value.filter((town) => matchesContextSearch(town.name)));
const total = computed(() => groups.value.reduce((sum, group) => sum + group.count, 0));
const totalLine = computed(() => {
const things = total.value === 1 ? t('1 thing') : t('{n} things', { n: total.value });
const layers = groups.value.length === 1 ? t('1 layer') : t('{n} layers', { n: groups.value.length });
const things = tn(total.value, '{count} thing', '{count} things');
const layers = tn(groups.value.length, '{count} layer', '{count} layers');
return t('{things} in view from {layers}', { things, layers });
});