function writeToSlingCms()

in i18n-helper/src/index.js [82:118]


function writeToSlingCms() {
  const i18n = {
    "jcr:primaryType": "sling:OrderedFolder",
    "jcr:content": {
      "jcr:title": "Sling CMS",
    },
  };

  for (const language of languages) {
    console.log(`Converting language ${language}...`);
    const translated = require(`../i18n/${language}`);
    const langJson = {
      "jcr:primaryType": "sling:Folder",
      "jcr:mixinTypes": ["mix:language"],
      "jcr:language": language,
      "sling:resourceType": "sling-cms/components/cms/blank",
    };

    const messages = require("./messages");
    for (const message of messages) {
      if (translated[message]) {
        langJson[`msg-${slugify(message, { lower: true }).substring(0, 40)}`] =
          {
            "jcr:primaryType": "sling:MessageEntry",
            "sling:message": translated[message],
            "sling:key": message,
          };
      }
    }
    i18n[language] = langJson;
  }
  console.log("Writing to i18n...");
  fs.writeFileSync(
    "../ui/src/main/resources/jcr_root/libs/sling-cms/i18n.json",
    JSON.stringify(i18n, null, 2)
  );
}