Giter Club home page Giter Club logo

lingva-translate's Introduction

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.

lingva-translate's People

Contributors

alefvanoon avatar allcontributors[bot] avatar dr460nf1r3 avatar esmailelbobdev2 avatar m2jest1c avatar thedaviddelta avatar thefrenchghosty avatar triallax avatar uhignacio-zz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lingva-translate's Issues

Option to clear contents without affect to language selection

From #9

When click on the logo, it clear contents as expected but with language selection then user has to choose language again if translate to same language and gtranslate doesn't has this behavior

I prefer suggest below options,

  1. Add two different feature to "lingva" and "translate". In this case, you have to customize the logo. I see this as flexible and something new.
    a. if click on lingva, then clear all contents including language selection
    b. if click on translate, then only clear contents that contain on windows
    (or you can add "clear/symbol" button to source window instead)

  2. When tap on the logo then remove contents without clear language selection (as gtranslate)

  3. Ignore this enhancement

instances in a json file

As @den7007 requested, we're adding LinvgaTranslate to LibRedirect, we have also an automatically updatable lists file that gets triggered every 12 hours.
Can the instances be in a json file so we don't have to scrap the repo's README plz?

Ex: instances.json

"lingva.ml",
"translate.alefvanoon.xyz",
"translate.igna.rocks",
"lingva.pussthecat.org",
"translate.datatunnel.xyz"

The issue: libredirect/browser_extension#16

Add paste button to source window

This is a minor enhancement.

Add a paste button to source window (near to play button) then user able to paste any clipboard contents without right-click - paste or ctrl+v (keyboard)

browser extension

hello i have a very good idea. for that .

my English bad . so I use google translate extension
but I don't like ,but I don't have other options to use. i have literally tried every translator extension but this was working good . but u know the google as privacy . so it would be good if lingava could be transformed to a web extension with some good theme and fast ,efficiency

tbh I am not a dev, even don't kwno programing
but I want something like this but in privacy towards.

hope u got the thing so pls think about making it to a extension

Do not interact processing with source editing

Problem Description

Currently it seems lingva let specific time to type word or sentence on source window. i mean it wait specific time after user stopped type, once it exceeded then start to process for translate it.
During process, lingva doesn't allow to type anything on source window however seldom it's possible to modify sentences or type more but once finished translation next recent changes automatically get discarded.

Expected Behavior

Allow users to edit or type more on source window during process then once done recent task next it should check again if there any changes; if any then it must translate content on source window once again.

keep one language fixed

i am using lingva as a web app in my android phone but it's always using detect language instead of fixed language even if i fix it manually , it will reset after i close and re-open , any way to fix this ?

translation_problem(russian): offensive language in translation

1. Summary

I got a hate speech word “педик” in the Lingva translation. I don’t reproduce the problem in Google Translate.

I would like this to be fixed. In addition, I would like if Lingva team to clarify how the offensive term appeared in the translation results.

2. Hate speech word

Lingva translated “queer kids” to “педиков”. See Russian dictionaries and translation dictionaries꞉ “педик” in Russian means an offensive, derogatory word for a homosexual man. This word has about the same meaning as the English words “fag” and “faggot”.

3. Steps to reproduce

I copy the text from Google Books

The essays range from discussions of Diderot, Oscar Wilde and Henry James to queer kids, political correctness adn the poetics of spanking.

I selected translation from English to Russian → I translated this text on the official websites of Lingva and Google Translate.

4. Results

4.1. Lingva.ml

Lingva.ml translation (archive copy)꞉

Lingva.ml result

4.2. Google Translate

Google Translate translation

Google Translate result

As you can see, Google Translate translated “queer kids” to “странные дети”, not to “педиков”.

Thanks.

Open a Saved Language Setting

Hello

Everytime, when I open the website, it opens with Detect Language and English.

Also I tried with https://lingva.ml/en/zh/ but still it opens with detect language.

For me I frequently use Chinese to English and Vice Versa, can you make an option, so that we don't have to select language everytime?

Flip Language Shortcut

Have been looking for a front end for a while, this is a great implementation!

However I do find the Google Ctrl + Shift + S shortcut--which switches the input language--very helpful.

Maybe this could be a future addition/enhancement.

Regards

Add instant translate feature

I continue to switch back to normal google translate because of the need to press translate everytime I enter a word, I would appreciate if this feature could be implemented

Dark theme by default

It would be nice to have an environment variable (for docker) or/and a way to enable the dark theme by default.

some question about this software

hi, sorry for my bad English,
I have not installed this software, but I have some questions:

  1. are this software can work offline (without connection from the internet)?
  2. will in the near future, this software be available in python or Windows Command Line Interface(CMD/Batch/Powershell)?

thank you, have a nice day

Detected language is not shown

Hi David

