From 148c63c5dd8b91e13fd98a07d5304bdf68f41ca2 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Mon, 26 Apr 2021 06:24:41 -0700 Subject: [PATCH] i18n: define translatable properties in frontmatter schema (#18964) * i18n: define translatable properties in frontmatter schema * mark `product` frontmatter as translatable * lint --- lib/frontmatter.js | 12 ++++++++---- script/fix-translation-errors.js | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/frontmatter.js b/lib/frontmatter.js index fadd7b163363..70562b2e2709 100644 --- a/lib/frontmatter.js +++ b/lib/frontmatter.js @@ -12,16 +12,20 @@ const schema = { properties: { title: { type: 'string', - required: true + required: true, + translatable: true }, shortTitle: { - type: 'string' + type: 'string', + translatable: true }, intro: { - type: 'string' + type: 'string', + translatable: true }, product: { - type: 'string' + type: 'string', + translatable: true }, permissions: { type: 'string' diff --git a/script/fix-translation-errors.js b/script/fix-translation-errors.js index 57e69c1343db..e723a7279fe2 100755 --- a/script/fix-translation-errors.js +++ b/script/fix-translation-errors.js @@ -20,7 +20,9 @@ const yaml = require('js-yaml') const ghesReleaseNotesSchema = require('../lib/release-notes-schema') const revalidator = require('revalidator') -const fixableFmProps = ['type', 'changelog', 'mapTopic', 'hidden', 'layout', 'defaultPlatform', 'showMiniToc', 'allowTitleToDifferFromFilename', 'interactive', 'beta_product'] +const fixableFmProps = Object.keys(fm.schema.properties) + .filter(property => !fm.schema.properties[property].translatable) + .sort() const fixableYmlProps = ['date'] const loadAndValidateContent = async (path, schema) => { @@ -50,6 +52,7 @@ const cmd = 'git diff --name-only origin/main | egrep "^translations/.*/(content const changedFilesRelPaths = execSync(cmd).toString().split('\n') changedFilesRelPaths.forEach(async (relPath) => { + // Skip READMEs if (!relPath || relPath.endsWith('README.md')) return const localisedAbsPath = path.join(__dirname, '..', relPath)