Skip to content

Commit 94a400d

Browse files
drmowinckelsclaude
andauthored
Fix Spanish content leaking onto English chapters/directory pages (#573)
* Fix Spanish content leaking onto English chapters/directory pages The missing_translations.R script was generating _index.en.md from the alphabetically-first _index.es.md source, then Hugo preferred that explicit-lang file over _index.md and rendered the Spanish title and body at /chapters/ and /directory/. Detect file languages by .LANG.md suffix (treating unsuffixed files as defaultContentLanguage), pick the default-lang file as the source, and exit early when only one language is configured. Production has only English enabled, so drop the R/renv setup and the translation step from build-production, check-build, and lighthouse workflows entirely. Update the i18n-check PR comment to no longer reference the now-removed build-time script. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Conditionally run translation step based on active language count Restore the R/renv setup and translation step in production build workflows, but gate them on a yq-based check that compares disableLanguages against the total number of languages defined in _default/languages.yaml. When fewer than two languages are active for the target environment, the R steps are skipped. The translation script also accepts an env argument (e.g. "production") and filters site_lang against that environment's disableLanguages, so it self-skips when invoked in a single-language environment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Rename default _index.md files to _index.en.md Make every section's default content language explicit by suffixing all section index files with .en. This eliminates the ambiguity that let the buggy translation script (when it generated _index.en.md from Spanish source) silently take precedence over an unsuffixed _index.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 76e143d commit 94a400d

14 files changed

Lines changed: 123 additions & 50 deletions

File tree

.github/workflows/build-production.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,38 @@ jobs:
3030
ver=$(cat .hugoversion)
3131
echo "hugovr=$ver" >> $GITHUB_ENV
3232
33+
- name: Check if translation step is needed
34+
id: i18n
35+
run: |
36+
total=$(yq 'keys | length' config/_default/languages.yaml)
37+
disabled=$(yq '.disableLanguages // [] | length' config/production/hugo.yaml)
38+
active=$((total - disabled))
39+
echo "Active languages for production: $active"
40+
if [ "$active" -gt 1 ]; then
41+
echo "needed=true" >> $GITHUB_OUTPUT
42+
else
43+
echo "needed=false" >> $GITHUB_OUTPUT
44+
fi
45+
3346
- name: Install cURL Headers
47+
if: steps.i18n.outputs.needed == 'true'
3448
run: |
3549
sudo apt-get update
3650
sudo apt-get install libcurl4-openssl-dev
3751
3852
- name: Setup R
53+
if: steps.i18n.outputs.needed == 'true'
3954
uses: r-lib/actions/setup-r@v2
4055
with:
4156
r-version: "renv"
4257

4358
- name: Setup renv
59+
if: steps.i18n.outputs.needed == 'true'
4460
uses: r-lib/actions/setup-renv@v2
4561

4662
- name: Populate untranslated pages
47-
run: |
48-
Rscript scripts/missing_translations.R
63+
if: steps.i18n.outputs.needed == 'true'
64+
run: Rscript scripts/missing_translations.R production
4965

5066
- name: Site data - Clean folders
5167
run: rm -r data/directory

.github/workflows/check-build.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,38 @@ jobs:
2727
ver=$(cat .hugoversion)
2828
echo "hugovr=$ver" >> $GITHUB_ENV
2929
30+
- name: Check if translation step is needed
31+
id: i18n
32+
run: |
33+
total=$(yq 'keys | length' config/_default/languages.yaml)
34+
disabled=$(yq '.disableLanguages // [] | length' config/production/hugo.yaml)
35+
active=$((total - disabled))
36+
echo "Active languages for production: $active"
37+
if [ "$active" -gt 1 ]; then
38+
echo "needed=true" >> $GITHUB_OUTPUT
39+
else
40+
echo "needed=false" >> $GITHUB_OUTPUT
41+
fi
42+
3043
- name: Install cURL Headers
44+
if: steps.i18n.outputs.needed == 'true'
3145
run: |
3246
sudo apt-get update
3347
sudo apt-get install libcurl4-openssl-dev
3448
3549
- name: Setup R
50+
if: steps.i18n.outputs.needed == 'true'
3651
uses: r-lib/actions/setup-r@v2
3752
with:
3853
r-version: "renv"
3954

4055
- name: Setup renv
56+
if: steps.i18n.outputs.needed == 'true'
4157
uses: r-lib/actions/setup-renv@v2
4258

4359
- name: Populate untranslated pages
44-
run: |
45-
Rscript scripts/missing_translations.R
60+
if: steps.i18n.outputs.needed == 'true'
61+
run: Rscript scripts/missing_translations.R production
4662

4763
- name: Setup Hugo
4864
uses: peaceiris/actions-hugo@v2

.github/workflows/i18n-check.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ jobs:
175175
for (const line of contentMissing.split('\n').filter(Boolean)) {
176176
md += `- \`${line.trim()}\`\n`;
177177
}
178-
md += '\n> The `missing_translations.R` script creates placeholder files at build time,\n';
179-
md += '> but proper translations are recommended.\n';
178+
md += '\n> Translations are recommended for all languages, but missing\n';
179+
md += '> language files will fall back to the default content language.\n';
180180
}
181181
}
182182

.github/workflows/lighthouse.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,38 @@ jobs:
2727
ver=$(cat .hugoversion)
2828
echo "hugovr=$ver" >> $GITHUB_ENV
2929
30+
- name: Check if translation step is needed
31+
id: i18n
32+
run: |
33+
total=$(yq 'keys | length' config/_default/languages.yaml)
34+
disabled=$(yq '.disableLanguages // [] | length' config/production/hugo.yaml)
35+
active=$((total - disabled))
36+
echo "Active languages for production: $active"
37+
if [ "$active" -gt 1 ]; then
38+
echo "needed=true" >> $GITHUB_OUTPUT
39+
else
40+
echo "needed=false" >> $GITHUB_OUTPUT
41+
fi
42+
3043
- name: Install cURL Headers
44+
if: steps.i18n.outputs.needed == 'true'
3145
run: |
3246
sudo apt-get update
3347
sudo apt-get install libcurl4-openssl-dev
3448
3549
- name: Setup R
50+
if: steps.i18n.outputs.needed == 'true'
3651
uses: r-lib/actions/setup-r@v2
3752
with:
3853
r-version: "renv"
3954

4055
- name: Setup renv
56+
if: steps.i18n.outputs.needed == 'true'
4157
uses: r-lib/actions/setup-renv@v2
4258

4359
- name: Populate untranslated pages
44-
run: Rscript scripts/missing_translations.R
60+
if: steps.i18n.outputs.needed == 'true'
61+
run: Rscript scripts/missing_translations.R production
4562

4663
- name: Setup Hugo
4764
uses: peaceiris/actions-hugo@v2
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)