From 95d02d7eef2bde648f57d99b6f9e78eb5e4c680b Mon Sep 17 00:00:00 2001 From: Rachael Sewell Date: Wed, 3 Nov 2021 10:28:32 -0700 Subject: [PATCH] group translations scripts together (#22232) --- script/README.md | 10 +++++----- script/{ => i18n}/fix-translation-errors.js | 6 +++--- script/{ => i18n}/lint-translation-files.js | 6 +++--- .../reset-known-broken-translation-files.js | 6 +++--- script/{ => i18n}/reset-translated-file.js | 4 ++-- script/{ => i18n}/test-render-translation.js | 12 ++++++------ script/{ => i18n}/update-crowdin-issue.js | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) rename script/{ => i18n}/fix-translation-errors.js (94%) rename script/{ => i18n}/lint-translation-files.js (82%) rename script/{ => i18n}/reset-known-broken-translation-files.js (88%) rename script/{ => i18n}/reset-translated-file.js (94%) rename script/{ => i18n}/test-render-translation.js (89%) rename script/{ => i18n}/update-crowdin-issue.js (98%) diff --git a/script/README.md b/script/README.md index ba2d3e6a4620..8c77a127b6e7 100644 --- a/script/README.md +++ b/script/README.md @@ -394,17 +394,17 @@ This is a convenience script for replacing the contents of translated files with It's intended to be a workaround to temporarily bypass Crowdin parser bugs while we wait for translators to fix them. -Usage: script/reset-translated-file.js +Usage: script/i18n/reset-translated-file.js Examples: -reset a single translated file using a relative path: $ script/reset-translated-file.js translations/es-XL/content/actions/index.md +reset a single translated file using a relative path: $ script/i18n/reset-translated-file.js translations/es-XL/content/actions/index.md -reset a single translated file using a full path: $ script/reset-translated-file.js /Users/z/git/github/docs-internal/translations/es-XL/content/actions/index.md +reset a single translated file using a full path: $ script/i18n/reset-translated-file.js /Users/z/git/github/docs-internal/translations/es-XL/content/actions/index.md -reset all language variants of a single English file (using a relative path): $ script/reset-translated-file.js content/actions/index.md $ script/reset-translated-file.js data/ui.yml +reset all language variants of a single English file (using a relative path): $ script/i18n/reset-translated-file.js content/actions/index.md $ script/i18n/reset-translated-file.js data/ui.yml -reset all language variants of a single English file (using a full path): $ script/reset-translated-file.js /Users/z/git/github/docs-internal/content/desktop/index.md $ script/reset-translated-file.js /Users/z/git/github/docs-internal/data/ui.yml +reset all language variants of a single English file (using a full path): $ script/i18n/reset-translated-file.js /Users/z/git/github/docs-internal/content/desktop/index.md $ script/i18n/reset-translated-file.js /Users/z/git/github/docs-internal/data/ui.yml --- diff --git a/script/fix-translation-errors.js b/script/i18n/fix-translation-errors.js similarity index 94% rename from script/fix-translation-errors.js rename to script/i18n/fix-translation-errors.js index 7d1c4f1e03a9..9e34268399cb 100755 --- a/script/fix-translation-errors.js +++ b/script/i18n/fix-translation-errors.js @@ -13,12 +13,12 @@ import path from 'path' import { execSync } from 'child_process' import { get, set } from 'lodash-es' import fs from 'fs' -import readFileAsync from '../lib/readfile-async.js' -import fm from '../lib/frontmatter.js' +import readFileAsync from '../../lib/readfile-async.js' +import fm from '../../lib/frontmatter.js' import matter from 'gray-matter' import chalk from 'chalk' import yaml from 'js-yaml' -import ghesReleaseNotesSchema from '../tests/helpers/schemas/ghes-release-notes-schema.js' +import ghesReleaseNotesSchema from '../../tests/helpers/schemas/ghes-release-notes-schema.js' import revalidator from 'revalidator' const __dirname = path.dirname(fileURLToPath(import.meta.url)) diff --git a/script/lint-translation-files.js b/script/i18n/lint-translation-files.js similarity index 82% rename from script/lint-translation-files.js rename to script/i18n/lint-translation-files.js index 996e015d48c7..651be7ce384c 100755 --- a/script/lint-translation-files.js +++ b/script/i18n/lint-translation-files.js @@ -3,7 +3,7 @@ // [start-readme] // // Use this script as part of the Crowdin merge process to output a list of parsing and rendering -// errors in translated files and run script/reset-translated-file.js on them. +// errors in translated files and run script/i18n/reset-translated-file.js on them. // // [end-readme] @@ -23,7 +23,7 @@ try { // 2. Check for rendering errors and output to file. Note this one must be run SECOND. console.log('Checking for rendering errors...') try { - execSync(`script/test-render-translation.js > ${renderErrorsLog}`) + execSync(`script/i18n/test-render-translation.js > ${renderErrorsLog}`) } catch (error) { console.log('There were new rendering errors!') } @@ -31,7 +31,7 @@ try { // Reset the broken files. console.log('Resetting broken files...') execSync( - `cat ${parsingErrorsLog} ${renderErrorsLog} | egrep "^translations/.*/(.+.md|.+.yml)$" | uniq | xargs -L1 script/reset-translated-file.js --prefer-main` + `cat ${parsingErrorsLog} ${renderErrorsLog} | egrep "^translations/.*/(.+.md|.+.yml)$" | uniq | xargs -L1 script/i18n/reset-translated-file.js --prefer-main` ) // Print a message with next steps. diff --git a/script/reset-known-broken-translation-files.js b/script/i18n/reset-known-broken-translation-files.js similarity index 88% rename from script/reset-known-broken-translation-files.js rename to script/i18n/reset-known-broken-translation-files.js index 7607e76dcf2a..c8e3c1b4431d 100755 --- a/script/reset-known-broken-translation-files.js +++ b/script/i18n/reset-known-broken-translation-files.js @@ -3,12 +3,12 @@ // [start-readme] // // Use this script as part of the Crowdin merge process to get the list of known broken -// files and run script/reset-translated-file.js on them. +// files and run script/i18n/reset-translated-file.js on them. // // [end-readme] import dotenv from 'dotenv' -import Github from './helpers/github.js' +import Github from '../helpers/github.js' import { promisify } from 'util' import ChildProcess from 'child_process' @@ -44,7 +44,7 @@ async function main() { await Promise.all( brokenFilesArray.map(async (file) => { console.log(`resetting ${file}`) - await exec(`script/reset-translated-file.js --prefer-main ${file}`) + await exec(`script/i18n/reset-translated-file.js --prefer-main ${file}`) }) ) diff --git a/script/reset-translated-file.js b/script/i18n/reset-translated-file.js similarity index 94% rename from script/reset-translated-file.js rename to script/i18n/reset-translated-file.js index fdb3ac4c5b59..5302c013ce53 100755 --- a/script/reset-translated-file.js +++ b/script/i18n/reset-translated-file.js @@ -9,11 +9,11 @@ // while we wait for translators to fix them. // // Usage: -// script/reset-translated-file.js +// script/i18n/reset-translated-file.js // // Examples: // -// $ script/reset-translated-file.js translations/es-XL/content/actions/index.md +// $ script/i18n/reset-translated-file.js translations/es-XL/content/actions/index.md // // [end-readme] diff --git a/script/test-render-translation.js b/script/i18n/test-render-translation.js similarity index 89% rename from script/test-render-translation.js rename to script/i18n/test-render-translation.js index 02dc5bb5fdbd..d662b0183db6 100755 --- a/script/test-render-translation.js +++ b/script/i18n/test-render-translation.js @@ -8,14 +8,14 @@ import { fileURLToPath } from 'url' import path from 'path' -import renderContent from '../lib/render-content/index.js' -import loadSiteData from '../lib/site-data.js' -import { loadPages } from '../lib/page-data.js' -import languages from '../lib/languages.js' +import renderContent from '../../lib/render-content/index.js' +import loadSiteData from '../../lib/site-data.js' +import { loadPages } from '../../lib/page-data.js' +import languages from '../../lib/languages.js' import { promisify } from 'util' import ChildProcess, { execSync } from 'child_process' import fs from 'fs' -import frontmatter from '../lib/frontmatter.js' +import frontmatter from '../../lib/frontmatter.js' import chalk from 'chalk' import { YAMLException } from 'js-yaml' @@ -91,7 +91,7 @@ async function loadAndPatchSiteData(filesWithKnownIssues = {}) { // Reset the file console.warn(`resetting file "${relPath}" due to loadSiteData error: ${error.toString()}`) - await exec(`script/reset-translated-file.js --prefer-main ${relPath}`) + await exec(`script/i18n/reset-translated-file.js --prefer-main ${relPath}`) // Try to load the site data again return loadAndPatchSiteData(filesWithKnownIssues) diff --git a/script/update-crowdin-issue.js b/script/i18n/update-crowdin-issue.js similarity index 98% rename from script/update-crowdin-issue.js rename to script/i18n/update-crowdin-issue.js index 5f335e6584d0..b0da7142c72c 100755 --- a/script/update-crowdin-issue.js +++ b/script/i18n/update-crowdin-issue.js @@ -9,7 +9,7 @@ // [end-readme] import dotenv from 'dotenv' -import Github from './helpers/github.js' +import Github from '../helpers/github.js' import { execSync } from 'child_process' dotenv.config()