Tweaks to Fluent/Transifex JSON processing scripts (#3058)

- Use locale directories for JSON files, since that's where the
  Transifex client will interact with them
- Skip non-locale directories (e.g., don't create an .ftl file for
  .DS_Store)
- Other minor simplification
This commit is contained in:
Dan Stillman 2023-04-13 01:22:29 -04:00 committed by Dan Stillman
parent afaf0b4968
commit 0de1305665
2 changed files with 26 additions and 28 deletions

View file

@ -5,16 +5,15 @@ import { fileURLToPath } from 'url';
import { onError, onSuccess } from './utils.js';
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
const JSONDir = join(ROOT, 'tmp', 'tx');
async function getJSON() {
const t1 = performance.now();
await fs.mkdirp(JSONDir);
const sourcefile = join(ROOT, 'chrome', 'locale', 'en-US', 'zotero', 'zotero.ftl');
const destFile = join(JSONDir, 'zotero_en_US.json');
const ftl = await fs.readFile(sourcefile, 'utf8');
const sourceDir = join(ROOT, 'chrome', 'locale', 'en-US', 'zotero');
const sourceFile = join(sourceDir, 'zotero.ftl');
const destFile = join(sourceDir, 'zotero.json');
const ftl = await fs.readFile(sourceFile, 'utf8');
const json = ftlToJSON(ftl, { transformTerms: false, storeTermsInJSON: false });
await fs.outputJSON(destFile, json);
await fs.outputJSON(destFile, json, { spaces: '\t' });
const t2 = performance.now();
return ({
action: 'ftl->json',