Languine AI Localization Platform

repository·main·Indexed 24 days ago

https://github.com/languine-ai/languine

A self-hosted, Vercel-native AI localization platform for automating translations via a CLI or GitHub Action. Powered by Vercel Workflows and Vercel AI Gateway, it supports over 18 translation formats including JSON, YAML, MDX, XLIFF, and Android XML. The platform includes a web dashboard for project management and integrates with tools like Expo for mobile app localization.

Tokens
21.9K
Snippets
43
Records
156
Agent score
84%

What's inside Languine

  1. How Languine architecture works

    main

    Languine is designed as a Vercel-native application. The architecture relies on several key components:

    • Web Dashboard: A Next.js app hosted on Vercel that manages projects and configuration.
    • Authentication: The dashboard is secured via Vercel Deployment Protection. The CLI and GitHub Action authenticate using a single LANGUINE_API_KEY.
    • Background Processing: Long-running translation tasks are handled by Vercel Workflows, which provide durable and resumable execution.
    • AI Orchestration: All AI requests pass through the Vercel AI Gateway, allowing you to switch between models (like OpenAI or Anthropic) via a single configuration (AI_MODEL).
    • Data Persistence: A serverless Postgres database managed via Drizzle ORM.
  2. Deploy Languine via Vercel

    main

    Languine can be deployed as a self-hosted, Vercel-native AI localization service using the one-click deploy button. This process forks the repository, creates a Vercel project using apps/web as the root, and provisions a serverless Postgres database via the Vercel Marketplace.

    Post-deployment steps:

    1. Enable Deployment Protection: In your Vercel project settings, go to Settings → Deployment Protection and enable Vercel Authentication or Password Protection. This is critical to prevent your LANGUINE_API_KEY from being publicly exposed via the dashboard or /cli/token.
    2. Initialize via Dashboard: Open your deployment URL to see a status checklist and ready-to-use CLI commands.
    https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flanguine-ai%2Flanguine&project-name=languine&repository-name=languine&root-directory=apps%2Fweb&env=LANGUINE_API_KEY,AI_MODEL&envDescription=LANGUINE_API_KEY%20is%20a%20random%20token%20you%20pick%20(e.g.%20%60openssl%20rand%20-hex%2032%60).%20AI_MODEL%20is%20optional%20(default%20openai%2Fgpt-4.1).&envLink=https%3A%2F%2Fgithub.com%2Flanguine-ai%2Flanguine%23environment-variables&stores=%5B%7B%22type%22%3A%22postgres%22%2C%22productSlug%22%3A%22neon%22%7D%5D&demo-title=Languine&demo-description=Self-hosted%20AI%20localization%20on%20your%20own%20Vercel%20account&demo-image=https%3A%2F%2Fraw.githubusercontent.com%2Flanguine-ai%2Flanguine%2Fmain%2Fapps%2Fweb%2Fsrc%2Fapp%2Fopengraph-image.png&demo-url=https%3A%2F%2Flanguine.ai
  3. Set up the React Email Starter

    main

    To use the React Email Starter, which provides a live browser preview for email development, follow these steps to install dependencies and start the development server.

    1. Install the project dependencies using npm or yarn.
    2. Start the development server.
    3. Access the live preview at http://localhost:3000.
    npm install
    npm run dev
  4. Translate project keys with Languine CLI

    main

    The translate command performs diff-based translation. It only translates keys that have changed since the last commit, as tracked via the languine.lock file. This supports over 18 formats including JSON, YAML, MDX, .strings, .xcstrings, .arb, .po, XLIFF, Android XML, PHP, Properties, CSV, Fluent, raw HTML, and JS/TS modules.

    npx languine@selfhosted translate
  5. Set up Languine for local development

    main

    To run Languine locally, clone the repository and use bun to install dependencies and run the development server. Note that you must provide an AI_GATEWAY_API_KEY in your local .env file to allow the AI Gateway to authenticate when running outside the Vercel environment.

    git clone https://github.com/languine-ai/languine
    cd languine
    bun install
    cp apps/web/.env.example apps/web/.env  # fill in DATABASE_URL etc.
    bun dev
  6. Authenticate with the Languine CLI

    main

    To authenticate the CLI with your self-hosted deployment, use the login command. You must provide the URL of your deployed Vercel application.

    Note: Use the @selfhosted dist-tag to ensure you are using the v4 CLI compatible with the self-hosted backend. Using @latest will resolve to the legacy 3.x CLI for the hosted SaaS service.

    npx languine@selfhosted login --url https://languine.your-team.vercel.app
  7. Use Languine CLI in CI or non-interactive environments

    main

    For automated environments like CI/CD or scripts, avoid interactive login by providing the LANGUINE_BASE_URL and LANGUINE_API_KEY via environment variables.

    Ensure LANGUINE_API_KEY matches the key you configured during your Vercel deployment.

    export LANGUINE_BASE_URL=https://languine.your-team.vercel.app
    export LANGUINE_API_KEY=<the-key-you-set-on-vercel>
    npx languine@selfhosted translate
  8. Use the Languine CLI

    main

    The self-hosted CLI is distributed under the selfhosted npm dist-tag. To avoid conflicts with the legacy hosted service (which uses languine@latest), you must explicitly use @selfhosted or pin version ^4 in your package.json.

    Interactive Setup

    Use these commands for manual setup in your local development environment:

    1. login: Opens /cli/token in your browser. Copy the API key from the protected page and paste it into the CLI.
    2. init: Creates a new project on your deployment and saves the projectId to languine.json.
    3. translate: Runs the translation process.

    Non-interactive (CI/CD) Setup

    For automated environments like GitHub Actions or scripts, provide the credentials via environment variables instead of interactive prompts.

    # Interactive usage
    npx languine@selfhosted login --url https://languine.your-team.vercel.app
    npx languine@selfhosted init
    npx languine@selfhosted translate
    
    # Non-interactive usage (CI/CD)
    export LANGUINE_BASE_URL=https://languine.your-team.vercel.app
    export LANGUINE_API_KEY=<the-key-you-set-on-vercel>
    npx languine@selfhosted translate
  9. Configure localization in Expo with Languine

    main

    This project uses Expo Localization for managing multiple languages. The localization setup is organized into three main parts:

    • locales/i18n.ts: The central i18n configuration file.
    • locales/{lang}.json: Standard translation files for each supported language.
    • locales/native/{lang}.json: Metadata translations specifically for the native app environment.
  10. Reset the Expo project to a blank state

    main

    If you want to start developing from scratch, run the reset-project script. This will move the existing starter code into an app-example directory and provide a clean, blank app directory for your own development. This project uses file-based routing within the app directory.

    npm run reset-project