From 45a128d3285599fb8fdd4c697f51118ac0849251 Mon Sep 17 00:00:00 2001 From: syfyra <258908070+syfyra@users.noreply.github.com> Date: Thu, 26 Nov 2026 17:29:25 +0100 Subject: [PATCH 1/2] studio: show category names in the chosen language (STUDIO-CATEGORY-NAMES) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The studio's I18N table has catNames for both languages ("Транспорт (Vehicles)" -> "Транспорт" / "Vehicles"), but the category chips and the model list headers showed the server's two-language name in either language. Show categoryLabel(cat) there, keep the server's name as the filter key (and for any name catNames does not list), and relabel the chips on a language switch; the list headers already re-render. Builds on #2339 (STUDIO-EU-STRINGS), which applies the other unused entries of the same table. Tested: new test in tests/test_viewer_studio.cjs (fails on #2339's head, passes after); the other studio tests pass. Co-Authored-By: Claude Opus 5.5 --- tests/test_viewer_studio.cjs | 21 +++++++++++++++++++++ viewer/studio.html | 14 ++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/test_viewer_studio.cjs b/tests/test_viewer_studio.cjs index 7a28f3b38..4364c3f65 100644 --- a/tests/test_viewer_studio.cjs +++ b/tests/test_viewer_studio.cjs @@ -213,6 +213,27 @@ test('switching to EU relabels the stats panel, the buttons, the texture gallery assert.equal(studio.elements.get('tex-count').innerText, 'Could not load the textures'); }); +test('category chips and headers show the catNames of the chosen language and keep the server name as the filter', () => { + const studio = loadStudio(); + studio.context.models = [ + { name: 'car.glb', folder: 'veh', category: 'Транспорт (Vehicles)', size: 4, url: '/models/car.glb' }, + { name: 'odd.glb', folder: 'x', category: 'Custom', size: 4, url: '/models/odd.glb' }, + ]; + studio.run(`allModels = models; renderCategoryChips({'Транспорт (Vehicles)': 1, Custom: 1}); renderAccordionList();`); + const chips = () => studio.elements.get('category-chips').children.slice(1).map(chip => chip.innerText); + const headers = () => studio.elements.get('model-list').children.map(group => visibleText(group.children[0].innerHTML).trim()); + assert.deepEqual(chips(), ['Транспорт (1)', 'Custom (1)']); + assert.deepEqual(headers().map(text => text.split(/\s+/)[0]), ['Транспорт', 'Custom']); + + studio.run(`setLanguage('eu')`); + assert.deepEqual(chips(), ['Vehicles (1)', 'Custom (1)']); + assert.deepEqual(headers().map(text => text.split(/\s+/)[0]), ['Vehicles', 'Custom']); + // The chip still filters by the server's name. + studio.run(`selectCategory('Транспорт (Vehicles)', document.getElementById('category-chips').children[1])`); + assert.equal(studio.run('activeCategory'), 'Транспорт (Vehicles)'); + assert.deepEqual(headers().map(text => text.split(/\s+/)[0]), ['Vehicles']); +}); + test('each model category pages independently, including a partial last page', () => { const studio = loadStudio(); studio.context.models = ['Props', 'Vehicles'].flatMap(category => Array.from({ length: 101 }, (_, i) => ({ diff --git a/viewer/studio.html b/viewer/studio.html index 60e6887ec..608461d67 100644 --- a/viewer/studio.html +++ b/viewer/studio.html @@ -565,6 +565,7 @@ function applyTranslations() { document.getElementById('tex-heading').innerText = t.texHeading; const allChip = document.getElementById('chip-all'); if (allChip) allChip.innerText = `${t.allCategories} (${allModels.length})`; + for (const { chip, cat, count } of categoryChips) chip.innerText = `${categoryLabel(cat)} (${count})`; if (texturesLoaded) document.getElementById('tex-count').innerText = `${allTextures.length} ${t.texCountSuffix}`; // Each stats label is the text node in front of its value (
Модель: ). for (const [id, key] of [['stat-name', 'statModel'], ['stat-category', 'statCategory'], @@ -582,6 +583,7 @@ let selectedModel = null; const modelPages = new Map(); let allTextures = []; let texturesLoaded = false; +const categoryChips = []; // { chip, cat, count } of the category filter chips, relabelled on a language switch let activeCategory = 'ALL'; let modelSearchQuery = ''; let texSearchQuery = ''; @@ -829,6 +831,7 @@ async function loadModels() { function renderCategoryChips(categories) { const container = document.getElementById('category-chips'); container.innerHTML = ''; + categoryChips.length = 0; const allChip = document.createElement('div'); allChip.className = 'filter-chip active'; @@ -840,12 +843,19 @@ function renderCategoryChips(categories) { Object.entries(categories).forEach(([cat, count]) => { const chip = document.createElement('div'); chip.className = 'filter-chip'; - chip.innerText = `${cat} (${count})`; + chip.innerText = `${categoryLabel(cat)} (${count})`; chip.onclick = () => selectCategory(cat, chip); container.appendChild(chip); + categoryChips.push({ chip, cat, count }); }); } +// The server names each category in both languages ("Транспорт (Vehicles)"); catNames gives the name to show, and +// the server's name stays the filter key. A name catNames does not list is shown as it is. +function categoryLabel(cat) { + return I18N[currentLang].catNames[cat] || cat; +} + function selectCategory(cat, chipElem) { if (activeCategory !== cat) modelPages.clear(); activeCategory = cat; @@ -897,7 +907,7 @@ function renderAccordionList() { const header = document.createElement('div'); header.className = 'cat-header'; header.innerHTML = ` - ${escapeHtml(cat)} ${list.length} + ${escapeHtml(categoryLabel(cat))} ${list.length} ▼ `; From f17157c8f03347f7b0e59c02a8faa5db888b12f3 Mon Sep 17 00:00:00 2001 From: MoonEyes <14891700+MoonEyes@users.noreply.github.com> Date: Wed, 2 Dec 2026 12:12:26 +0100 Subject: [PATCH 2/2] studio: model search matches the category name it shows Kal0s-design's check of #3094: the chips and headers now show the catNames of the chosen language, but the model search still matched only the server's category name, so "Vegetation" found nothing in EU while a word of the hidden Russian name did. The search now matches the shown name as well as the server's; a test covers both. Co-Authored-By: Claude Opus 5.5 --- tests/test_viewer_studio.cjs | 19 +++++++++++++++++++ viewer/studio.html | 4 +++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/test_viewer_studio.cjs b/tests/test_viewer_studio.cjs index f938b62c7..413a2c190 100644 --- a/tests/test_viewer_studio.cjs +++ b/tests/test_viewer_studio.cjs @@ -291,6 +291,25 @@ test('category chips and headers show the catNames of the chosen language and ke assert.deepEqual(headers().map(text => text.split(/\s+/)[0]), ['Vehicles']); }); +test('model search matches the category name shown in the chosen language, not only the server name', () => { + const studio = loadStudio(); + studio.context.models = [ + { name: 'tree.glb', folder: 'x', category: 'Растительность (Nature)', size: 4, url: '/models/tree.glb' }, + { name: 'car.glb', folder: 'y', category: 'Транспорт (Vehicles)', size: 4, url: '/models/car.glb' }, + ]; + studio.run(`currentLang = 'eu'; allModels = models; renderAccordionList();`); + const search = query => { + studio.context.query = query; + studio.run(`document.getElementById('model-search').value = query; onModelSearch();`); + return studio.elements.get('model-list').children.map(group => visibleText(group.children[0].innerHTML).trim().split(/\s+/)[0]); + }; + // "Vegetation" is only in the EU label "Vegetation & Nature", not in the server's name. + assert.deepEqual(search('Vegetation'), ['Vegetation']); + // The server's name still matches, in either language. + assert.deepEqual(search('Транспорт'), ['Vehicles']); + assert.deepEqual(search('Nature'), ['Vegetation']); +}); + test('each model category pages independently, including a partial last page', () => { const studio = loadStudio(); studio.context.models = ['Props', 'Vehicles'].flatMap(category => Array.from({ length: 101 }, (_, i) => ({ diff --git a/viewer/studio.html b/viewer/studio.html index 33ce15932..69f14be52 100644 --- a/viewer/studio.html +++ b/viewer/studio.html @@ -983,7 +983,9 @@ function renderAccordionList() { const matchesCat = (activeCategory === 'ALL' || m.category === activeCategory); const matchesSearch = !modelSearchQuery || m.name.toLowerCase().includes(modelSearchQuery) || - (m.category && m.category.toLowerCase().includes(modelSearchQuery)) || + // The category as shown (catNames of the chosen language) and the server's name both match. + (m.category && (m.category.toLowerCase().includes(modelSearchQuery) || + categoryLabel(m.category).toLowerCase().includes(modelSearchQuery))) || (m.folder && m.folder.toLowerCase().includes(modelSearchQuery)); return matchesCat && matchesSearch; });