Trim metafields.shopify translations
Last updated
color
material
size
target-gendernode <<'NODE'
const fs = require("fs");
const path = require("path");
const keep = new Set(
fs.readFileSync("metafields-shopify-keep.txt", "utf8")
.split(/\r?\n/)
.map((line) => line.trim())
.filter(Boolean)
);
for (const file of fs.readdirSync("locales")) {
if (!file.endsWith(".json") || file.endsWith(".schema.json")) continue;
const filePath = path.join("locales", file);
const json = JSON.parse(fs.readFileSync(filePath, "utf8"));
const source = json.metafields?.shopify;
if (!source || typeof source !== "object" || Array.isArray(source)) continue;
const trimmed = {};
for (const key of Object.keys(source)) {
if (keep.has(key)) trimmed[key] = source[key];
}
json.metafields.shopify = trimmed;
fs.writeFileSync(filePath, `${JSON.stringify(json, null, 2)}\n`);
console.log(`${file}: kept ${Object.keys(trimmed).length} of ${Object.keys(source).length}`);
}
NODE