Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Generate pseudo-locale files for visual QA testing.
|
|
*
|
|
* Reads every English translation JSON file and produces matching files
|
|
* for the xx and yy pseudo-locales with all leaf values replaced by a
|
|
* fill string. {{interpolation}} tokens are preserved so i18next can
|
|
* still substitute variables at runtime.
|
|
*
|
|
* Usage:
|
|
* node scripts/generate-pseudo-locales.js
|
|
*
|
|
* Re-run after adding or changing any English namespace file.
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const LOCALES_DIR = path.resolve(__dirname, '../server/public/locales');
|
|
const EN_DIR = path.join(LOCALES_DIR, 'en');
|
|
|
|
const PSEUDO_LOCALES = {
|
|
xx: '11111',
|
|
yy: '55555',
|
|
};
|
|
|
|
function replaceValues(obj, fill) {
|
|
const out = {};
|
|
for (const [key, value] of Object.entries(obj)) {
|
|
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
out[key] = replaceValues(value, fill);
|
|
} else if (typeof value === 'string') {
|
|
// Preserve {{variable}} tokens
|
|
const vars = value.match(/\{\{.*?\}\}/g);
|
|
if (vars) {
|
|
out[key] = vars.map((v) => `${fill} ${v}`).join(' ') + ` ${fill}`;
|
|
} else {
|
|
out[key] = fill;
|
|
}
|
|
} else {
|
|
out[key] = value;
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
|
|
function walkDir(dir) {
|
|
const results = [];
|
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
const full = path.join(dir, entry.name);
|
|
if (entry.isDirectory()) {
|
|
results.push(...walkDir(full));
|
|
} else if (entry.name.endsWith('.json')) {
|
|
results.push(full);
|
|
}
|
|
}
|
|
return results;
|
|
}
|
|
|
|
const enFiles = walkDir(EN_DIR);
|
|
let totalFiles = 0;
|
|
|
|
for (const enFile of enFiles) {
|
|
const rel = path.relative(EN_DIR, enFile);
|
|
const data = JSON.parse(fs.readFileSync(enFile, 'utf8'));
|
|
|
|
for (const [locale, fill] of Object.entries(PSEUDO_LOCALES)) {
|
|
const outFile = path.join(LOCALES_DIR, locale, rel);
|
|
fs.mkdirSync(path.dirname(outFile), { recursive: true });
|
|
const pseudo = replaceValues(data, fill);
|
|
fs.writeFileSync(outFile, JSON.stringify(pseudo, null, 2) + '\n', 'utf8');
|
|
totalFiles++;
|
|
}
|
|
}
|
|
|
|
console.log(`Generated ${totalFiles} pseudo-locale files from ${enFiles.length} English sources.`);
|