@olibolduc/website-translator
v1.0.8
Published
CLI tool to translate static websites using Google Gemini AI with intelligent caching and SEO optimization
Maintainers
Readme
@olibolduc/website-translator
AI-powered translation tool for static websites with intelligent caching and SEO optimization.
Features
- 🤖 AI Translation: Uses Google Gemini for accurate, context-aware translations
- 💾 Smart Caching: Stores translations in
translations.jsonto avoid redundant API calls - 🌐 SEO Optimized: Automatically generates
hreflang,canonicaltags, andsitemap.xml - 🔗 URL Management: Translates slugs and rewrites all internal links
- 📦 Full Build: Generates complete multilingual site structure
Installation
npm install @olibolduc/website-translatorUsage
Basic Command
npx website-translator translate <source-dir> <output-dir> --lang <target-lang> --url <base-url> [--source-lang <source-lang>]Example
npx website-translator translate . ./dist --lang en --url https://mysite.com --source-lang frParameters
<source-dir>: Path to your Webflow export or static site<output-dir>: Where to generate the translated site--lang: Target language code (en, es, fr, de, etc.)--url: Base URL for canonical tags and sitemap--source-lang: (Optional) Source language code (default: fr)
Output Structure
dist/
├── index.html # Original (FR)
├── contact.html # Original (FR)
├── sitemap.xml # Global sitemap
├── en/ # Translated version
│ ├── index.html
│ ├── contact-us.html
│ ├── css/
│ ├── js/
│ └── images/Environment Variables
Create a .env file:
GEMINI_API_KEY=your_google_gemini_api_keyTranslation Cache
The tool maintains a translations.json file to:
- Avoid re-translating unchanged content
- Allow manual corrections
- Reduce API costs
Editing Translations
- Open
translations.json - Find the text you want to change
- Modify the
translatedfield - Save and rebuild
GitHub Actions Integration
Example workflow:
- name: Install translator
run: npm install @olibolduc/website-translator
- name: Translate site
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: npx website-translator translate ./source ./dist --lang en --url https://mysite.comLicense
MIT
