ghost-n8n-translator
v1.0.1
Published
Translation service for Ghost blogs using n8n webhook integration
Maintainers
Readme
Ghost Translation Service
A lightweight JavaScript library for translating Ghost blog content using n8n webhook integration.
Features
- 🔄 Automatic content translation
- 🔀 Toggle between original and translated content
- 🎯 Supports all Ghost blog content (paragraphs, headings, lists)
- 🛡️ Built-in error handling
- 🎨 Clean and minimal UI
Installation
You can install this package in several ways:
Using npm
npm install ghost-n8n-translatorUsing yarn
yarn add ghost-n8n-translatorDirect CDN Usage
You can use the package directly from CDN:
jsDelivr (Recommended)
<script src="https://cdn.jsdelivr.net/npm/[email protected]/translation-service.min.js"></script>unpkg
<script src="https://unpkg.com/[email protected]/translation-service.min.js"></script>Usage
Basic Setup
- Add the script to your Ghost theme:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/translation-service.min.js"></script>
<script>
const translator = new TranslationService('https://your-n8n-server.com/webhook/translate');
document.addEventListener('DOMContentLoaded', () => {
translator.translateGhostContent();
translator.addTranslationToggle();
});
</script>N8N Webhook Setup
- Create a new workflow in n8n
- Add an HTTP Webhook node as trigger
- Add your translation service node (e.g., Google Translate, DeepL)
- Configure the webhook to expect:
{ "text": "Text to translate", "target": "Target language code" } - Return response in format:
{ "translated_text": "Translated content" }
API Reference
TranslationService
Constructor
const translator = new TranslationService(n8nWebhookUrl);Methods
translate(text, targetLang)
Translates a single piece of text
const translated = await translator.translate('Hello', 'es');translateGhostContent()
Translates all content in the current Ghost post
await translator.translateGhostContent();addTranslationToggle()
Adds a toggle button to switch between original and translated content
translator.addTranslationToggle();License
MIT
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
