diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 010bac2f33..be1fa89783 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -203,6 +203,23 @@ jobs: # Falure won't fail the job (remove -x when all current issues are fixed) ./scripts/check-i18n -s -x + check-i18n-links: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + - uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + + - name: Install packages + run: yarn install:ci + + - name: Run check of all http links in the i18n files (broken lnk check) + run: | + # Falure won't fail the job (remove -x when all current issues are fixed) + ./scripts/check-i18n-links -x # coverage: # runs-on: ubuntu-latest diff --git a/scripts/check-i18n-links b/scripts/check-i18n-links index b3a8062524..c070e58684 100755 --- a/scripts/check-i18n-links +++ b/scripts/check-i18n-links @@ -23,9 +23,7 @@ const pkgFolder = path.resolve(base, 'pkg'); const reset = "\x1b[0m"; const cyan = `\x1b[96m`; const yellow = `\x1b[33m`; -const white = `\x1b[97m`; const bold = `\x1b[1m`; -const bg_red = `\x1b[41m`; const DOCS_BASE_REGEX = /export const DOCS_BASE = '([^']*)';/; @@ -46,9 +44,7 @@ const CATEGORIES = [ let docsBaseUrl = ''; -// -s flag will show the details of all of the unused strings // -x flag will cause script to return 0, even if there are errors -let showUnused = false; let doNotReturnError = false; // Simple arg parsing @@ -57,9 +53,7 @@ if (process.argv.length > 2) { process.argv.shift(); process.argv.forEach((arg) => { - if (arg === '-s') { - showUnused = true; - } else if (arg === '-x') { + if (arg === '-x') { doNotReturnError = true; } }); @@ -73,52 +67,6 @@ if (docsBaseFileMatches && docsBaseFileMatches.length === 2) { docsBaseUrl = docsBaseFileMatches[1]; } -function parseReference(ref) { - if (!ref.includes('$') || ref.startsWith('${')) { - return ref; - } - - let out = ''; - let inVar = false; - let variable = ''; - let vars = 0; - - for (let i=0;i o.trim().replaceAll('\'', '')); - - if (opts.length === 2) { - const a = p.map((o) => o === '$' ? opts[0] : o).join('.'); - const b = p.map((o) => o === '$' ? opts[1] : o).join('.'); - - return [a, b]; - } - } - - p = p.map((a) => a.startsWith('$') ? `.*${ a.substr(1) }` : a); - - return new RegExp(p.join('\\.'), 'g'); -} - function readAndParseTranslations(filePath) { const data = fs.readFileSync(filePath, 'utf8'); @@ -182,30 +130,6 @@ function parseLinks(str) { return links; } -function makeRegex(str) { - if (str.startsWith('/') && str.endsWith('/')) { - return new RegExp(str.substr(1, str.length - 2), 'g'); - } else { - // String - // Support .* for a simple wildcard match - if (str.includes('*')) { - const parts = str.split('.'); - const p = parts.map((s, i) => s === '*' ? (i === parts.length -1 ? '.*' : '[^\.]*') : s); - - return new RegExp(`^${ p.join('\\.') }$`); - } else { - return str; - } - } -} - -function doesMatch(stringOrRegex, str) { - if (typeof stringOrRegex === 'string') { - return str === stringOrRegex; - } else { - return str.match(stringOrRegex); - } -} function loadI18nFiles(folder) { let res = {}; @@ -247,11 +171,6 @@ i18n = { ...i18n, ...loadI18nFiles(pkgFolder) }; console.log(`Read ${cyan}${ Object.keys(i18n).length }${reset} translations`); // eslint-disable-line no-console -//..console.log(`Found ${cyan}${ Object.keys(references).length }${reset} i18n references in code`); // eslint-disable-line no-console - -let unused = 0; -const unusedKeys = []; - const links = []; // Look for translations that are not used @@ -291,7 +210,7 @@ function showByCategory(linksToShow, prefixLabel, otherLabel, color) { }); CATEGORIES.forEach((category) => { - if (byCategory[category.name].length) { + if (byCategory[category.name]?.length) { console.log(`${color}${prefixLabel} ${category.name}${reset}`); // eslint-disable-line no-console byCategory[category.name].forEach((link) => console.log(` ${link}`)); // eslint-disable-line no-console } @@ -304,7 +223,7 @@ function showByCategory(linksToShow, prefixLabel, otherLabel, color) { } async function check(links) { - const badLinks = []; + const brokenLinks = []; for(let i =0; i 0) { + process.exit(1); + } } console.log(`${cyan}Checking doc links ...${reset}`); // eslint-disable-line no-console diff --git a/shell/assets/translations/en-us.yaml b/shell/assets/translations/en-us.yaml index cf1460d099..258d698b4e 100644 --- a/shell/assets/translations/en-us.yaml +++ b/shell/assets/translations/en-us.yaml @@ -438,7 +438,7 @@ authConfig: 5: 'Upload the downloaded JSON file in the OAuth credentials box.' 3: title: 'Create Service Account credentials' - introduction: 'Follow this guide to:' + introduction: 'Follow this guide to:' body: 1: Create a service account. 2: Generate a key for the service account. @@ -1134,7 +1134,7 @@ cis: alertNeeded: |- Alerting must be enabled within the CIS chart values.yaml. This requires that the {vendor} Monitoring and Alerting app is installed - and the Receivers and Routes are configured to send out alerts. + and the Receivers and Routes are configured to send out alerts. alertOnComplete: Alert on scan completion alertOnFailure: Alert on scan failure benchmarkVersion: Benchmark Version @@ -3484,7 +3484,7 @@ monitoring: keyFilePath: label: Key File Path placeholder: e.g. ./key-file.pfx - secretsBanner: The file paths below must be referenced in
alertmanager.alertmanagerSpec.secrets
when deploying the Monitoring chart. For more information see our documentation. + secretsBanner: The file paths below must be referenced in
alertmanager.alertmanagerSpec.secrets
when deploying the Monitoring chart. For more information see our documentation. projectMonitoring: detail: error: "Unable to fetch Dashboard values with status: " diff --git a/shell/assets/translations/zh-hans.yaml b/shell/assets/translations/zh-hans.yaml index 5624e82078..d78f4f491b 100644 --- a/shell/assets/translations/zh-hans.yaml +++ b/shell/assets/translations/zh-hans.yaml @@ -429,7 +429,7 @@ authConfig: 5: '在 OAuth 凭证框中,上传下载的 JSON 文件。' 3: title: '创建 Service Account 凭证' - introduction: '参照本指南:' + introduction: '参照本指南:' body: 1: 创建一个 Service Account。 2: 为这个 Service Account 生成密钥。 @@ -1049,7 +1049,7 @@ cis: alertNeeded: |- 必须在 CIS Chart values.yaml 中开启告警。 这要求 {vendor} 的 Monitoring 与 Alerting 应用已经安装 - ,而且接收器和路由已配置告警发送。 + ,而且接收器和路由已配置告警发送。 alertOnComplete: 扫描完成告警 alertOnFailure: 扫描失败告警 benchmarkVersion: Benchmark 版本 @@ -3235,7 +3235,7 @@ monitoring: keyFilePath: label: 密钥文件路径 placeholder: 例如:./key-file.pfx - secretsBanner: 部署 Monitoring Chart 时,必须在<
alertmanager.alertmanagerSpec.secrets
中引用以下文件路径。详情请查看官方文档。 + secretsBanner: 部署 Monitoring Chart 时,必须在<
alertmanager.alertmanagerSpec.secrets
中引用以下文件路径。详情请查看官方文档。 projectMonitoring: detail: error: "无法获取具有状态的仪表板值: "