langding

# πŸ—ΊοΈ Langding _AI-Powered Landing Page Translation Tool_ ![Python](https://img.shields.io/badge/Python-3.11%2B-blue.svg) ![AI](https://img.shields.io/badge/AI-OpenAI%20%7C%20Anthropic-green.svg) ![Status](https://img.shields.io/badge/Status-Development-yellow.svg) ![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg) ![Automation](https://img.shields.io/badge/Automation-Translation-orange.svg)

🌐 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


## πŸ“š Table of Contents | 🎯 **Core Sections** | πŸ“– **Technical Docs** | πŸš€ **Advanced Usage** | | :----------------------------------: | :-------------------------------------------------: | :-----------------------------------------------: | | [✨ Features](#-features) | [πŸ”§ Environment Variables](#-environment-variables) | [πŸ“ Processing Templates](#-processing-templates) | | [πŸ› οΈ Installation](#️-installation) | [πŸŽ›οΈ Command Line Options](#-command-line-options) | [πŸ€– AI Provider Setup](#-ai-provider-setup) | | [βš™οΈ Configuration](#️-configuration) | [πŸ“Š Logging](#-logging) | [πŸ“ Examples](#-examples) | | [πŸš€ Usage](#-usage) | [πŸ“œ License](#-license) | [πŸ“« Contact](#-contact) |

✨ 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

πŸ”§ Core Translation Engine

🌐 Multi-AI Support

πŸ“„ Output Management


πŸ› οΈ Installation

Prerequisites

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:

Log Levels


πŸ“« 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](https://www.gnu.org/licenses/gpl-3.0.en.html). 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](/LICENSE) file included in this repository.