function convertLegacyPhraseToNewShape()

in auto-param-new-string-helper/categorizeNewStrings.js [371:400]


function convertLegacyPhraseToNewShape(legacyPhrase) {
  const {desc} = legacyPhrase;
  const hashToText = legacyPhrase[HASH_TO_TEXT];
  if (desc == null && hashToText == null) {
    return legacyPhrase;
  }

  const hashToLeaf = {};
  for (const hash in hashToText) {
    hashToLeaf[hash] = {
      text: hashToText[hash],
      desc,
    };
  }
  legacyPhrase[HASH_TO_LEAF] = hashToLeaf;

  if (typeof legacyPhrase.jsfbt === 'string') {
    legacyPhrase.jsfbt = {
      t: {
        text: legacyPhrase.jsfbt,
        desc,
      },
      m: [],
    };
  }

  delete legacyPhrase.desc;
  delete legacyPhrase.type;
  return legacyPhrase;
}