aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-09 10:47:18 -0700
committerAdam Soltys <[email protected]>2026-10-09 10:47:18 -0700
commit7e064d5c8b33f788bda2755a32e71e2fb01a00ba (patch)
tree66a3b32f07a98b5646ffc9b662362bc912eb7553 /tools
parent41d7b9d4e5d0e10cdac708d9c9cd4838e47240ec (diff)
downloadcoinosv3-7e064d5c8b33f788bda2755a32e71e2fb01a00ba.tar.gz
coinosv3-7e064d5c8b33f788bda2755a32e71e2fb01a00ba.zip
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).
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vps2H27rhbG9ZqseGfMrc3
Diffstat (limited to 'tools')
-rw-r--r--tools/translate-test.js7
1 files changed, 5 insertions, 2 deletions
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')));