Thanks for creating this, I just tried this out after seeing your fediverse post.

I noticed that the detected language is not shown, so you don't actually know as what language a phrase was detected as.

You were added to awesome-humane-tech

This is just a FYI issue to notify that you were added to the curated awesome-humane-tech in the 'Translation' category, and - if you like that - are now entitled to wear our badge:

Awesome Humane Tech

By adding this to the README:

[![Awesome Humane Tech](https://raw.githubusercontent.com/humanetech-community/awesome-humane-tech/main/humane-tech-badge.svg?sanitize=true)](https://github.com/humanetech-community/awesome-humane-tech)

https://github.com/humanetech-community/awesome-humane-tech

reverse proxy?

Is it possible to put lingva behind reverse proxy?

I've tried with docker-compose (with both SITE_DOMAIN= and NEXT_PUBLIC_SITE_DOMAIN = ) but it doesn't work.
In the logs below the "url: http://localhost:3000" seems to indicate that the values after either SITE_DOMAIN or NEXT_PUBLIC_SITE_DOMAIN are ignored.

And also by the way, not sure which one of these 2 variables NEXT_PUBLIC_SITE_DOMAIN or SITE_DOMAIN to use since both are hinted at in the docs.

Logs from lingva:
Starting lingva ... done
Attaching to lingva
lingva | yarn run v1.22.5
lingva | $ next build
lingva | info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
lingva | info - Checking validity of types...
lingva | info - Creating an optimized production build...
lingva | > [PWA] Compile client (static)
lingva | > [PWA] Auto register service worker with: /app/node_modules/next-pwa/register.js
lingva | > [PWA] Service worker: /app/public/sw.js
lingva | > [PWA] url: /sw.js
lingva | > [PWA] scope: /
lingva | > [PWA] Compile server
lingva | info - Compiled successfully
lingva | info - Collecting page data...
lingva | info - Generating static pages (0/4)
lingva | info - Generating static pages (1/4)
lingva | info - Generating static pages (2/4)
lingva | info - Generating static pages (3/4)
lingva | info - Generating static pages (4/4)
lingva | info - Finalizing page optimization...
lingva |
lingva | Page Size First Load JS
lingva | ┌ /_app 0 B 179 kB
lingva | ├ ● /[[...slug]] 5.75 kB 185 kB
lingva | ├ └ /
lingva | ├ ○ /404 (692 ms) 289 B 179 kB
lingva | ├ ○ /500 282 B 179 kB
lingva | ├ λ /api/graphql 0 B 179 kB
lingva | ├ λ /api/v1/[[...slug]] 0 B 179 kB
lingva | └ λ /api/v1/languages/[[...slug]] 0 B 179 kB
lingva | + First Load JS shared by all 179 kB
lingva | ├ chunks/framework.c93ed7.js 42.6 kB
lingva | ├ chunks/main.b7dd7b.js 25.3 kB
lingva | ├ chunks/pages/_app.ed78be.js 110 kB
lingva | └ chunks/webpack.70ff54.js 866 B
lingva |
lingva | λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
lingva | ○ (Static) automatically rendered as static HTML (uses no initial props)
lingva | ● (SSG) automatically generated as static HTML + JSON (uses getStaticProps)
lingva | (ISR) incremental static regeneration (uses revalidate in getStaticProps)
lingva |
lingva | Done in 32.90s.
lingva | yarn run v1.22.5
lingva | $ next start --port ${PORT-3000}
lingva | ready - started server on 0.0.0.0:3000, url: http://localhost:3000

Show pronunciation text, verified status and 'definition of word' and 'translations of word' for available strings

Thank you so much for develop this front-end web app 🥇 ❤️

1. Show pronunciation text.

Why it is important? I saw lingva offer option for play audio about translated word but it still difficult to recognize then user need to go to gtranslate site.

Read book
image

2. Show verified status for available words and sentences**

Why it is important? It help to trust the specific translation bit more and less possibility to incorrect.

3. Add definition of word and translations of word components

Why it is important? it helps to gather more details about the word and if it other language word than to most popular english then more useful for reader and get meaning of it in depth.

image

3.1. Option to search appeared words in translation of word component

If you able to implement it successfully then let to re-search each words appeared in translation of book component result. as you know, it's simple enhancement, put words to search box when tap.

4. Show other available words for the translation

Gtranslate has a option to view other available words for the translation. If that also possible to take then we have complete front-end, but i dont know if that easy possible and may be tricky

Why it is important? - There're many translations are not verified and incorrect for many languages (some times verified translation also not perfect) then that feature helps check other available translations for it

image

Some translations return the translation as a key

With an API call some translations return the translation as a key so the string ends up being empty. For example translating from Armenian to German for the word 'work' returns:

{"translation":"Arbeit:"}

The same is true for Farsi.

The issue is not with non-latin characters, as I checked Japanese, and it works as expected.

Lingva doesn't respect the WCAG standards for accessible text

Lingva currently doesn't respect the WCAG standards for accessible text: the contrast between background and foreground content isn't high enough.

Note: automated checkers aren't, for whatever reason, able to see the issue, but it's those texts:

light theme
dark theme

WebExtension

It would be great to have this available as a WebExtension, for translating small pieces of text as well as webpages.

Display alternate translations

When using Google Translate alternate translations are displayed for each word entered. This helps a lot when translating words that vary based on context or may have regional variations.

I see from #8 that Lingva has some limitations because it scrapes the mobile version of Translate. However, alternate translations are displayed on mobile translate, so the scraping shouldn't be an issue in this circumstance.

Thanks.

encoding slahes/URLs for API requests

hi, thx for this v cool project.

i hacked up a tiny interface to the API in emacs, and i'm sorting out issues with it as they come up.

today i tried to send a query that included forward slashes in it. i hexify the request, so the / becomes %2F in my query string, but the request still fails with a 404. i assumed this was me just being incompetent, but i just tried it now using a REST API client, and with curl, and it still fails.

my curl example looks like this

curl -i -XGET https\://translate.igna.rocks/api/v1/en/fr/test\%2Ftest

can you see if i'm doing anything wrong?

thanks for any pointers, and for the package itself again.

Change port docker

I ran the following command as port 3000 on my server is busy:

docker run -p 3030:3030 -e site_domain=example.com thedaviddelta/lingva-translate:latest

Once this finished running, NextJS tried to run the server on 3000 instead. Is there any way this can be fixed?

New instance!

Hi! I am hosting an instance of Lingva at translate.datatunnel.xyz!
Hosting at Hetzner using Let's Encrypt :)

Would you be so kind to add it to the list?

a suggestion

I would like to make a suggestion, is it possible to set two more environment variables for setting the default translation language?

Logo link back to lingva

it helps to load the lingva home page quick and clear any recent contents. that must be compatible to use self-host instances domains

Docker image for the project

It would be easy to integrate the project self-hosted services if we could have a docker-compose file, building docker-compose for NextJS is pretty easy and I guess it would help everyone

Multiple engines/backends

Currently lingva is based on google translate, which performs well but it is not the only choice. There are translators from microsoft, yandex and deepL as well as open source ones like apertium and https://libretranslate.com/

I think adding those engines would be great and is consistent with the goals of the project. Proprietary ones have privacy issues and user may want use them with a FOSS client and open source ones become promoted by being as an alternative here.

An abstraction on engines creates a path for contributors who want to add their favorite engine.

Move the link to the Github repository to the footer

Having the link to the Github repository on the header is unnecessary in my opinion, 99% of the users don't need to go on Github.

Having it moved to the footer (with clickable text) will make the UI "clearer" in my opinion.

Site is broken without JavaScript

The README of this repository seems to say the pages are server-side rendered. However, it does not seem possible to use the website without enabling JavaScript. Could this be added as an option?

Is it possible to prepare a link for translation?

I would like to set two specific languages (from - to), but if I try lingva.ml/en/xx/ it directs me to lingvia.ml/auto/en/xx/. Is there a correct way to do this? This way I can circumvent scrolling true all the languages each time.

Auto dark mode

Hi,
This is an awesome project!, I just have a small suggestion.

Instead of manually switching to or from light mode, why not follow the device's prefer-color-scheme?
I think it should be relatively easy to implement.

[FEATUER REQUEST] Enable suggestions of a wrong words?

As a non native english speaker I really missspill a lot of words and my main usage of google translation was accuracy and it's function to correct my weird words.
image

Lingva already got accuracy as it pulls from google but now i lack option of correction, I think of 2 ways to solve this:

  • Inside HTML. enable tag to let browser scan words and correct them [super easy] but corrections won't be as much as good
  • pull corrected words from google as you already pull translation [kinda hard] but it would be nice!

[Question] It Uses Google Translate but No Google Services?

Alternative front-end for Google Translate . . . Lingva scrapes through GTranslate and retrieves the translation without using any Google-related service, preventing them from tracking.

Sorry if these are dumb questions, but I'm confused. The description says it's a front-end for Google Translate. Then it says it "scrapes through GTranslate". GTranslate (GTranslate.io) is "a leading website translation services provider". Is it scraping through some data provided by GTranslate? Or is GTranslate in this context shorthand for Google Translate?

Then it says it "retrieves the translation without using any Google-related service". If it's a front-end for Google Translate, then it's using at least one Google-related service—Google Translate. What am I misunderstanding here?

Sorry if I'm being dense. This project looks interesting, but I want to understand how it relates to Google before I begin using it.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.