mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
A screenshot review of the Spanish UI found: - Text left in English. Catalog entries copied from English (Bloom, Cyber, Pin, NEWS, SITE, ON/OFF, RANGE, PITCH, HGT…) and the radio music genres, which never went through t(). The genres are translated in es and ru now. - Wording: gender agreement, calques of the English, hints that name buttons that do not exist, and one concept worded two ways. - Layout: the DESACTIVADO pill squeezed layer names until words broke mid-word; the scene and camera selects showed one word; a collapsed rail title pushed its button out of the card; the image slot line and a comparison readout were cut or split. The layout fixes are scoped to languages other than English, so English stays pixel-identical. Visual-style slider values now use the locale's decimal separator (0,85). npm run i18n now reports a translation that is identical to the English, unless src/i18n/same-as-english.json lists it for that language (codes, product names, words spelled the same). Co-Authored-By: Claude Opus 5.5 <[email protected]>
139 lines
3.9 KiB
JavaScript
139 lines
3.9 KiB
JavaScript
import { MUSIC_GENRES, CATEGORY_MATCHERS } from './policy.js';
|
|
import { t } from '../../i18n/index.js';
|
|
|
|
export function createCategories({
|
|
state: layerState,
|
|
services,
|
|
parts,
|
|
source,
|
|
}) {
|
|
/** Normalize one directory tag to a stable, lower-case display token. */
|
|
|
|
function normalizeRadioTag(value) {
|
|
return String(value ?? '')
|
|
.trim()
|
|
.toLocaleLowerCase()
|
|
.replace(/[_-]+/g, ' ')
|
|
.replace(/\s+/g, ' ')
|
|
.slice(0, 80);
|
|
}
|
|
|
|
function stationTags(station) {
|
|
if (Array.isArray(station?.tags))
|
|
return station.tags.map(normalizeRadioTag).filter(Boolean);
|
|
return String(station?.tags ?? '')
|
|
.split(',')
|
|
.map(normalizeRadioTag)
|
|
.filter(Boolean);
|
|
}
|
|
|
|
function hasTag(station, needles) {
|
|
const tags = stationTags(station);
|
|
return needles.some((needle) =>
|
|
tags.some((tag) => tag === needle || tag.includes(needle)),
|
|
);
|
|
}
|
|
|
|
function detectedGenres(station) {
|
|
return MUSIC_GENRES.filter(([genre]) => hasTag(station, [genre])).map(
|
|
([genre]) => genre,
|
|
);
|
|
}
|
|
|
|
/** Return whether a station belongs in a station-tag category. */
|
|
|
|
function stationMatchesRadioCategory(station, categoryId) {
|
|
if (categoryId === 'all') return true;
|
|
if (categoryId.startsWith('genre:')) {
|
|
return detectedGenres(station).includes(
|
|
categoryId.slice('genre:'.length),
|
|
);
|
|
}
|
|
if (categoryId === 'music') {
|
|
return (
|
|
detectedGenres(station).length > 0 ||
|
|
hasTag(station, ['music', 'hits', 'songs'])
|
|
);
|
|
}
|
|
if (categoryId === 'other') {
|
|
return (
|
|
!Object.entries(CATEGORY_MATCHERS).some(([id]) =>
|
|
stationMatchesRadioCategory(station, id),
|
|
) && !stationMatchesRadioCategory(station, 'music')
|
|
);
|
|
}
|
|
return hasTag(station, CATEGORY_MATCHERS[categoryId] || []);
|
|
}
|
|
|
|
/** Build canonical and detected-genre categories from station-level tags. */
|
|
|
|
function buildRadioCategories(stations) {
|
|
const rows = Array.isArray(stations) ? stations : [];
|
|
const categories = [
|
|
{ id: 'all', label: t('All', { context: 'radio tag' }) },
|
|
{ id: 'news', label: t('News') },
|
|
{ id: 'talk', label: t('Talk') },
|
|
{ id: 'weather', label: t('Weather / Emergency') },
|
|
{ id: 'public-safety', label: t('Public Safety') },
|
|
{
|
|
id: 'aviation-marine',
|
|
label: t('Aviation / Marine'),
|
|
},
|
|
{
|
|
id: 'traffic-transit',
|
|
label: t('Traffic / Transit'),
|
|
},
|
|
{ id: 'music', label: t('Music') },
|
|
];
|
|
|
|
for (const [genre, label] of MUSIC_GENRES) {
|
|
const id = `genre:${genre}`;
|
|
if (rows.some((station) => stationMatchesRadioCategory(station, id))) {
|
|
categories.push({ id, label: t(label) });
|
|
}
|
|
}
|
|
categories.push({ id: 'other', label: t('Other') });
|
|
return categories.map((category) => ({
|
|
...category,
|
|
color: parts.model.radioCategoryColor(category.id),
|
|
count: rows.filter((station) =>
|
|
stationMatchesRadioCategory(station, category.id),
|
|
).length,
|
|
}));
|
|
}
|
|
|
|
/** Filter stations without changing the active stream or selection. */
|
|
|
|
function filterRadioStations(stations, categoryId = 'all') {
|
|
return (Array.isArray(stations) ? stations : []).filter((station) =>
|
|
stationMatchesRadioCategory(station, categoryId),
|
|
);
|
|
}
|
|
|
|
/** Return whether Radio Browser metadata identifies a station as English-language. */
|
|
|
|
function isEnglishRadioStation(station) {
|
|
const languages = Array.isArray(station?.languages)
|
|
? station.languages
|
|
: [];
|
|
return languages.some((language) => {
|
|
const normalized = normalizeRadioTag(language);
|
|
return (
|
|
normalized === 'en' ||
|
|
normalized === 'eng' ||
|
|
normalized.startsWith('english')
|
|
);
|
|
});
|
|
}
|
|
return {
|
|
normalizeRadioTag,
|
|
stationTags,
|
|
hasTag,
|
|
detectedGenres,
|
|
stationMatchesRadioCategory,
|
|
buildRadioCategories,
|
|
filterRadioStations,
|
|
isEnglishRadioStation,
|
|
};
|
|
}
|