Skip to content

JuanVilla424/langding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

61 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ—ΊοΈ Langding

AI-Powered Landing Page Translation Tool

Python AI Status License: GPL v3 Automation


🌐 Overview

Langding is an AI-driven landing page auto-translation tool designed for developers who need to localize their websites efficiently. It extracts meaningful content from HTML files, translates it using advanced AI models (OpenAI GPT or Anthropic Claude), and generates complete multilingual versions with automatic language detection.

🎯 Core Translation Features

  • πŸ€– AI-Powered Translation: Leverages OpenAI GPT or Anthropic Claude for context-aware translations
  • 🌍 Multi-Language Support: Supports 10+ languages with automatic browser detection
  • πŸ“„ Smart Template System: Generates reusable templates with intelligent placeholder mapping
  • πŸ”„ Auto-Redirect Generation: Creates language detection and redirect pages
  • ⚑ Batch Processing: Efficiently processes multiple HTML files
  • πŸŽ›οΈ Flexible Configuration: Environment-based and CLI configuration options


✨ Features

graph TD
    A[HTML Input] --> B[Content Extraction]
    B --> C{AI Translation}
    C -->|OpenAI GPT| D[Context-Aware Translation]
    C -->|Anthropic Claude| D
    D --> E[Template Generation]
    E --> F[Multi-Language Output]
    F --> G[Auto-Redirect Pages]

    H[Configuration] --> C
    H --> I[Environment Variables]
    H --> J[CLI Arguments]

    K[Logging System] --> L[Rotation & Monitoring]

    style A fill:#e1f5fe
    style F fill:#f3e5f5
    style G fill:#fff3e0
    style C fill:#e8f5e8
Loading

πŸ”§ Core Translation Engine

  • Smart Content Extraction: Prioritizes headings, paragraphs, and meta content
  • Context Preservation: Maintains technical accuracy and professional tone
  • Template Generation: Creates reusable placeholders for efficient processing

🌐 Multi-AI Support

  • OpenAI GPT Integration: Support for GPT-3.5-turbo and GPT-4 models
  • Anthropic Claude Integration: Claude-3-haiku and Claude-3-sonnet support
  • Provider Switching: Easy configuration between AI providers

πŸ“„ Output Management

  • Structured File Generation: Organized output with language-specific files
  • Auto-Redirect System: Browser language detection with fallback support
  • GitHub Pages Ready: Direct deployment compatibility

πŸ› οΈ Installation

Prerequisites

  • Python 3.11+
  • Git
  • AI API Key (OpenAI OR Anthropic)

Quick Setup

# Clone repository
git clone https://github.com/JuanVilla424/langding.git
cd langding

# Setup virtual environment
python -m venv venv
source venv/bin/activate  # Windows: .\venv\Scripts\activate

# Install dependencies
pip install --upgrade pip
pip install -r requirements.txt

πŸ”‘ AI Provider Setup

Choose ONE provider:

Option A: OpenAI

export OPENAI_API_KEY='sk-your-openai-key-here'
export AI_PROVIDER='openai'

Option B: Anthropic Claude

export ANTHROPIC_API_KEY='sk-ant-your-anthropic-key-here'
export AI_PROVIDER='anthropic'

βš™οΈ Configuration

Environment Configuration

Create .env file:

# Output Configuration
OUTPUT_DIR=output

# Language Selection (JSON format)
LANGS=["English","Spanish","French","German","Portuguese","Italian","Japanese","Korean","Chinese","Arabic"]

# AI Provider Selection
AI_PROVIDER=openai  # Options: openai, anthropic

# OpenAI Configuration
OPENAI_API_KEY=your-openai-api-key-here
OPENAI_MODEL=gpt-3.5-turbo

# Anthropic Configuration
ANTHROPIC_API_KEY=your-anthropic-api-key-here
ANTHROPIC_MODEL=claude-3-haiku-20240307

πŸ“‹ Configuration Variables

Variable Description Default Required
OUTPUT_DIR Output directory for generated files output ❌
LANGS Target languages (JSON array) ["English","Spanish","French","German"] ❌
AI_PROVIDER AI service provider openai ❌
OPENAI_API_KEY OpenAI API key - βœ… (if using OpenAI)
ANTHROPIC_API_KEY Anthropic API key - βœ… (if using Anthropic)
OPENAI_MODEL OpenAI model name gpt-3.5-turbo ❌
ANTHROPIC_MODEL Anthropic model name claude-3-haiku-20240307 ❌

πŸš€ Usage

Basic Commands

# Process templates directory
python langding.py --process-templates

# Process custom input directory
python langding.py --input-dir input_html --output-dir translated_html

# Specify target languages
python langding.py --process-templates --languages Spanish French German

# Enable debug logging
python langding.py --process-templates --log-level DEBUG

πŸ“ Processing Templates

Input Structure:

templates/
β”œβ”€β”€ index.html          # Main landing page
β”œβ”€β”€ about.html          # Additional pages
└── contact.html        # More pages

Command:

python langding.py --process-templates

Generated Output:

output/
β”œβ”€β”€ index.html                    # Auto-redirect page
β”œβ”€β”€ english_index.html           # English version
β”œβ”€β”€ spanish_index.html           # Spanish version
β”œβ”€β”€ french_index.html            # French version
β”œβ”€β”€ template_index.html          # Template with placeholders
└── index_translations.json     # Translation metadata

πŸŽ›οΈ Command Line Options

python langding.py [OPTIONS]

Options:
  --input-dir TEXT        Input directory containing HTML files
  --output-dir TEXT       Output directory for generated files
  --template-dir TEXT     Template directory (default: templates)
  --languages TEXT...     Target languages for translation
  --log-level CHOICE      Logging level [DEBUG|INFO|WARNING|ERROR]
  --process-templates     Process files from templates directory
  --help                  Show help message and exit

πŸ“ Examples

Example 1: Basic Translation

# Translate templates to Spanish and French
python langding.py --process-templates --languages Spanish French

Example 2: Custom Workflow

# Custom directories with specific languages
python langding.py \
  --input-dir my_website \
  --output-dir translations \
  --languages English Spanish Portuguese Italian \
  --log-level INFO

Example 3: Development Mode

# Debug mode with detailed logging
python langding.py --process-templates --log-level DEBUG

πŸ€– AI Provider Setup

OpenAI Configuration

  1. Get API key from OpenAI Platform
  2. Set environment variables:
export OPENAI_API_KEY='sk-your-key-here'
export AI_PROVIDER='openai'

Anthropic Claude Configuration

  1. Get API key from Anthropic Console
  2. Set environment variables:
export ANTHROPIC_API_KEY='sk-ant-your-key-here'
export AI_PROVIDER='anthropic'

πŸ“Š Logging

Logs are stored in logs/langding.log with automatic rotation:

  • File Size Limit: 5MB per file
  • Backup Count: 5 files maximum
  • Format: timestamp - logger - level - message

Log Levels

  • DEBUG: Detailed diagnostic information
  • INFO: General operational messages
  • WARNING: Warning messages for potential issues
  • ERROR: Error messages for failed operations

πŸ“« Contact

For any inquiries or support, please open an issue or contact r6ty5r296it6tl4eg5m.constant214@passinbox.com.


πŸ“œ License

2025 β€” This project is licensed under the GNU General Public License v3.0. You are free to use, modify, and distribute this software under the terms of the GPL-3.0 license. For more details, please refer to the LICENSE file included in this repository.

About

Langding is an AI driven landing auto-translate site - https://langding.bridgefusion.icu

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors