Extension: Rooster Lesson Translator -> Automatic translations for LingQ lessons

ROOSTER WEB EXTENSIONS CATALOGUE

ROOSTER LESSON TRANSLATOR FOR LINGQ
Browser extensions to translate your LingQ lessons.

ROOSTER LESSON TRANSLATOR FOR LINGQ COMMUNITY VERSION

@bamboozled Also supplied the code to make this a reality. Give them some love.

LATEST PATCH

Patch Notes

INSTALL THIS SOFTWARE

INSTALL
FIREFOX | CHROME | SOURCE CODE

PICTURE EXAMPLES

→ Translate own lessons → Choose the translation language
image
→ Translate other peoples lessons (displayed in a resizable popup)

FEATURES | LIMITS

→ This software automatically creates a translation and then applies it to your lesson.
→ If the lesson is not yours a popup is displayed

The below features apply to Firefox Only. Chrome has a hard limit of 100 sentences.
→ A translation limit and speed is applied depending on your LingQ subscription status.
→ Free Users are limited to translating 50 sentences per lesson.
→ Premium members receive unlimited translations
→ Librarians receive a 50% speed boost

HOW TO USE THIS SOFTWARE

→ This button opens the Rooster Translate display
image

→ Your text will be translated to the language in the URL as default
image

→ Change translation language to whichever option you want.
image

HOW TO ACCESS
→ Go to /listen or /reader in the LingQ URL.
image
image

→ Click Translate button
image
image

→ Lesson has Translation
image

→ Translation is also available raw in the developer tools (press F12 and click Console)

PAIRED EXTENSIONS

→ Pair with Rooster Reader Extension to create automatic scrolling translations.
→ Pair with Rooster Lesson Editor to quickly format and translate lessons.

7 Likes

Good Job. This is exacty what I have been looking for. Is Chrome version coming soon?

I think you should get a permanent job with LingQ and implement all of these changes in the LingQ system , if possible. An efficient LingQ will attract more customers.

1 Like

Hi @asad100101

Thanks for your support.
Send me a message and I’ll get you setup with a no limit version on Chrome right now.

Sorry, was afk for a moment. To enable this for all lessons, not just your own, use a different url. This also simplifies the code get_indexes function. I don’t think we can get away with just one API version unfortunately. Maybe give this a try:

Summary
INDEX_URL = f'https://www.lingq.com/api/v3/{LANGUAGE}/lessons/{LESSON_ID}/sentences/'

def get_indexes():
    response = requests.get(INDEX_URL, headers=HEADERS)

    if response.status_code == 200:
        data = response.json()
        indexes = []

        for item in data:
            index = item.get('index')
            indexes.append(index)

        return indexes
    else:
        print(f'Error: {response.status_code}\nResponse: {response.text}')
        return []
1 Like

What happens in this code is if the lesson is not yours to edit it breaks at the getindex stage. So it’s not a bad check for own lesson. I’ll implement a change that displays the sentences in a manipulable GUI if it’s not your lesson.

1 Like

It must be because I’m the librarian. Maybe it’s not a bad restriction for the add-on. I’m sure there is a way to get access to the individual sentences. But without documentation it’s just trial and error. It’s probably not important enough to spend time on it.

Check out my Rooster Lesson Extractor addon :slight_smile:

Yes, Librarian privilege should extend that entire language. I’ve dropped the uncapped version source code in the chat.

1 Like

I think I found a suitable URL that might be accessible to all users(potentially?). But I’m a little afraid setting everything to “google translate” might bulldoze human made translations. I won’t spend more time on this, your version is already good enough as is.

Summary
INDEX_URL = f'https://www.lingq.com/api/v3/{LANGUAGE}/lessons/{LESSON_ID}/simple/'

def get_indexes():
    response = requests.get(INDEX_URL, headers=HEADERS)

    if response.status_code == 200:
        data = response.json().get('tokenizedText', [])
        indexes = []

        for item in data:
            if isinstance(item, list):
                for subitem in item:
                    tokens = subitem.get('tokens', [])
                    for token in tokens:
                        index = token.get('index')
                        if index is not None:
                            indexes.append(index)

        return indexes
    else:
        print(f'Error: {response.status_code}\nResponse: {response.text}')
        return []
1 Like

The /simple URL should be accessible yes. That’s the URL I use in basically every extension to collect initial data. It’s light enough and not cluttered with too much unnecessary stuff.

1 Like

Big new patch just released for Auto Translate. Check it out.

How do I find it?
Post must be at least 20 characters.
How do I find it?

The addon isn’t approved yet on Firefox. They are usually pretty quick. Maybe check again in a few hours. The source code is available to download if you want to manually install. Instructions are on the bottom of the 1st post on the main page.

