• Stars
    star
    1,448
  • Rank 31,633 (Top 0.7 %)
  • Language
    TypeScript
  • License
    GNU Affero Genera...
  • Created over 3 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Alternative front-end for Google Translate

Lingva Translate

Travis Build Vercel Status Cypress Tests License Awesome Humane Tech Powered by Vercel

Alternative front-end for Google Translate, serving as a Free and Open Source translator with over a hundred languages available

How does it work?

Inspired by projects like NewPipe, Nitter, Invidious or Bibliogram, Lingva scrapes through Google Translate and retrieves the translation without directly accessing any Google-related service, preventing them from tracking.

For this purpose, Lingva is built, among others, with the following Open Source resources:

  • Lingva Scraper, a Google Translate scraper built and maintained specifically for this project, which obtains all kind of information from this platform.
  • TypeScript, the JavaScript superset, as the language.
  • React as the main front-end framework.
  • Next.js as the complementary React framework, that provides Server-Side Rendering, Static Site Generation or serverless API endpoints.
  • ChakraUI for the in-component styling.
  • Jest, Testing Library & Cypress for unit, integration & E2E testing.
  • Apollo Server for handling the GraphQL endpoint.
  • Inkscape for designing both the logo and the banner.

Deployment

As Lingva is a Next.js project you can deploy your own instance anywhere Next is supported.

The only requirement is to set an environment variable called NEXT_PUBLIC_SITE_DOMAIN with the domain you're deploying the instance under. This is used for the canonical URL and the meta tags.

Optionally, there are other environment variables available:

  • NEXT_PUBLIC_FORCE_DEFAULT_THEME: Force a certain theme over the system preference set by the user. The accepted values are light and dark.
  • NEXT_PUBLIC_DEFAULT_SOURCE_LANG: Set an initial source language instead of the default auto.
  • NEXT_PUBLIC_DEFAULT_TARGET_LANG: Set an initial target language instead of the default en.

Docker

An official Docker image is available to ease the deployment using Compose, Kubernetes or similar technologies. Remember to also include the environment variables (simplified to site_domain, force_default_theme, default_source_lang and default_target_lang) when running the container.

Docker Compose:

version: '3'

services:

  lingva:
    container_name: lingva
    image: thedaviddelta/lingva-translate:latest
    restart: unless-stopped
    environment:
      - site_domain=lingva.ml
      - force_default_theme=light
      - default_source_lang=auto
      - default_target_lang=en
    ports:
      - 3000:3000

Docker Run

docker run -p 3000:3000 -e site_domain=lingva.ml -e force_default_theme=light -e default_source_lang=auto -e default_target_lang=en thedaviddelta/lingva-translate:latest

Vercel

Another easy way is to use the Next.js creators' own platform, Vercel, where you can deploy it for free with the following button.

Deploy with Vercel

Instances

These are the currently known Lingva instances. Feel free to make a Pull Request including yours (please remember to add [skip ci] to the last commit).

Domain Hosting SSL Provider
lingva.ml (Official) Vercel Let's Encrypt
translate.igna.wtf Vercel Let's Encrypt
translate.plausibility.cloud Hetzner Let's Encrypt
lingva.lunar.icu Lansol Cloudflare
translate.projectsegfau.lt Self-hosted Let's Encrypt
translate.dr460nf1r3.org Netcup Cloudflare
lingva.garudalinux.org Hetzner Cloudflare
translate.jae.fi Self-hosted Let's Encrypt

Public APIs

Nearly all the Lingva instances should supply a pair of public developer APIs: a RESTful one and a GraphQL one.

Note: both APIs return the translation audio as a Uint8Array (served as number[] in JSON and [Int] in GraphQL) with the contents of the audio buffer.

REST API v1

  • GET /api/v1/:source/:target/:query
{
    translation: string
    info?: TranslationInfo
}
  • GET /api/v1/audio/:lang/:query
{
    audio: number[]
}
  • GET /api/v1/languages/?:(source|target)
{
    languages: [
        {
            code: string,
            name: string
        }
    ]
}

