Post Translation
girok-md can automatically translate your posts to multiple languages, making your content accessible to a global audience.
Overview
The translation feature:
- Auto-detects source language from post content
- Translates title, summary, and body automatically
- Supports incremental translation - only translates new or updated posts
- Offers multiple providers - Google Translate (free) or AI models (OpenAI, Anthropic, Google AI)
Configuration
Enable translation in your setting.toml:
[posts.translate]# Enable translation featureenabled = true
# Target languages to translate into# Uses ISO 639-1 codes: en, ko, ja, zh, es, fr, de, etc.target_langs = ["en", "ko"]Using AI Providers (Optional)
For higher quality translations, configure an AI provider:
[posts.translate]enabled = truetarget_langs = ["en", "ko", "ja"]
# AI Provider: "openai" | "anthropic" | "google"provider = "openai"
# API Key (use environment variable for security)api_key = "${OPENAI_API_KEY}"
# Model to usemodel = "gpt-4o-mini"Supported Models
| Provider | Models |
|---|---|
| OpenAI | gpt-4o, gpt-4o-mini, gpt-4-turbo |
| Anthropic | claude-sonnet-4-20250514, claude-3-5-haiku-20241022 |
| Google AI | gemini-1.5-pro, gemini-1.5-flash |
Usage
Translate All Posts
Run the translate command after syncing your posts:
# First, sync your postsnpm run sync
# Then translatenpm run translateCommand Options
| Option | Description |
|---|---|
--force, -f | Re-translate all posts, even if already translated |
--slug <slug>, -s <slug> | Translate only a specific post |
Examples:
# Force re-translate all postsnpm run translate -- --force
# Translate a specific postnpm run translate -- --slug my-post-title
# Combine optionsnpm run translate -- -f -s my-post-titleHow It Works
Translation Process
- Scans
src/content/posts/for source posts - Detects the source language of each post
- Identifies posts missing translations for target languages
- Translates title, summary/description, and content
- Saves translated posts with language suffix
File Naming
Translated posts are saved with a language suffix:
| Original | Translated (Korean) | Translated (Japanese) |
|---|---|---|
my-post.md | my-post_ko.md | my-post_ja.md |
Frontmatter Changes
Translated posts include additional metadata:
---title: 번역된 제목lang: kotranslated_from: my-posttranslate_sync_at: 2024-01-15 10:30:00---| Field | Description |
|---|---|
lang | Language code of this translation |
translated_from | Slug of the original post |
translate_sync_at | Timestamp of when translation was performed |
Language Detection
girok-md automatically detects the source language by analyzing the content:
| Language | Detection Method |
|---|---|
| Korean | Korean characters (한글) |
| Japanese | Hiragana/Katakana characters |
| Chinese | CJK ideographs (without Japanese) |
| English | Latin alphabet (default fallback) |
You can also explicitly set the language in frontmatter:
---title: My Postlang: en---Best Practices
- Run sync before translate - Ensure posts are up-to-date
- Review AI translations - AI translations are good but may need minor edits
- Use environment variables - Never commit API keys to your repository
- Start with free tier - Test with Google Translate before paying for AI
Troubleshooting
Translation not running?
- Check that
enabled = truein[posts.translate] - Verify
target_langsis configured - Run
npm run syncfirst
API errors?
- Verify your API key is correct
- Check that the environment variable is set
- Ensure you have API credits/quota available
Posts not being translated?
- Translation already exists (use
--forceto re-translate) - Source language matches target language
- Post not yet synced (run
npm run sync)
Next Steps
- Writing Posts - Learn about post frontmatter
- Deployment - Deploy your multilingual blog