LATEST PATCH V1.13 - ROOSTER LESSON TRANSLATOR

→ Translates to language displayed in your URL as a default
image
→ Change language to another option if you want
image
→ Button added to LingQ menu
image

edit: Lesson translator is now live on Firefox and Chrome

1 Like

LATEST PATCH V1.14 - ROOSTER LESSON TRANSLATOR COMMUNITY VERSION

LIMITATIONS - READ ME

PATCH 1.14 IS ONLY COMPATIBLE WITH FIREFOX BROWSER
I HAVE SUBMITTED A DIFFERENT VERSION OF THIS PATCH TO CHROME WHICH IS NOW 100 SENTENCES FOR ALL USERS UNTIL I FIGURE OUT THE PROBLEM

→ BIG PATCH FOR LINGQ SUBSCRIBERS AND LINGQ LIBRARIANS

→ LingQ Lifetime Premium and Monthly premium subscribers can now use this add-on without any translation limit.

image

LingQ Librarians get a 50% reduction in translation time as well as unlimited translations.

LingQ Librarians Picture

This patch is now Live on Firefox for all users and the chrome version will be available tomorrow.

Wow! Nice work again!

I decided to try out the Lesson Translator on a Korean video that only had TL text, and the translation seems pretty darn good.

So far as I can tell (as a beginner and with the help of DeepL—free version, lol). There was one awkwardly worded sentence, but the translation is strong.

This is impressive!

P.S. I’ll have to work with it more, but I wanted to share my initial thoughts. (Just Wow! :smiley: ) Where are the free translations sourced from?

1 Like

@srdurden mentioned this to me.

Translations are requested directly from the LingQ server. Its basically just going to every sentence in sentence mode, pressing translate, gathering results and apply to your lesson.
In a future premium version I will likely allow translations from other sources.

1 Like

Interesting, I didn’t know LingQ had sentence translation ability, but I have been seeing a lot of mentions of it lately on the Forum… I thought it only worked if you highlight up to 9 words in reader mode. :laughing:

Thanks for the info!

Is it possible to add a premium feature that allows you to create/display multiple of the same type of translations for a given translation?

For Example:

Human Translation [English Translation 1]: [Translation from the video, or if you’re basically a translator yourself—not me—or just want to put in your own tweaked translation]
Direct Translation [English Translation 2]: [Translation that keeps the original structure of the sentence, so you can understand how the sentence is laid out but still see the actual words in your native language—not sure if any programs do this, but one way for users to do this is to write out their LingQ definitions in a pseudo-direct-translation style]

Here is an imperfect example of something that a user can use to (aid them in) creat(ing) a direct translation if tools like this aren’t as accessible/don’t exist:

Edit: Screenshot from Mirinae - Korean Language Explorer — credit to them

Being able to display multiple translations in a sentence would be really helpful (and being able to export this as an additional field to Anki would be great, too)!

P.S. Not sure if it exactly fits into the Rooster Lesson Translator, but since it regards a type of translation, I thought I would pop this here.

1 Like

hey @jpp025

I have this listed under Rooster Reader premium.
It would be possible to bring this to my extensions but its not possible within the LingQ interface to add a second translation to a lesson. One way I could possibly do this would be to hijack the “Notes” for each sentence and then write some code that modifies the display of the LingQ reader to append the notes under the translation. Or just display them as an additional box in Rooster Reader.

To get your translation we do something like this.

Code
# Function to translate a text
def translate_text(text, input_language, target_language, translation_type, model='gpt-3.5-turbo-16k', temperature=0.5, max_tokens=8000):
    # Forming the translation prompt
    if translation_type == 'Literal':
        prompt = f'Translate the following {input_language} text to {target_language} literally: "{text}"'
    else: # 'derived'
        prompt = f'Translate the following {input_language} text to {target_language} idiomatically: "{text}"'

This is a good suggestion and ill keep it in mind.

I’ll put this on the notes to export the “Notes” if I go that route.

edit: what the f, I just thought… add the second translation to some obscure language and we can call it like that. like set the literal translation as a Zulu translation or something.

Alright what I’m going to do with this is… Allow you to set a custom translation in lesson editor. with that 2nd translation it will be displayed as an additional box in rooster reader free. i’ll get cracking.

Either of these might work, as I tend to use the notes section (due to the limitations of LingQ) to do something similar to what I described above.

Ah, Makes perfect sense to have it there now that I think about your feedback in this reply!

hmm… This is an interesting thought, but if other users are learning Zulu (or _____ more obscure language), would that through things off for other users?

1 Like