Content Automation Scripts
The project includes three AI-powered scripts that help maintain high-quality content. These scripts can fix grammar, improve readability, and translate content automatically.
Overview
| Script | Command | What it does |
|---|---|---|
| Grammar Fix | pnpm fix:grammar | Fixes spelling, typos, and grammar errors |
| Readability | pnpm improve:readability | Improves sentence clarity and flow |
| Translation | pnpm translate:en | Translates Dutch content to English |
All scripts support dry-run mode (preview changes without writing) and language filters (process only Dutch or only English).
Setup
These scripts require API keys. Add them to your .env file in the project root:
NUXT_OPENAI_API_KEY=sk-... # For grammar & readability scripts
NUXT_GOOGLE_TRANSLATE_SECRET=... # For translation scriptWARNING
Never commit .env to Git. The file is already in .gitignore. Ask a team member for the API keys if you don't have them.
Grammar Fix Script
Fixes spelling and grammar mistakes with a conservative approach — it only changes things that are clearly wrong.
Commands
# Preview changes (recommended first step)
pnpm fix:grammar:dry
# Fix all content (both languages)
pnpm fix:grammar
# Fix only Dutch content
pnpm fix:grammar:nl
# Fix only English content
pnpm fix:grammar:enWhat it fixes
- Spelling errors (e.g., "ondersuek" → "onderzoek")
- Grammar mistakes
- Expands abbreviations (o.a. → onder andere)
- Basic punctuation issues
What it preserves
- Markdown formatting (links, headings, lists)
- Code blocks and components
- Frontmatter structure
- Annotation syntax (
:annotation{:ids="[1]"}[text])
Readability Improvement Script
Goes further than grammar fixes — it restructures sentences and paragraphs for clarity.
Commands
# Preview changes
pnpm improve:readability:dry
# Improve all content
pnpm improve:readability
# Improve only Dutch
pnpm improve:readability:nl
# Improve only English
pnpm improve:readability:en
# Force re-process already-processed files
pnpm improve:readability:forceWhat it improves
- Complex sentences → shorter, clearer ones
- Passive voice → active voice where appropriate
- Jargon → plain language
- Ambiguous pronouns → explicit references
- Dense paragraphs → broken into digestible chunks
- Weak transitions → smoother flow
Example
Before:
Er wordt door ons onderzoek gedaan naar de omstandigheden
waarin de varkens worden gehouden en dit is niet goed en
het moet beter en er zijn diverse problemen met de
huisvesting die we hebben gezien tijdens het onderzoek.After:
Wij onderzoeken de omstandigheden waarin varkens worden
gehouden. Deze omstandigheden zijn slecht en moeten
verbeteren.
Tijdens het onderzoek zagen we meerdere problemen met
de huisvesting.TIP
The readability script makes more substantial changes than the grammar script. Always review changes carefully before committing.
Translation Script
Translates Dutch content to English automatically using Google Translate.
Commands
# Preview what would be translated
pnpm translate:en:dry
# Translate all untranslated content
pnpm translate:enHow it works
- Scans
content/nl/for files - Checks if a corresponding English file exists in
content/en/ - Translates missing or outdated files
- Preserves all Markdown structure, links, and components
What gets translated
- Markdown body text
- Frontmatter text fields (
title,description,image.alt) - JSON text fields (
name,plural,label,subLabel)
What stays the same
- Folder and file names
- URLs and paths
- Animal keys, welfare brand keys
- Dates, coordinates, and other technical values
- Annotation syntax structure
Recommended Workflow
For new Dutch content
Run the scripts in this exact order:
# Step 1: Fix grammar in your new Dutch content
pnpm fix:grammar:nl
# Step 2: Improve readability in Dutch
pnpm improve:readability:nl
# Step 3: Translate to English
pnpm translate:en
# Step 4: Fix any grammar artifacts in the English translation
pnpm fix:grammar:en
# Step 5: Improve readability of the English version
pnpm improve:readability:enFor reviewing all existing content
# Preview everything first
pnpm fix:grammar:dry
pnpm improve:readability:dry
# If happy with the previews, run for real
pnpm fix:grammar
pnpm improve:readability
# Always review changes before committing
git diff content/After any script run
Always review the changes before committing:
# See what changed
git diff content/
# If everything looks good, commit
git add content/
git commit -m "content: fix grammar in investigation articles"
# If something went wrong, revert
git checkout content/Progress Tracking
Each script tracks which files it has already processed:
| Script | Log file |
|---|---|
| Grammar | .grammar-fix-log.json |
| Readability | .readability-log.json |
| Translation | .translation-log.json |
These log files prevent re-processing unchanged files, saving API costs. To force re-processing, use the --force flag or delete the relevant log file.
Cost Estimates
| Operation | First run (all content) | Incremental (new content) |
|---|---|---|
| Grammar fix | ~$5-15 | ~$1-5 |
| Readability | ~$5-15 | ~$1-5 |
| Translation | ~$15-30 | ~$1-5 |
| Total | ~$25-60 | ~$3-15 |
Troubleshooting
"No changes needed"
The file was already processed. Check the log file, or use --force to re-process.
"API key not found"
Check your .env file. Make sure the variable names are correct:
NUXT_OPENAI_API_KEYfor grammar and readabilityNUXT_GOOGLE_TRANSLATE_SECRETfor translation
"Rate limit exceeded"
Wait a few minutes and try again. The scripts will resume from where they left off.
Changes are too aggressive
The readability script can sometimes restructure more than you'd like. Options:
- Review changes with
git diffand selectively revert - Use only the grammar script for a lighter touch
- Manually edit after the script runs