function injectTraceEngineStrings() {
  const traceEngineStringsDir = `${LH_ROOT}/node_modules/@paulirish/trace_engine/locales`;
  const lhStringsDir = `${LH_ROOT}/shared/localization/locales`;
  for (const file of glob.sync(`${lhStringsDir}/*.json`)) {
    let name = path.basename(file);
    if (name.endsWith('.ctc.json')) {
      continue;
    }

    if (name === 'ar-XB.json') {
      name = 'ar.json';
    }

    if (['en-XA.json'].includes(name)) {
      continue;
    }

    const traceEnginePath = `${traceEngineStringsDir}/${name}`;
    if (!fs.existsSync(traceEnginePath)) {
      throw new Error(`expected locale file to exist: ${traceEnginePath}`);
    }

    const traceEngineStrings = JSON.parse(fs.readFileSync(traceEnginePath, 'utf-8'));
    const strings = JSON.parse(fs.readFileSync(file, 'utf-8'));
    for (const [key, value] of Object.entries(traceEngineStrings)) {
      const lhKey = `node_modules/@paulirish/trace_engine/${key.replace('.ts', '.js')}`;

      // TODO: why is this so malformed? see b/399706272
      if (['he.json', 'ru.json', 'ta.json'].includes(name) && lhKey === 'node_modules/@paulirish/trace_engine/generated/Deprecation.js | ObsoleteCreateImageBitmapImageOrientationNone') {
        continue;
      }

      value.message = value.message
        .replace(/\\\\/g, '')
        .replace(`{imageOrientation: 'from-image'}`, `\\\\{imageOrientation: 'from-image'\\\\}`)
        .replace(`{imageOrientation: ''from-image''}`, `\\\\{imageOrientation: ''from-image''\\\\}`)
        .replace(`{imageOrientation: "from-image"}`, `\\\\{imageOrientation: "from-image"\\\\}`)
        .replace(`{imageOrientation: 'from-image'\\}`, `\\\\{imageOrientation: 'from-image'\\\\}`);
      strings[lhKey] = value;
    }

    fs.writeFileSync(file, JSON.stringify(sortObject(strings), null, 2) + '\n');
  }
}
Inject translated strings from `node_modules/@paulirish/trace_engine`. This avoids Lighthouse
re-translating these same strings.