From c6f1be01125ef8b52eb29552b4040983f51fcc7b Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Wed, 10 Sep 2025 08:52:21 -0700 Subject: [PATCH 01/19] Add Vale locale-specific linting framework for translated documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit establishes a Vale testing framework specifically for translated documentation in the doc-locale directory, separate from the existing English documentation linting. Changes include: - Add locale_rules Vale style with ReferenceQuotationRemoval rule to detect Japanese quotation marks around links (「[text](link)」) - Create dedicated Vale configuration (.vale.ini) for localized docs - Add custom Vale output templates (vale.tmpl, vale-json.tmpl) for consistent formatting with existing tooling - Extend i18n_lint_doc.sh script to run locale-specific Vale rules alongside existing global Vale checks The new framework allows for language-specific documentation quality checks that differ from English requirements, starting with Japanese quotation mark detection around reference links. Relates to https://gitlab.com/gitlab-com/localization/docs-site-localization/-/issues/338 --- doc-locale/.vale.ini | 14 ++++++ .../ReferenceQuotationRemoval.yml | 11 +++++ doc-locale/.vale/vale-json.tmpl | 43 +++++++++++++++++ doc-locale/.vale/vale.tmpl | 48 +++++++++++++++++++ scripts/i18n_lint_doc.sh | 4 +- 5 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 doc-locale/.vale.ini create mode 100644 doc-locale/.vale/locale_rules/ReferenceQuotationRemoval.yml create mode 100644 doc-locale/.vale/vale-json.tmpl create mode 100644 doc-locale/.vale/vale.tmpl diff --git a/doc-locale/.vale.ini b/doc-locale/.vale.ini new file mode 100644 index 00000000000000..2e46c325ecd392 --- /dev/null +++ b/doc-locale/.vale.ini @@ -0,0 +1,14 @@ +# Vale configuration file for localized documentation. +# +# For more information, see https://vale.sh/docs/vale-ini. + +StylesPath = .vale +MinAlertLevel = suggestion + +IgnoredScopes = code, text.frontmatter.redirect_to + +[*.md] +BasedOnStyles = locale_rules + +# Ignore SVG markup +TokenIgnores = (\*\*\{\w*\}\*\*) diff --git a/doc-locale/.vale/locale_rules/ReferenceQuotationRemoval.yml b/doc-locale/.vale/locale_rules/ReferenceQuotationRemoval.yml new file mode 100644 index 00000000000000..56ba99f3c636c6 --- /dev/null +++ b/doc-locale/.vale/locale_rules/ReferenceQuotationRemoval.yml @@ -0,0 +1,11 @@ +--- +name: locale_rules.ReferenceQuotationRemoval +description: | + Remove quotation marks around reference links +extends: existence +message: "Check for quotation marks around reference links at '%s'" +level: warning +nonword: true +scope: raw +tokens: + - '「[^」]+」' diff --git a/doc-locale/.vale/vale-json.tmpl b/doc-locale/.vale/vale-json.tmpl new file mode 100644 index 00000000000000..bbcb7fc171d08d --- /dev/null +++ b/doc-locale/.vale/vale-json.tmpl @@ -0,0 +1,43 @@ +{{- /* Modify Vale's output https://vale.sh/manual/output/ */ -}} + +{{- $fileIndexes := len .Files -}} +{{- $fileIndexes = sub $fileIndexes 1 -}} + +[ + {{- /* Range over the linted files */ -}} + {{- range $idx1, $a := .Files -}} + {{- $path := .Path -}} + + {{/* Range over the file's alerts */}} + {{- range $idx2, $b := .Alerts -}} + {{- $error := "info" -}} + {{- if eq .Severity "error" -}} + {{- $error = "blocker" -}} + {{- else if eq .Severity "warning" -}} + {{- $error = "major" -}} + {{- end}} + + {{- /* Variables setup */ -}} + {{- $loc := printf "%d" .Line -}} + {{- $message := printf "%s" .Message -}} + {{- $moreinfo := "" -}} + {{- if .Link -}} + {{- $moreinfo = printf " See %s" .Link -}} + {{- end -}} + {{- if $idx2 -}},{{- end -}} + + {{/* Output */}} + { + "description": "{{ $message }}{{ $moreinfo }}", + "fingerprint": "{{ $path }}-{{ $loc }}", + "severity": "{{ $error }}", + "location": { + "path": "{{ $path }}", + "lines": { + "begin": {{ $loc }} + } + } + } + {{- end}}{{- if (lt $idx1 $fileIndexes) -}},{{- end -}} + {{- end}} +] diff --git a/doc-locale/.vale/vale.tmpl b/doc-locale/.vale/vale.tmpl new file mode 100644 index 00000000000000..3fe958023b9f28 --- /dev/null +++ b/doc-locale/.vale/vale.tmpl @@ -0,0 +1,48 @@ +{{- /* Modify Vale's output https://docs.errata.ai/vale/cli#--output */ -}} + +{{- /* Keep track of our various counts */ -}} + +{{- $e := 0 -}} +{{- $w := 0 -}} +{{- $s := 0 -}} + +{{- /* Range over the linted files */ -}} + +{{- range .Files}} +{{- $path := .Path | underline -}} + +{{- /* Range over the file's alerts */ -}} + +{{- range .Alerts -}} + +{{- $error := "" -}} +{{- if eq .Severity "error" -}} + {{- $error = .Severity | red -}} + {{- $e = add1 $e -}} +{{- else if eq .Severity "warning" -}} + {{- $error = .Severity | yellow -}} + {{- $w = add1 $w -}} +{{- else -}} + {{- $error = .Severity | blue -}} + {{- $s = add1 $s -}} +{{- end}} + +{{- /* Variables setup */ -}} + +{{- $path = $path -}} +{{- $loc := printf "Line %d, position %d" .Line (index .Span 0) -}} +{{- $check := printf "%s" .Check -}} +{{- $message := printf "%s" .Message -}} +{{- $link := printf "%s" .Link -}} + +{{- /* Output */ -}} + +{{ $path }}: + {{ $loc }} (rule {{ $check }}) + {{ $error }}: {{ $message }} + More information: {{ $link }} + +{{end -}} +{{end -}} + +{{- $e}} {{"errors" | red}}, {{$w}} {{"warnings" | yellow}}, and {{$s}} {{"suggestions" | blue}} found in {{.LintedTotal}} {{.LintedTotal | int | plural "file" "files"}}. diff --git a/scripts/i18n_lint_doc.sh b/scripts/i18n_lint_doc.sh index 78f641b83b70c3..1c5d558611cb2a 100755 --- a/scripts/i18n_lint_doc.sh +++ b/scripts/i18n_lint_doc.sh @@ -29,8 +29,8 @@ printf "${COLOR_GREEN}INFO: Running Markdownlint on i18n files...${COLOR_RESET}\ } # 2. Run Vale -printf "${COLOR_GREEN}INFO: Running Vale on i18n files...${COLOR_RESET}\n" -vale --minAlertLevel error --filter='.Name matches "gitlab_docs"' ${MD_DOC_PATH_VALE} || { +printf "${COLOR_GREEN}INFO: Running locae Vale rules on i18n files...${COLOR_RESET}\n" +vale --config=doc-locale/.vale.ini --minAlertLevel warning --filter='.Name matches "locale_rules"' ${MD_DOC_PATH_VALE} || { printf "${COLOR_YELLOW}WARNING: Vale found issues in i18n files, but continuing...${COLOR_RESET}\n" ((ERRORCODE++)) } -- GitLab From 78bf3c439afd3ed3ad64afb333832c3128b1c69e Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Wed, 10 Sep 2025 17:59:03 -0700 Subject: [PATCH 02/19] Fix typo in script --- scripts/i18n_lint_doc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/i18n_lint_doc.sh b/scripts/i18n_lint_doc.sh index 1c5d558611cb2a..73f6a80404c813 100755 --- a/scripts/i18n_lint_doc.sh +++ b/scripts/i18n_lint_doc.sh @@ -29,7 +29,7 @@ printf "${COLOR_GREEN}INFO: Running Markdownlint on i18n files...${COLOR_RESET}\ } # 2. Run Vale -printf "${COLOR_GREEN}INFO: Running locae Vale rules on i18n files...${COLOR_RESET}\n" +printf "${COLOR_GREEN}INFO: Running locale Vale rules on i18n files...${COLOR_RESET}\n" vale --config=doc-locale/.vale.ini --minAlertLevel warning --filter='.Name matches "locale_rules"' ${MD_DOC_PATH_VALE} || { printf "${COLOR_YELLOW}WARNING: Vale found issues in i18n files, but continuing...${COLOR_RESET}\n" ((ERRORCODE++)) -- GitLab From 3966eed42dba18e448f0a821da496441ea1431a0 Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Thu, 11 Sep 2025 10:55:21 -0700 Subject: [PATCH 03/19] Remove unused vale-json.tmpl from doc-locale Vale configuration --- doc-locale/.vale/vale-json.tmpl | 43 --------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 doc-locale/.vale/vale-json.tmpl diff --git a/doc-locale/.vale/vale-json.tmpl b/doc-locale/.vale/vale-json.tmpl deleted file mode 100644 index bbcb7fc171d08d..00000000000000 --- a/doc-locale/.vale/vale-json.tmpl +++ /dev/null @@ -1,43 +0,0 @@ -{{- /* Modify Vale's output https://vale.sh/manual/output/ */ -}} - -{{- $fileIndexes := len .Files -}} -{{- $fileIndexes = sub $fileIndexes 1 -}} - -[ - {{- /* Range over the linted files */ -}} - {{- range $idx1, $a := .Files -}} - {{- $path := .Path -}} - - {{/* Range over the file's alerts */}} - {{- range $idx2, $b := .Alerts -}} - {{- $error := "info" -}} - {{- if eq .Severity "error" -}} - {{- $error = "blocker" -}} - {{- else if eq .Severity "warning" -}} - {{- $error = "major" -}} - {{- end}} - - {{- /* Variables setup */ -}} - {{- $loc := printf "%d" .Line -}} - {{- $message := printf "%s" .Message -}} - {{- $moreinfo := "" -}} - {{- if .Link -}} - {{- $moreinfo = printf " See %s" .Link -}} - {{- end -}} - {{- if $idx2 -}},{{- end -}} - - {{/* Output */}} - { - "description": "{{ $message }}{{ $moreinfo }}", - "fingerprint": "{{ $path }}-{{ $loc }}", - "severity": "{{ $error }}", - "location": { - "path": "{{ $path }}", - "lines": { - "begin": {{ $loc }} - } - } - } - {{- end}}{{- if (lt $idx1 $fileIndexes) -}},{{- end -}} - {{- end}} -] -- GitLab From d0d8e2e83175962e91ad1af2d9e32f50311ce406 Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Thu, 11 Sep 2025 11:07:56 -0700 Subject: [PATCH 04/19] Move Japanese vale rules into ja-jp --- .../.vale/locale_rules/ReferenceQuotationRemoval.yml | 0 doc-locale/{ => ja-jp}/.vale/vale.tmpl | 0 scripts/i18n_lint_doc.sh | 10 ++++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) rename doc-locale/{ => ja-jp}/.vale/locale_rules/ReferenceQuotationRemoval.yml (100%) rename doc-locale/{ => ja-jp}/.vale/vale.tmpl (100%) diff --git a/doc-locale/.vale/locale_rules/ReferenceQuotationRemoval.yml b/doc-locale/ja-jp/.vale/locale_rules/ReferenceQuotationRemoval.yml similarity index 100% rename from doc-locale/.vale/locale_rules/ReferenceQuotationRemoval.yml rename to doc-locale/ja-jp/.vale/locale_rules/ReferenceQuotationRemoval.yml diff --git a/doc-locale/.vale/vale.tmpl b/doc-locale/ja-jp/.vale/vale.tmpl similarity index 100% rename from doc-locale/.vale/vale.tmpl rename to doc-locale/ja-jp/.vale/vale.tmpl diff --git a/scripts/i18n_lint_doc.sh b/scripts/i18n_lint_doc.sh index 73f6a80404c813..228562f56f0ee3 100755 --- a/scripts/i18n_lint_doc.sh +++ b/scripts/i18n_lint_doc.sh @@ -29,12 +29,18 @@ printf "${COLOR_GREEN}INFO: Running Markdownlint on i18n files...${COLOR_RESET}\ } # 2. Run Vale -printf "${COLOR_GREEN}INFO: Running locale Vale rules on i18n files...${COLOR_RESET}\n" -vale --config=doc-locale/.vale.ini --minAlertLevel warning --filter='.Name matches "locale_rules"' ${MD_DOC_PATH_VALE} || { +printf "${COLOR_GREEN}INFO: Running Vale on i18n files...${COLOR_RESET}\n" +vale --minAlertLevel error --filter='.Name matches "gitlab_docs"' ${MD_DOC_PATH_VALE} || { printf "${COLOR_YELLOW}WARNING: Vale found issues in i18n files, but continuing...${COLOR_RESET}\n" ((ERRORCODE++)) } +printf "${COLOR_GREEN}INFO: Running Japanese-specific Vale rules on doc-locale/ja-jp...${COLOR_RESET}\n" +vale --config=doc-locale/ja-jp/.vale.ini --minAlertLevel warning --filter='.Name matches "locale_rules"' ${MD_DOC_PATH_VALE} || { + printf "${COLOR_YELLOW}WARNING: Japanese Vale rules found issues in translation files, but continuing...${COLOR_RESET}\n" + ((ERRORCODE++)) +} + # Report results if [ "$ERRORCODE" -ne 0 ]; then printf "\n${COLOR_RED}ERROR: i18n lint checks failed!${COLOR_RESET}\n" -- GitLab From 35dfe3c95c4fdcbcbb5a331fd1fce268e5f03b7b Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Thu, 11 Sep 2025 11:46:13 -0700 Subject: [PATCH 05/19] feat: Add language-specific CI/CD jobs for i18n documentation linting - Separate Japanese-specific Vale linting into dedicated CI job - Create universal script using env variables to avoid duplication - Move Japanese Vale config to separate job - Add efficient triggering: jobs only run when language files change - Enable scalable architecture for adding future languages Benefits: - One job per language with independent maintenance - DRY principle: single script handles all languages via CI variables - Parallel execution possible for multiple languages - Only runs when doc-locale/{language}/**/*.md files are modified Files changed: - .gitlab/ci/docs.gitlab-ci.yml: Add japanese-vale job with variables - .gitlab/ci/rules.gitlab-ci.yml: Add language-specific trigger rules - scripts/i18n_lint_doc.sh: Remove Japanese-specific logic - scripts/i18n_lint_language_vale.sh: New universal script with env vars Future languages can be added by simply creating new CI jobs with appropriate LANGUAGE_CODE, LANGUAGE_NAME, and VALE_FILTER variables. --- .gitlab/ci/docs.gitlab-ci.yml | 18 ++++++++ .gitlab/ci/rules.gitlab-ci.yml | 8 ++++ doc-locale/{ => ja-jp}/.vale.ini | 0 scripts/i18n_lint_doc.sh | 8 +--- scripts/i18n_lint_language_vale.sh | 73 ++++++++++++++++++++++++++++++ test_i18n_script.sh | 44 ++++++++++++++++++ 6 files changed, 144 insertions(+), 7 deletions(-) rename doc-locale/{ => ja-jp}/.vale.ini (100%) create mode 100755 scripts/i18n_lint_language_vale.sh create mode 100644 test_i18n_script.sh diff --git a/.gitlab/ci/docs.gitlab-ci.yml b/.gitlab/ci/docs.gitlab-ci.yml index 312c57aba586c7..3003370e842b05 100644 --- a/.gitlab/ci/docs.gitlab-ci.yml +++ b/.gitlab/ci/docs.gitlab-ci.yml @@ -196,6 +196,24 @@ docs-i18n-lint markdown: - install_gitlab_gem - scripts/i18n_lint_doc.sh +# Japanese-specific Vale linting with language-specific rules +docs-i18n-lint japanese-vale: + extends: + - .default-retry + - .docs:rules:docs-i18n-lint-japanese + - .docs-markdown-lint-image + stage: lint + needs: [] + variables: + LANGUAGE_CODE: "ja-jp" + LANGUAGE_NAME: "Japanese" + VALE_FILTER: "locale_rules" + VALE_MIN_ALERT_LEVEL: "warning" + script: + - source ./scripts/utils.sh + - install_gitlab_gem + - scripts/i18n_lint_language_vale.sh + # Verify localized documentation files have corresponding English versions docs-i18n-lint paths: extends: diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index b13fa9391a41b0..a55f8d6c02d763 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -1311,6 +1311,14 @@ - <<: *if-tech-docs-localization changes: *docs-i18n-patterns +.docs:rules:docs-i18n-lint-japanese: + rules: + - <<: *if-tech-docs-localization + changes: + - "doc-locale/ja-jp/**/*.md" + - "doc-locale/ja-jp/.vale.ini" + - "scripts/i18n_lint_language_vale.sh" + .docs:rules:deprecations-and-removals: rules: - <<: *if-default-refs diff --git a/doc-locale/.vale.ini b/doc-locale/ja-jp/.vale.ini similarity index 100% rename from doc-locale/.vale.ini rename to doc-locale/ja-jp/.vale.ini diff --git a/scripts/i18n_lint_doc.sh b/scripts/i18n_lint_doc.sh index 228562f56f0ee3..20a4723c8b991e 100755 --- a/scripts/i18n_lint_doc.sh +++ b/scripts/i18n_lint_doc.sh @@ -28,19 +28,13 @@ printf "${COLOR_GREEN}INFO: Running Markdownlint on i18n files...${COLOR_RESET}\ ((ERRORCODE++)) } -# 2. Run Vale +# 2. Run Vale (general i18n rules) printf "${COLOR_GREEN}INFO: Running Vale on i18n files...${COLOR_RESET}\n" vale --minAlertLevel error --filter='.Name matches "gitlab_docs"' ${MD_DOC_PATH_VALE} || { printf "${COLOR_YELLOW}WARNING: Vale found issues in i18n files, but continuing...${COLOR_RESET}\n" ((ERRORCODE++)) } -printf "${COLOR_GREEN}INFO: Running Japanese-specific Vale rules on doc-locale/ja-jp...${COLOR_RESET}\n" -vale --config=doc-locale/ja-jp/.vale.ini --minAlertLevel warning --filter='.Name matches "locale_rules"' ${MD_DOC_PATH_VALE} || { - printf "${COLOR_YELLOW}WARNING: Japanese Vale rules found issues in translation files, but continuing...${COLOR_RESET}\n" - ((ERRORCODE++)) -} - # Report results if [ "$ERRORCODE" -ne 0 ]; then printf "\n${COLOR_RED}ERROR: i18n lint checks failed!${COLOR_RESET}\n" diff --git a/scripts/i18n_lint_language_vale.sh b/scripts/i18n_lint_language_vale.sh new file mode 100755 index 00000000000000..a68b64942e8c35 --- /dev/null +++ b/scripts/i18n_lint_language_vale.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +# Universal language-specific Vale linting script +# Uses environment variables to configure language-specific behavior + +set -o pipefail + +COLOR_RED="\e[31m" +COLOR_GREEN="\e[32m" +COLOR_YELLOW="\e[33m" +COLOR_RESET="\e[39m" + +# Check required environment variables +if [ -z "$LANGUAGE_CODE" ]; then + printf "${COLOR_RED}ERROR: LANGUAGE_CODE environment variable is required${COLOR_RESET}\n" + printf "${COLOR_YELLOW}Example: LANGUAGE_CODE=ja-jp${COLOR_RESET}\n" + exit 1 +fi + +if [ -z "$LANGUAGE_NAME" ]; then + printf "${COLOR_RED}ERROR: LANGUAGE_NAME environment variable is required${COLOR_RESET}\n" + printf "${COLOR_YELLOW}Example: LANGUAGE_NAME=Japanese${COLOR_RESET}\n" + exit 1 +fi + +# Optional environment variables with defaults +VALE_FILTER="${VALE_FILTER:-locale_rules}" +VALE_MIN_ALERT_LEVEL="${VALE_MIN_ALERT_LEVEL:-warning}" + +cd "$(dirname "$0")/.." || exit 1 +printf "${COLOR_GREEN}INFO: Running ${LANGUAGE_NAME}-specific Vale linting at path $(pwd)...${COLOR_RESET}\n" +printf "${COLOR_GREEN}INFO: Language Code: ${LANGUAGE_CODE}${COLOR_RESET}\n" +printf "${COLOR_GREEN}INFO: Vale Filter: ${VALE_FILTER}${COLOR_RESET}\n" +printf "${COLOR_GREEN}INFO: Min Alert Level: ${VALE_MIN_ALERT_LEVEL}${COLOR_RESET}\n" + +ERRORCODE=0 + +# Set defaults for language-specific documentation paths +LANG_DOC_PATH="doc-locale/${LANGUAGE_CODE}/{*,**/*}.md" +LANG_DOC_PATH_VALE="doc-locale/${LANGUAGE_CODE}/" + +# Run options if files specified on command line +if [ -n "$1" ]; then + LANG_DOC_PATH="$@" + LANG_DOC_PATH_VALE="$@" + printf "${COLOR_GREEN}INFO: Checking specified files: ${LANG_DOC_PATH}${COLOR_RESET}\n" +fi + +# Check if language documentation directory exists +if [ ! -d "doc-locale/${LANGUAGE_CODE}" ]; then + printf "${COLOR_YELLOW}WARNING: ${LANGUAGE_NAME} documentation directory (doc-locale/${LANGUAGE_CODE}) not found, skipping ${LANGUAGE_NAME} Vale linting...${COLOR_RESET}\n" + exit 0 +fi + +# Check if language Vale configuration exists +if [ ! -f "doc-locale/${LANGUAGE_CODE}/.vale.ini" ]; then + printf "${COLOR_YELLOW}WARNING: ${LANGUAGE_NAME} Vale configuration (doc-locale/${LANGUAGE_CODE}/.vale.ini) not found, skipping ${LANGUAGE_NAME} Vale linting...${COLOR_RESET}\n" + exit 0 +fi + +printf "${COLOR_GREEN}INFO: Running ${LANGUAGE_NAME}-specific Vale rules on doc-locale/${LANGUAGE_CODE}...${COLOR_RESET}\n" +vale --config=doc-locale/${LANGUAGE_CODE}/.vale.ini --minAlertLevel ${VALE_MIN_ALERT_LEVEL} --filter=".Name matches \"${VALE_FILTER}\"" ${LANG_DOC_PATH_VALE} || { + printf "${COLOR_RED}ERROR: ${LANGUAGE_NAME} Vale rules found issues in translation files${COLOR_RESET}\n" + ((ERRORCODE++)) +} + +# Report results +if [ "$ERRORCODE" -ne 0 ]; then + printf "\n${COLOR_RED}ERROR: ${LANGUAGE_NAME} Vale lint checks failed!${COLOR_RESET}\n" + exit 1 +else + printf "\n${COLOR_GREEN}SUCCESS: All ${LANGUAGE_NAME} Vale lint checks passed${COLOR_RESET}\n" + exit 0 +fi \ No newline at end of file diff --git a/test_i18n_script.sh b/test_i18n_script.sh new file mode 100644 index 00000000000000..bf9f420a2d138e --- /dev/null +++ b/test_i18n_script.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Quick test script for i18n_lint_language_vale.sh + +echo "=== Testing Universal Language Linting Script ===" + +# Test 1: Missing required variables +echo "Test 1: Missing LANGUAGE_CODE (should fail)" +unset LANGUAGE_CODE LANGUAGE_NAME VALE_FILTER VALE_MIN_ALERT_LEVEL +./scripts/i18n_lint_language_vale.sh +echo "" + +# Test 2: Missing LANGUAGE_NAME +echo "Test 2: Missing LANGUAGE_NAME (should fail)" +export LANGUAGE_CODE="ja-jp" +unset LANGUAGE_NAME +./scripts/i18n_lint_language_vale.sh +echo "" + +# Test 3: Valid Japanese configuration +echo "Test 3: Valid Japanese configuration" +export LANGUAGE_CODE="ja-jp" +export LANGUAGE_NAME="Japanese" +export VALE_FILTER="locale_rules" +export VALE_MIN_ALERT_LEVEL="warning" +./scripts/i18n_lint_language_vale.sh +echo "" + +# Test 4: Valid French configuration (non-existent directory) +echo "Test 4: French configuration with non-existent directory (should skip gracefully)" +export LANGUAGE_CODE="fr-fr" +export LANGUAGE_NAME="French" +export VALE_FILTER="french_rules" +./scripts/i18n_lint_language_vale.sh +echo "" + +# Test 5: Test defaults +echo "Test 5: Test with minimal variables (using defaults)" +export LANGUAGE_CODE="ja-jp" +export LANGUAGE_NAME="Japanese" +unset VALE_FILTER VALE_MIN_ALERT_LEVEL +./scripts/i18n_lint_language_vale.sh +echo "" + +echo "=== Testing Complete ===" \ No newline at end of file -- GitLab From eadc68cd874b6197b5ac8b5ad6a93776512cd323 Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Thu, 11 Sep 2025 11:53:05 -0700 Subject: [PATCH 06/19] Update rule to be more greedy --- .../ja-jp/.vale/locale_rules/ReferenceQuotationRemoval.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc-locale/ja-jp/.vale/locale_rules/ReferenceQuotationRemoval.yml b/doc-locale/ja-jp/.vale/locale_rules/ReferenceQuotationRemoval.yml index 56ba99f3c636c6..7e992b40d5ddaf 100644 --- a/doc-locale/ja-jp/.vale/locale_rules/ReferenceQuotationRemoval.yml +++ b/doc-locale/ja-jp/.vale/locale_rules/ReferenceQuotationRemoval.yml @@ -8,4 +8,4 @@ level: warning nonword: true scope: raw tokens: - - '「[^」]+」' + - '「\[.+?\]\([^)]+\)」' -- GitLab From 8a2252c4eb7801b7814140744c920a1efbdec9c3 Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Thu, 11 Sep 2025 12:07:38 -0700 Subject: [PATCH 07/19] Update documentation for langauge testing --- .../documentation/testing/_index.md | 83 ++++++++++++++++++- scripts/i18n_lint_doc.sh | 2 +- test_i18n_script.sh | 44 ---------- 3 files changed, 82 insertions(+), 47 deletions(-) delete mode 100644 test_i18n_script.sh diff --git a/doc/development/documentation/testing/_index.md b/doc/development/documentation/testing/_index.md index 2cfc017a749f0d..2c69913ade9d12 100644 --- a/doc/development/documentation/testing/_index.md +++ b/doc/development/documentation/testing/_index.md @@ -94,15 +94,94 @@ To ensure quality across all our translated content, we've implemented testing f multiple languages. These tests mirror those used for the English version, but run on internationalized content in the `/doc-locale/` or `/docs-locale/` directories. +### General translation linting + +The `docs-i18n-lint markdown` job runs general linting tests on all translated documentation: + +- **Markdownlint**: Checks Markdown structure and formatting +- **Vale**: Runs general documentation style rules using the `gitlab_docs` filter + +This job runs when any files in `/doc-locale/` or `/docs-locale/` are modified and provides baseline quality checks +for all translated content. + | Project | English Dir | Translation Dir | Linting Jobs | | ----- | ----- | ----- | ----- | -| GitLab | [`/doc`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc) | [`/doc-locale`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc-locale) | `docs-i18n-lint markdown` | +| GitLab | [`/doc`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc) | [`/doc-locale`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc-locale) | `docs-i18n-lint markdown`
`docs-i18n-lint japanese-vale` | | GitLab Runner | [`/docs`](https://gitlab.com/gitlab-org/gitlab-runner/-/tree/main/docs) | [`/docs-locale`](https://gitlab.com/gitlab-org/gitlab-runner/-/tree/main/docs-locale?ref_type=heads) | `docs:lint i18n markdown` | | Linux package | [`/doc`](https://gitlab.com/gitlab-org/omnibus-gitlab/-/tree/master/doc) | [`/doc-locale`](https://gitlab.com/gitlab-org/omnibus-gitlab/-/tree/master/doc-locale) | `docs-lint-i18n markdown`
`docs-lint-i18n content` | | Charts | [`/doc`](https://gitlab.com/gitlab-org/charts/gitlab/-/tree/master/doc) | [`/doc-locale`](https://gitlab.com/gitlab-org/charts/gitlab/-/tree/master/doc-locale) | `check_docs_i18n_content`
`check_docs_i18n_markdown` | | Operator | [`/doc`](https://gitlab.com/gitlab-org/cloud-native/gitlab-operator/-/tree/master/doc) | [`/doc-locale`](https://gitlab.com/gitlab-org/cloud-native/gitlab-operator/-/tree/master/doc-locale) | `docs-i18n-lint content`
`docs-i18n-lint markdown` | -### Path verification of orphaned translation Files +### Language-specific translation linting + +For languages with specific style requirements, we provide dedicated CI/CD jobs that run +language-specific Vale rules. Each language has its own job that only runs when files +in that language are modified. + +#### Japanese language support + +The `docs-i18n-lint japanese-vale` job runs Japanese-specific Vale linting: + +- **Script**: [`scripts/i18n_lint_language_vale.sh`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/scripts/i18n_lint_language_vale.sh) +- **Configuration**: `doc-locale/ja-jp/.vale.ini` +- **Vale filter**: `locale_rules` +- **Triggers**: Only runs when these files change: + - `doc-locale/ja-jp/**/*.md` - Japanese documentation files + - `doc-locale/ja-jp/.vale.ini` - Japanese Vale configuration + - `scripts/i18n_lint_language_vale.sh` - Universal language linting script + +The job uses environment variables to configure the universal script: + +```yaml +variables: + LANGUAGE_CODE: "ja-jp" + LANGUAGE_NAME: "Japanese" + VALE_FILTER: "locale_rules" + VALE_MIN_ALERT_LEVEL: "warning" +``` + +#### Adding new languages + +To add language-specific linting for additional languages: + +1. **Create language-specific Vale configuration** at `doc-locale/LANGUAGE_CODE/.vale.ini` +2. **Add a new CI job** in `.gitlab/ci/docs.gitlab-ci.yml`: + + ```yaml + docs-i18n-lint LANGUAGE-vale: + extends: + - .default-retry + - .docs:rules:docs-i18n-lint-LANGUAGE + - .docs-markdown-lint-image + stage: lint + needs: [] + variables: + LANGUAGE_CODE: "LANGUAGE_CODE" # e.g., "fr-fr", "de-de" + LANGUAGE_NAME: "LANGUAGE_NAME" # e.g., "French", "German" + VALE_FILTER: "VALE_FILTER_NAME" # e.g., "french_rules" + VALE_MIN_ALERT_LEVEL: "warning" # or "error" for stricter rules + script: + - source ./scripts/utils.sh + - install_gitlab_gem + - scripts/i18n_lint_language_vale.sh + ``` + +3. **Add triggering rules** in `.gitlab/ci/rules.gitlab-ci.yml`: + + ```yaml + .docs:rules:docs-i18n-lint-LANGUAGE: + rules: + - <<: *if-tech-docs-localization + changes: + - "doc-locale/LANGUAGE_CODE/**/*.md" + - "doc-locale/LANGUAGE_CODE/.vale.ini" + - "scripts/i18n_lint_language_vale.sh" + ``` + +The universal script approach eliminates code duplication while maintaining language-specific +customization through environment variables. + +### Path verification of orphaned translation files The `docs-i18n-lint paths` job fails if translated files in `/doc-locale` have no corresponding English source files. The job runs when: diff --git a/scripts/i18n_lint_doc.sh b/scripts/i18n_lint_doc.sh index 20a4723c8b991e..78f641b83b70c3 100755 --- a/scripts/i18n_lint_doc.sh +++ b/scripts/i18n_lint_doc.sh @@ -28,7 +28,7 @@ printf "${COLOR_GREEN}INFO: Running Markdownlint on i18n files...${COLOR_RESET}\ ((ERRORCODE++)) } -# 2. Run Vale (general i18n rules) +# 2. Run Vale printf "${COLOR_GREEN}INFO: Running Vale on i18n files...${COLOR_RESET}\n" vale --minAlertLevel error --filter='.Name matches "gitlab_docs"' ${MD_DOC_PATH_VALE} || { printf "${COLOR_YELLOW}WARNING: Vale found issues in i18n files, but continuing...${COLOR_RESET}\n" diff --git a/test_i18n_script.sh b/test_i18n_script.sh deleted file mode 100644 index bf9f420a2d138e..00000000000000 --- a/test_i18n_script.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# Quick test script for i18n_lint_language_vale.sh - -echo "=== Testing Universal Language Linting Script ===" - -# Test 1: Missing required variables -echo "Test 1: Missing LANGUAGE_CODE (should fail)" -unset LANGUAGE_CODE LANGUAGE_NAME VALE_FILTER VALE_MIN_ALERT_LEVEL -./scripts/i18n_lint_language_vale.sh -echo "" - -# Test 2: Missing LANGUAGE_NAME -echo "Test 2: Missing LANGUAGE_NAME (should fail)" -export LANGUAGE_CODE="ja-jp" -unset LANGUAGE_NAME -./scripts/i18n_lint_language_vale.sh -echo "" - -# Test 3: Valid Japanese configuration -echo "Test 3: Valid Japanese configuration" -export LANGUAGE_CODE="ja-jp" -export LANGUAGE_NAME="Japanese" -export VALE_FILTER="locale_rules" -export VALE_MIN_ALERT_LEVEL="warning" -./scripts/i18n_lint_language_vale.sh -echo "" - -# Test 4: Valid French configuration (non-existent directory) -echo "Test 4: French configuration with non-existent directory (should skip gracefully)" -export LANGUAGE_CODE="fr-fr" -export LANGUAGE_NAME="French" -export VALE_FILTER="french_rules" -./scripts/i18n_lint_language_vale.sh -echo "" - -# Test 5: Test defaults -echo "Test 5: Test with minimal variables (using defaults)" -export LANGUAGE_CODE="ja-jp" -export LANGUAGE_NAME="Japanese" -unset VALE_FILTER VALE_MIN_ALERT_LEVEL -./scripts/i18n_lint_language_vale.sh -echo "" - -echo "=== Testing Complete ===" \ No newline at end of file -- GitLab From b2531716762b2f2c3bea6b86fd3bfea00436f55c Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Thu, 11 Sep 2025 12:53:21 -0700 Subject: [PATCH 08/19] Fix markdownlint errors for documentation --- .../documentation/testing/_index.md | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/doc/development/documentation/testing/_index.md b/doc/development/documentation/testing/_index.md index 2c69913ade9d12..89c1e2f084e7ad 100644 --- a/doc/development/documentation/testing/_index.md +++ b/doc/development/documentation/testing/_index.md @@ -98,7 +98,7 @@ content in the `/doc-locale/` or `/docs-locale/` directories. The `docs-i18n-lint markdown` job runs general linting tests on all translated documentation: -- **Markdownlint**: Checks Markdown structure and formatting +- **markdownlint**: Checks Markdown structure and formatting - **Vale**: Runs general documentation style rules using the `gitlab_docs` filter This job runs when any files in `/doc-locale/` or `/docs-locale/` are modified and provides baseline quality checks @@ -122,10 +122,10 @@ in that language are modified. The `docs-i18n-lint japanese-vale` job runs Japanese-specific Vale linting: -- **Script**: [`scripts/i18n_lint_language_vale.sh`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/scripts/i18n_lint_language_vale.sh) -- **Configuration**: `doc-locale/ja-jp/.vale.ini` -- **Vale filter**: `locale_rules` -- **Triggers**: Only runs when these files change: +- Script: [`scripts/i18n_lint_language_vale.sh`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/scripts/i18n_lint_language_vale.sh) +- Configuration: `doc-locale/ja-jp/.vale.ini` +- Vale filter: `locale_rules` +- Triggers: Only runs when these files change: - `doc-locale/ja-jp/**/*.md` - Japanese documentation files - `doc-locale/ja-jp/.vale.ini` - Japanese Vale configuration - `scripts/i18n_lint_language_vale.sh` - Universal language linting script @@ -144,39 +144,39 @@ variables: To add language-specific linting for additional languages: -1. **Create language-specific Vale configuration** at `doc-locale/LANGUAGE_CODE/.vale.ini` -2. **Add a new CI job** in `.gitlab/ci/docs.gitlab-ci.yml`: - - ```yaml - docs-i18n-lint LANGUAGE-vale: - extends: - - .default-retry - - .docs:rules:docs-i18n-lint-LANGUAGE - - .docs-markdown-lint-image - stage: lint - needs: [] - variables: - LANGUAGE_CODE: "LANGUAGE_CODE" # e.g., "fr-fr", "de-de" - LANGUAGE_NAME: "LANGUAGE_NAME" # e.g., "French", "German" - VALE_FILTER: "VALE_FILTER_NAME" # e.g., "french_rules" - VALE_MIN_ALERT_LEVEL: "warning" # or "error" for stricter rules - script: - - source ./scripts/utils.sh - - install_gitlab_gem - - scripts/i18n_lint_language_vale.sh - ``` - -3. **Add triggering rules** in `.gitlab/ci/rules.gitlab-ci.yml`: - - ```yaml - .docs:rules:docs-i18n-lint-LANGUAGE: - rules: - - <<: *if-tech-docs-localization - changes: - - "doc-locale/LANGUAGE_CODE/**/*.md" - - "doc-locale/LANGUAGE_CODE/.vale.ini" - - "scripts/i18n_lint_language_vale.sh" - ``` +- Create language-specific Vale configuration at `doc-locale/LANGUAGE_CODE/.vale.ini` +- Add a new CI job in `.gitlab/ci/docs.gitlab-ci.yml`: + + ```yaml + docs-i18n-lint LANGUAGE-vale: + extends: + - .default-retry + - .docs:rules:docs-i18n-lint-LANGUAGE + - .docs-markdown-lint-image + stage: lint + needs: [] + variables: + LANGUAGE_CODE: "LANGUAGE_CODE" # e.g., "fr-fr", "de-de" + LANGUAGE_NAME: "LANGUAGE_NAME" # e.g., "French", "German" + VALE_FILTER: "VALE_FILTER_NAME" # e.g., "french_rules" + VALE_MIN_ALERT_LEVEL: "warning" # or "error" for stricter rules + script: + - source ./scripts/utils.sh + - install_gitlab_gem + - scripts/i18n_lint_language_vale.sh + ``` + +- Add triggering rules in `.gitlab/ci/rules.gitlab-ci.yml`: + + ```yaml + .docs:rules:docs-i18n-lint-LANGUAGE: + rules: + - <<: *if-tech-docs-localization + changes: + - "doc-locale/LANGUAGE_CODE/**/*.md" + - "doc-locale/LANGUAGE_CODE/.vale.ini" + - "scripts/i18n_lint_language_vale.sh" + ``` The universal script approach eliminates code duplication while maintaining language-specific customization through environment variables. -- GitLab From 5d0172b96798c634b434198fb65654ebbf8d3ee6 Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Thu, 11 Sep 2025 15:16:07 -0700 Subject: [PATCH 09/19] Catch all rule for doc-locale/ja-jp directory --- .gitlab/ci/rules.gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index a55f8d6c02d763..d0229aca62bb9d 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -356,6 +356,9 @@ - "scripts/i18n_lint_doc.sh" - "scripts/i18n_verify_paths.sh" +.docs-ja-jp-patterns: &docs-ja-jp-patterns + - "doc-locale/ja-jp/**/*" + .if-tech-docs-localization: &if-tech-docs-localization if: '($CI_PROJECT_PATH == "gitlab-com/localization" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH) || ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_EVENT_TYPE != "merge_train") || @@ -1314,10 +1317,7 @@ .docs:rules:docs-i18n-lint-japanese: rules: - <<: *if-tech-docs-localization - changes: - - "doc-locale/ja-jp/**/*.md" - - "doc-locale/ja-jp/.vale.ini" - - "scripts/i18n_lint_language_vale.sh" + changes: *docs-ja-jp-patterns .docs:rules:deprecations-and-removals: rules: -- GitLab From c77f3f8dd1d88301c5d4c9b9937e1d386c5607c1 Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Tue, 16 Sep 2025 16:26:00 -0700 Subject: [PATCH 10/19] Fix docs-ja-jp-patterns to catch .vale --- .gitlab/ci/rules.gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index d0229aca62bb9d..484301d3cc5b9d 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -357,7 +357,7 @@ - "scripts/i18n_verify_paths.sh" .docs-ja-jp-patterns: &docs-ja-jp-patterns - - "doc-locale/ja-jp/**/*" + - "doc-locale/ja-jp/**/{*,.*}" .if-tech-docs-localization: &if-tech-docs-localization if: '($CI_PROJECT_PATH == "gitlab-com/localization" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH) || -- GitLab From b0c4dffab12957b76cb3b7df5d2c9fdf76825e00 Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Tue, 16 Sep 2025 16:53:34 -0700 Subject: [PATCH 11/19] Be more expicit with hidden directories --- .gitlab/ci/rules.gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 484301d3cc5b9d..927fb00170d0bf 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -357,7 +357,9 @@ - "scripts/i18n_verify_paths.sh" .docs-ja-jp-patterns: &docs-ja-jp-patterns - - "doc-locale/ja-jp/**/{*,.*}" + - "doc-locale/ja-jp/**/*" + - "doc-locale/ja-jp/.*" + - "doc-locale/ja-jp/.vale/**/*" .if-tech-docs-localization: &if-tech-docs-localization if: '($CI_PROJECT_PATH == "gitlab-com/localization" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH) || -- GitLab From 8ce56f2bfa2557fe7702d44dc4aa76ba8c8ce08d Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Wed, 17 Sep 2025 12:46:06 -0700 Subject: [PATCH 12/19] Apply 5 suggestions by Marcel --- .gitlab/ci/rules.gitlab-ci.yml | 5 +++-- doc/development/documentation/testing/_index.md | 2 +- scripts/i18n_lint_language_vale.sh | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 927fb00170d0bf..b13a5e644d026b 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -351,15 +351,16 @@ - "tooling/eslint-config/eslint-local-rules/**/*" .docs-i18n-patterns: &docs-i18n-patterns + - ".gitlab/ci/docs.gitlab-ci.yml" - "doc-locale/**/*" - "doc-locale/.markdownlint/.markdownlint-cli2.yaml" - "scripts/i18n_lint_doc.sh" - "scripts/i18n_verify_paths.sh" .docs-ja-jp-patterns: &docs-ja-jp-patterns + - ".gitlab/ci/docs.gitlab-ci.yml" - "doc-locale/ja-jp/**/*" - - "doc-locale/ja-jp/.*" - - "doc-locale/ja-jp/.vale/**/*" + - "scripts/i18n_lint_language_vale.sh" .if-tech-docs-localization: &if-tech-docs-localization if: '($CI_PROJECT_PATH == "gitlab-com/localization" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH) || diff --git a/doc/development/documentation/testing/_index.md b/doc/development/documentation/testing/_index.md index 89c1e2f084e7ad..809dba457177d8 100644 --- a/doc/development/documentation/testing/_index.md +++ b/doc/development/documentation/testing/_index.md @@ -101,7 +101,7 @@ The `docs-i18n-lint markdown` job runs general linting tests on all translated d - **markdownlint**: Checks Markdown structure and formatting - **Vale**: Runs general documentation style rules using the `gitlab_docs` filter -This job runs when any files in `/doc-locale/` or `/docs-locale/` are modified and provides baseline quality checks +This job runs when any files in `/doc-locale/` or `/docs-locale/` are modified and provides baseline quality checks for all translated content. | Project | English Dir | Translation Dir | Linting Jobs | diff --git a/scripts/i18n_lint_language_vale.sh b/scripts/i18n_lint_language_vale.sh index a68b64942e8c35..28d9c5ab444695 100755 --- a/scripts/i18n_lint_language_vale.sh +++ b/scripts/i18n_lint_language_vale.sh @@ -58,7 +58,7 @@ if [ ! -f "doc-locale/${LANGUAGE_CODE}/.vale.ini" ]; then fi printf "${COLOR_GREEN}INFO: Running ${LANGUAGE_NAME}-specific Vale rules on doc-locale/${LANGUAGE_CODE}...${COLOR_RESET}\n" -vale --config=doc-locale/${LANGUAGE_CODE}/.vale.ini --minAlertLevel ${VALE_MIN_ALERT_LEVEL} --filter=".Name matches \"${VALE_FILTER}\"" ${LANG_DOC_PATH_VALE} || { +vale --config=doc-locale/${LANGUAGE_CODE}/.vale.ini --minAlertLevel ${VALE_MIN_ALERT_LEVEL} ${LANG_DOC_PATH_VALE} || { printf "${COLOR_RED}ERROR: ${LANGUAGE_NAME} Vale rules found issues in translation files${COLOR_RESET}\n" ((ERRORCODE++)) } @@ -70,4 +70,4 @@ if [ "$ERRORCODE" -ne 0 ]; then else printf "\n${COLOR_GREEN}SUCCESS: All ${LANGUAGE_NAME} Vale lint checks passed${COLOR_RESET}\n" exit 0 -fi \ No newline at end of file +fi -- GitLab From 99de297894b92430dc10fe9b63c2635b580555dc Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Wed, 17 Sep 2025 13:13:52 -0700 Subject: [PATCH 13/19] Revise script to pass shellcheck --- scripts/i18n_lint_language_vale.sh | 63 +++++++++--------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/scripts/i18n_lint_language_vale.sh b/scripts/i18n_lint_language_vale.sh index 28d9c5ab444695..27d7658f230b14 100755 --- a/scripts/i18n_lint_language_vale.sh +++ b/scripts/i18n_lint_language_vale.sh @@ -2,67 +2,40 @@ # Universal language-specific Vale linting script # Uses environment variables to configure language-specific behavior -set -o pipefail +set -euo pipefail COLOR_RED="\e[31m" COLOR_GREEN="\e[32m" -COLOR_YELLOW="\e[33m" COLOR_RESET="\e[39m" -# Check required environment variables -if [ -z "$LANGUAGE_CODE" ]; then - printf "${COLOR_RED}ERROR: LANGUAGE_CODE environment variable is required${COLOR_RESET}\n" - printf "${COLOR_YELLOW}Example: LANGUAGE_CODE=ja-jp${COLOR_RESET}\n" - exit 1 -fi - -if [ -z "$LANGUAGE_NAME" ]; then - printf "${COLOR_RED}ERROR: LANGUAGE_NAME environment variable is required${COLOR_RESET}\n" - printf "${COLOR_YELLOW}Example: LANGUAGE_NAME=Japanese${COLOR_RESET}\n" - exit 1 -fi - # Optional environment variables with defaults VALE_FILTER="${VALE_FILTER:-locale_rules}" VALE_MIN_ALERT_LEVEL="${VALE_MIN_ALERT_LEVEL:-warning}" cd "$(dirname "$0")/.." || exit 1 -printf "${COLOR_GREEN}INFO: Running ${LANGUAGE_NAME}-specific Vale linting at path $(pwd)...${COLOR_RESET}\n" -printf "${COLOR_GREEN}INFO: Language Code: ${LANGUAGE_CODE}${COLOR_RESET}\n" -printf "${COLOR_GREEN}INFO: Vale Filter: ${VALE_FILTER}${COLOR_RESET}\n" -printf "${COLOR_GREEN}INFO: Min Alert Level: ${VALE_MIN_ALERT_LEVEL}${COLOR_RESET}\n" +printf "INFO: Running ${LANGUAGE_NAME}-specific Vale linting at path $(pwd)...\n" +printf "INFO: Language Code: ${LANGUAGE_CODE}\n" +printf "INFO: Vale Filter: ${VALE_FILTER}\n" +printf "INFO: Min Alert Level: ${VALE_MIN_ALERT_LEVEL}\n" ERRORCODE=0 -# Set defaults for language-specific documentation paths -LANG_DOC_PATH="doc-locale/${LANGUAGE_CODE}/{*,**/*}.md" -LANG_DOC_PATH_VALE="doc-locale/${LANGUAGE_CODE}/" - -# Run options if files specified on command line -if [ -n "$1" ]; then - LANG_DOC_PATH="$@" - LANG_DOC_PATH_VALE="$@" - printf "${COLOR_GREEN}INFO: Checking specified files: ${LANG_DOC_PATH}${COLOR_RESET}\n" -fi - -# Check if language documentation directory exists -if [ ! -d "doc-locale/${LANGUAGE_CODE}" ]; then - printf "${COLOR_YELLOW}WARNING: ${LANGUAGE_NAME} documentation directory (doc-locale/${LANGUAGE_CODE}) not found, skipping ${LANGUAGE_NAME} Vale linting...${COLOR_RESET}\n" - exit 0 -fi +# shellcheck disable=SC2059 +printf "${COLOR_GREEN}INFO: Running ${LANGUAGE_NAME}-specific Vale rules...${COLOR_RESET}\n" -# Check if language Vale configuration exists -if [ ! -f "doc-locale/${LANGUAGE_CODE}/.vale.ini" ]; then - printf "${COLOR_YELLOW}WARNING: ${LANGUAGE_NAME} Vale configuration (doc-locale/${LANGUAGE_CODE}/.vale.ini) not found, skipping ${LANGUAGE_NAME} Vale linting...${COLOR_RESET}\n" - exit 0 +# Run vale with either specified files or default path +if [ $# -gt 0 ]; then + vale --config="doc-locale/${LANGUAGE_CODE}/.vale.ini" --minAlertLevel "${VALE_MIN_ALERT_LEVEL}" "$@" || { + printf "${COLOR_RED}ERROR: ${LANGUAGE_NAME} Vale rules found issues in translation files${COLOR_RESET}\n" + ((ERRORCODE++)) + } +else + vale --config="doc-locale/${LANGUAGE_CODE}/.vale.ini" --minAlertLevel "${VALE_MIN_ALERT_LEVEL}" "doc-locale/${LANGUAGE_CODE}/" || { + printf "${COLOR_RED}ERROR: ${LANGUAGE_NAME} Vale rules found issues in translation files${COLOR_RESET}\n" + ((ERRORCODE++)) + } fi -printf "${COLOR_GREEN}INFO: Running ${LANGUAGE_NAME}-specific Vale rules on doc-locale/${LANGUAGE_CODE}...${COLOR_RESET}\n" -vale --config=doc-locale/${LANGUAGE_CODE}/.vale.ini --minAlertLevel ${VALE_MIN_ALERT_LEVEL} ${LANG_DOC_PATH_VALE} || { - printf "${COLOR_RED}ERROR: ${LANGUAGE_NAME} Vale rules found issues in translation files${COLOR_RESET}\n" - ((ERRORCODE++)) -} - # Report results if [ "$ERRORCODE" -ne 0 ]; then printf "\n${COLOR_RED}ERROR: ${LANGUAGE_NAME} Vale lint checks failed!${COLOR_RESET}\n" -- GitLab From 60c53c8d54c33e4dd20f031ff1c1344b492cabde Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Wed, 17 Sep 2025 13:20:05 -0700 Subject: [PATCH 14/19] Revise docs-ja-jp-patterns ruleset --- .gitlab/ci/rules.gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index b13a5e644d026b..1db9133a8a8f6a 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -359,8 +359,9 @@ .docs-ja-jp-patterns: &docs-ja-jp-patterns - ".gitlab/ci/docs.gitlab-ci.yml" - - "doc-locale/ja-jp/**/*" - "scripts/i18n_lint_language_vale.sh" + - "doc-locale/ja-jp/**/*" + - "doc-locale/ja-jp/.vale/**/*" .if-tech-docs-localization: &if-tech-docs-localization if: '($CI_PROJECT_PATH == "gitlab-com/localization" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH) || -- GitLab From 3df4985410a3a535173af312eb014de2bd3c1266 Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Wed, 17 Sep 2025 13:39:44 -0700 Subject: [PATCH 15/19] Let's be the most defined --- .gitlab/ci/rules.gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 1db9133a8a8f6a..724af56b8bf6e5 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -361,6 +361,7 @@ - ".gitlab/ci/docs.gitlab-ci.yml" - "scripts/i18n_lint_language_vale.sh" - "doc-locale/ja-jp/**/*" + - "doc-locale/ja-jp/.*" - "doc-locale/ja-jp/.vale/**/*" .if-tech-docs-localization: &if-tech-docs-localization -- GitLab From 68fe69c0fea6ec0d198aba1f41f81e5147e3a67a Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Wed, 17 Sep 2025 14:44:23 -0700 Subject: [PATCH 16/19] Update rulesset to catch all hidden --- .gitlab/ci/rules.gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 724af56b8bf6e5..b4e5e2d4a5da99 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -362,7 +362,6 @@ - "scripts/i18n_lint_language_vale.sh" - "doc-locale/ja-jp/**/*" - "doc-locale/ja-jp/.*" - - "doc-locale/ja-jp/.vale/**/*" .if-tech-docs-localization: &if-tech-docs-localization if: '($CI_PROJECT_PATH == "gitlab-com/localization" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH) || -- GitLab From 70f5f766f0b972074c37fe30fe77926551feda06 Mon Sep 17 00:00:00 2001 From: Lauren Barker Date: Wed, 17 Sep 2025 15:24:14 -0700 Subject: [PATCH 17/19] Back to being most defined --- .gitlab/ci/rules.gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index b4e5e2d4a5da99..724af56b8bf6e5 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -362,6 +362,7 @@ - "scripts/i18n_lint_language_vale.sh" - "doc-locale/ja-jp/**/*" - "doc-locale/ja-jp/.*" + - "doc-locale/ja-jp/.vale/**/*" .if-tech-docs-localization: &if-tech-docs-localization if: '($CI_PROJECT_PATH == "gitlab-com/localization" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH) || -- GitLab From f378470dd8b8bfacfe59d12b6fb00daf9121ecd3 Mon Sep 17 00:00:00 2001 From: Marcel Amirault Date: Thu, 18 Sep 2025 15:06:56 +0900 Subject: [PATCH 18/19] Apply 1 suggestion(s) to 1 file(s) --- .gitlab/ci/rules.gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 724af56b8bf6e5..49436c87d09909 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -361,8 +361,6 @@ - ".gitlab/ci/docs.gitlab-ci.yml" - "scripts/i18n_lint_language_vale.sh" - "doc-locale/ja-jp/**/*" - - "doc-locale/ja-jp/.*" - - "doc-locale/ja-jp/.vale/**/*" .if-tech-docs-localization: &if-tech-docs-localization if: '($CI_PROJECT_PATH == "gitlab-com/localization" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH) || -- GitLab From f2de3702819477cafa69d3476e680b5a92b7ef7d Mon Sep 17 00:00:00 2001 From: Marcel Amirault Date: Thu, 18 Sep 2025 17:49:05 +0900 Subject: [PATCH 19/19] Update spec to test --- spec/dot_gitlab_ci/rules_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/dot_gitlab_ci/rules_spec.rb b/spec/dot_gitlab_ci/rules_spec.rb index 76a8a6a742431a..14844d5cbc2d12 100644 --- a/spec/dot_gitlab_ci/rules_spec.rb +++ b/spec/dot_gitlab_ci/rules_spec.rb @@ -205,6 +205,7 @@ Dir.glob('*.md') + Dir.glob('changelogs/*') + Dir.glob('doc/.{markdownlint,vale}/**/*', File::FNM_DOTMATCH) + + Dir.glob('doc-locale/**/*', File::FNM_DOTMATCH) + Dir.glob('node_modules/**/*', File::FNM_DOTMATCH) + Dir.glob('patches/*') + Dir.glob('public/assets/**/.*') + -- GitLab