Skip to content

Commit

Permalink
i18n: define translatable properties in frontmatter schema (github#18964
Browse files Browse the repository at this point in the history
)

* i18n: define translatable properties in frontmatter schema

* mark `product` frontmatter as translatable

* lint
  • Loading branch information
zeke authored Apr 26, 2021
1 parent 53a262a commit 148c63c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/frontmatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 4 additions & 1 deletion script/fix-translation-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 148c63c

Please sign in to comment.