/** * Выгрузка для носителей языка: i18n-review/.csv * key, ru, translation, status, approved * Носитель правит колонку translation и ставит "yes" в approved, затем: pnpm i18n:import <файл>. * * pnpm i18n:export — все языки, только needs_review * pnpm i18n:export -- --all — все ключи */ import { mkdirSync, writeFileSync } from 'node:fs'; import path from 'node:path'; import { csvEscape, readLocale, readReview, ROOT, statusOf, TARGETS } from './lib.ts'; const all = process.argv.includes('--all'); const ru = readLocale('ru'); const review = readReview(); const outDir = path.resolve(ROOT, '../../i18n-review'); mkdirSync(outDir, { recursive: true }); for (const locale of TARGETS) { const msgs = readLocale(locale); const rows = [['key', 'ru', 'translation', 'status', 'approved']]; for (const [key, source] of Object.entries(ru)) { const status = statusOf(review, locale, key, source, msgs[key]); if (!all && status === 'approved') continue; rows.push([key, source, msgs[key] ?? '', status, '']); } const file = path.join(outDir, `${locale}.csv`); // BOM — чтобы Excel открыл UTF-8 с армянским и китайским writeFileSync(file, '' + rows.map((r) => r.map(csvEscape).join(',')).join('\n') + '\n'); console.log(`${file}: ${rows.length - 1} строк`); }