> For the complete documentation index, see [llms.txt](https://en-ascent.webvista.studio/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://en-ascent.webvista.studio/developer/trim-metafields-shopify-translations.md).

# Trim metafields.shopify translations

Ascent uses Shopify category metafields in places such as the product specification table and the product compare table. Those labels are translated with keys like:

```liquid
{{ 'metafields.shopify.material' | t }}
```

Shopify's taxonomy can generate a very large `metafields.shopify` object in every storefront locale file. You can trim those keys when the store only uses a small set of category metafields.

## What can be trimmed

Only trim keys inside:

```json
{
  "metafields": {
    "shopify": {}
  }
}
```

Do not remove other translation groups unless you have checked where they are used.

Keep a `metafields.shopify` key when any of these are true:

* The store has products with that Shopify category metafield.
* The key is selected in a Product compare table block.
* You are not sure whether a merchant may use it soon.

If a key is removed but the theme still renders `{{ 'metafields.shopify.key' | t }}`, the storefront can show a missing translation label. When in doubt, keep the key.

## Build a keep list

Create a text file with one key per line:

```txt
color
material
size
target-gender
```

Use the exact key after `metafields.shopify.`. For example, keep `material` for `metafields.shopify.material`.

Also include any keys configured in product compare table blocks. In Ascent, compare table blocks can read `product.metafields.shopify[block.settings.key]`.

## Trim all storefront locale files

Save the keep list as `metafields-shopify-keep.txt`, then run this script from the theme root:

```bash
node <<'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
```

## Check the result

After trimming:

* Search the theme for `metafields.shopify.` and confirm the required keys are still in the keep list.
* Preview products that show the specification table.
* Preview pages that use the Product compare table.
* Check each enabled storefront language, especially the default language.

The values displayed for Shopify category metafields come from the product metafield values, such as `value.label`. The locale keys only control the field names shown by the theme.