In addition, every endpoint can return an error message with the following structure instead.

{
    error: string
}

GraphQL API

  • /api/graphql
query {
    translation(source: String target: String query: String!) {
        source: {
            lang: {
                code: String!
                name: String!
            }
            text: String!
            audio: [Int]!
            detected: {
                code: String
                name: String
            }
            typo: String
            pronunciation: String
            definitions: {
                type: String
                list: {
                    definition: String
                    example: String
                    field: String
                    synonyms: [String]
                }
            }
            examples: [String]
            similar: [String]
        }
        target: {
            lang: {
                code: String!
                name: String!
            }
            text: String!
            audio: [Int]!
            pronunciation: String
            extraTranslations: {
                type: String
                list: {
                    word: String
                    article: String
                    frequency: Int
                    meanings: [String]
                }
            }
        }
    }
    audio(lang: String! query: String!) {
        lang: {
            code: String!
            name: String!
        }
        text: String!
        audio: [Int]!
    }
    languages(type: SOURCE|TARGET) {
        code: String!
        name: String!
    }
}

Related projects

  • Lingva Scraper - Google Translate scraper built and maintained specifically for this project
  • SimplyTranslate - Very simple translation front-end with multi-engine support
  • LibreTranslate - FOSS translation service that uses the open Argos engine
  • Lentil for Android - Unofficial native client for Android that uses Lingva's public API
  • Arna Translate - Unofficial cross-platform native client that uses Lingva's public API
  • Translate-UT - Unofficial native client for Ubuntu Touch that uses Lingva's public API

Contributors

Thanks goes to these wonderful people (emoji key):


David

️️️️♿️ 💻 📖 🎨 ⚠️

Mohammed Anas

💻

TheFrenchGhosty

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Copyright © 2021 thedaviddelta & contributors.
This project is GNU AGPLv3 licensed.

More Repositories

1

scope-extensions-js

Package for using Kotlin's Scope Function Extensions on JavaScript and TypeScript
TypeScript
53
star
2

lingva-scraper

Google Translate scraper for Lingva Translate
TypeScript
41
star
3

kainet-music

Free and Open Source music streaming service
TypeScript
32
star
4

crash

Secret crush matcher for social networks
Kotlin
8
star
5

kainet-scraper

YouTube Music scraper for Kainet Music
TypeScript
5
star
6

pull-the-lever

Extension for saving all your currently open tabs
TypeScript
4
star
7

mySkip

Extension for automatically skipping video ads and closing banner ads on YouTube
JavaScript
3
star
8

myJDoc

Extension for automatically changing to a selected JavaDocs version
JavaScript
1
star
9

web-nextra

Very tiny personal page made with Nextra
TypeScript
1
star
10

campaign-web-template

Template for static single-paged campaign webs
HTML
1
star
11

pruebas_backend

Repositorio donde subir diversas pruebas básicas con lenguajes backend así como requests a ellas
HTML
1
star
12

SpeedwaBot

Simple Discord bot about Jojo's built on NodeJS
JavaScript
1
star
13

dretab

Extension for adding Chromium's "New Tab to the right" to Gecko/Firefox
TypeScript
1
star
14

css-for-js-workshops

Workshops from the CSS for JS devs course by Josh W Comeau
JavaScript
1
star
15

vscode-openerp-code-snippets

Snippets for developing OpenERP modules with Python and XML
1
star
16

hamburgueseria

Hamburguesería vegana pero no mucho
JavaScript
1
star
17

BancoTS

Banco simple en TypeScript
TypeScript
1
star
18

psweet

1
star
19

movie-api-test

TypeScript
1
star
20

Banco

Simple aplicación con el fin de aprendizaje
Java
1
star
21

cloudflare_ddns_node

Dynamically update DNS record on IP change using Cloudflare API
JavaScript
1
star