From 46496ee27724c0ec227e38d97dfbe82c9895942a Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 18 Oct 2022 18:53:40 +0200 Subject: [PATCH 1/2] github/github link checker issue with particular link (#31814) --- script/check-github-github-links.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/script/check-github-github-links.js b/script/check-github-github-links.js index 54bd1d1b7585..e49f729ab127 100755 --- a/script/check-github-github-links.js +++ b/script/check-github-github-links.js @@ -112,7 +112,10 @@ async function main() { (contents.substring(numIndex, numIndex + 11) === 'GitHub.help' && contents.charAt(numIndex + 16) === '#') || (contents.substring(numIndex, numIndex + 16) === 'GitHub.developer' && - contents.charAt(numIndex + 26) === '#') + contents.charAt(numIndex + 26) === '#') || + // See internal issue #2180 + contents.slice(numIndex, numIndex + 'GitHub.help_url}/github/#{'.length) === + 'GitHub.help_url}/github/#{' ) { return } From b1610289b22db13abb94312c3a6a2fe34c053f2b Mon Sep 17 00:00:00 2001 From: Hector Alfaro Date: Tue, 18 Oct 2022 12:59:59 -0400 Subject: [PATCH 2/2] Add a translation root (#31822) Co-authored-by: Kevin Heis Co-authored-by: Peter Bengtsson --- lib/constants.js | 1 + lib/languages.js | 11 +++++++---- lib/page-data.js | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/constants.js b/lib/constants.js index 1c4e6fed6201..e82f0d9e14a1 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -1 +1,2 @@ export const PREFERRED_LOCALE_COOKIE_NAME = 'preferredlang' +export const TRANSLATIONS_ROOT = process.env.TRANSLATIONS_ROOT || 'translations' diff --git a/lib/languages.js b/lib/languages.js index 9b9fbeed3179..93122e7405a0 100644 --- a/lib/languages.js +++ b/lib/languages.js @@ -1,5 +1,8 @@ // see also languages-schema.js +import { TRANSLATIONS_ROOT } from './constants.js' +import path from 'path' + const languages = { en: { name: 'English', @@ -13,7 +16,7 @@ const languages = { code: 'cn', hreflang: 'zh-Hans', redirectPatterns: [/^\/zh-\w{2}/, /^\/zh/], - dir: 'translations/zh-CN', + dir: path.join(TRANSLATIONS_ROOT, 'zh-CN'), }, ja: { name: 'Japanese', @@ -21,21 +24,21 @@ const languages = { code: 'ja', hreflang: 'ja', redirectPatterns: [/^\/jp/], - dir: 'translations/ja-JP', + dir: path.join(TRANSLATIONS_ROOT, 'ja-JP'), }, es: { name: 'Spanish', nativeName: 'Español', code: 'es', hreflang: 'es', - dir: 'translations/es-ES', + dir: path.join(TRANSLATIONS_ROOT, 'es-ES'), }, pt: { name: 'Portuguese', nativeName: 'Português do Brasil', code: 'pt', hreflang: 'pt', - dir: 'translations/pt-BR', + dir: path.join(TRANSLATIONS_ROOT, 'pt-BR'), }, } diff --git a/lib/page-data.js b/lib/page-data.js index 4b3775850711..e6b141c873d2 100644 --- a/lib/page-data.js +++ b/lib/page-data.js @@ -222,7 +222,7 @@ export async function correctTranslationOrphans(pageList, basePath = null) { // Filter out all non-English pages that appear to be excess. // E.g. if an English doc was renamed from `content/foo.md` to - // `content/bar.md` what will happen is that `translations/*/content/foo.md` + // `content/bar.md` what will happen is that `TRANSLATIONS_ROOT/*/content/foo.md` // will still linger around and we want to remove that even if it was // scooped up from disk. const newPageList = [] @@ -263,7 +263,7 @@ export async function correctTranslationOrphans(pageList, basePath = null) { // to create them for this language. But the trick is that we // use the English relative path so it can have something to read. // For example, if we have figured out that - // `translations/ja-JP/content/foo.md` doesn't exist, we pretend + // `TRANSLATIONS_ROOT/ja-JP/content/foo.md` doesn't exist, we pretend // that we can use `foo.md` and the base path of `content/`. pageLoadPromises.push( Page.init({