From 7e064d5c8b33f788bda2755a32e71e2fb01a00ba Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 9 Oct 2026 10:47:18 -0700 Subject: Translation: a hashtag in a script the reader can't read gets its translation in brackets after it — "#総合部絵チャ (…)" — the tag itself kept as the link it is. A post that is only such hashtags now counts as foreign (it was judged by its prose alone, of which it has none, so nothing ever offered to translate it), and ⋯ → Translate on a post with no words says so instead of "already in your language". The registrar's language detection reads the glossed tags too; lang-guess's scriptOf takes a minimum (a two-character tag has a script too). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vps2H27rhbG9ZqseGfMrc3 --- tools/translate-test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/translate-test.js b/tools/translate-test.js index 2760693..d3fe095 100644 --- a/tools/translate-test.js +++ b/tools/translate-test.js @@ -15,11 +15,13 @@ const now = Math.floor(Date.now() / 1000); const post = (content, ago) => finalizeEvent({ kind: 1, created_at: now - ago, tags: [], content }, AUTHOR.sk); const ES = post('Hola a todos, hoy compré café con bitcoin en el mercado y fue muy fácil para todos los que estaban allí', 100); const JA = post('ビットコインは素晴らしいです。明日また会いましょう。', 200); +const TAG = post('#総合部絵チャ', 250); const EN = post('An ordinary post in English about the weather and the market today', 300); const ANSWERS = { [ES.content]: { text: 'Hello everyone, today I bought coffee with bitcoin at the market and it was very easy for everyone there', source: 'es' }, [JA.content]: { text: 'Bitcoin is great. Let’s meet again tomorrow.', source: 'ja' }, [EN.content]: { text: EN.content, source: 'en' }, + [TAG.content]: { text: '#総合部絵チャ (general art chat)', source: 'ja' }, }; const html = await buildHtml({ minify: true, pwa: false }); @@ -78,7 +80,7 @@ try { localStorage.setItem(k + ':feedNotes', JSON.stringify(ns)); localStorage.setItem(k + ':profiles', JSON.stringify({ [pk]: { name: 'Globetrotter', t: Date.now() } })); localStorage.setItem('btc-wallet-feed:' + k, 'following'); - }, [base, AUTHOR.pk, [ES, JA, EN]]); + }, [base, AUTHOR.pk, [ES, JA, TAG, EN]]); await page.reload({ waitUntil: 'domcontentloaded' }); await waitText('receive', 20000); await openFeed(); @@ -87,8 +89,9 @@ try { check('the Spanish post is shown in English', await waitText('today I bought coffee with bitcoin', 10000) && !(await has('compré café'))); check('...saying where it came from', /Translated from Spanish/.test(await row('today I bought coffee') || ''), (await row('today I bought coffee') || '').split('\n').slice(-6).join(' | ')); check('the Japanese post too', await waitText('Bitcoin is great', 5000) && /Translated from Japanese/.test(await row('Bitcoin is great') || '')); + check('a post that is only a Japanese hashtag gets its tag glossed, the tag kept', await waitText('#総合部絵チャ (general art chat)', 5000)); const asked = await page.evaluate(() => window.__tr.map((b) => b.text.slice(0, 12) + '>' + b.target)); - check('the English post is left alone (never sent)', asked.length === 2 && !asked.some((x) => x.startsWith('An ordinary')), asked.join(', ')); + check('the English post is left alone (never sent)', asked.length === 3 && !asked.some((x) => x.startsWith('An ordinary')), asked.join(', ')); await page.evaluate(() => { const r = [...document.querySelectorAll('[data-zap-post]')].find((n) => n.textContent.includes('today I bought coffee')); [...r.querySelectorAll('.note-translate-btn')].find((b) => /original/i.test(b.textContent)).click(); }); await sleep(400); check('Show original brings the Spanish back', await has('compré café') && !(await has('today I bought coffee'))); -- cgit v1.2.3