Giter Club home page Giter Club logo

instanttranslate's Introduction

Instant Translate

This add-on is used to translate selected and/or clipboard text from one language to another. This is done using the Google Translate service.

Configuring languages

To configure source, target and in case swap language, go to: NVDA Menu >> Preferences >> Instant Translate Settings.

There are two comboboxes labeled "Source language" and "Target language", and a checkbox to decide if it must copy the translation to clipboard.

In addition, if you selected auto option (the first choice) from "Source language" combobox, there are also a combobox labeled "Language for swapping" and a checkbox about the auto-swap.

The meaning of two first comboboxes and checkbox for copy is clear, but some words about the rest are necessary. Remember always that the explanations below assume the source language set on the auto option.

The "Language for swapping" combobox is useful when you swap via script (see below) the source and target language; in fact, a target language set on the auto option has no sense, so the addon sets it to value of combobox above.

So, imagine this situation: you usually translate into English (your main language), but sometimes (for example, when you write a document) you need to translate into Italian (your second language, suppose); you can set "Language for swapping" combobox to Italian, so you will translate from English to Italian without accessing directly to the addon settings. Obviously this function has a major or minor utility according to your more frequent needs.

Now, the auto-swap checkbox: it appears if and only if you set the auto option in "Source language" combobox, and is directly connected with "Language for swapping" combobox. If you activate it, then the addon tries to commute automatically from your source and target configuration to a configuration where target becomes the source language, and language selected in "Language for swapping" combobox is the new target language; extremely useful if the source language of the text you want translate is the target language.

A simple example: take again in mind the situation imagined previously; if you translate a text in a language different from English, there is no problem, you get the correct translation in English. But if you need to translate a text from English, normally you get a translation into English identical to original text, and this is a bit useless. Thanks to auto-swap function, however, assuming that you want to know how your text sounds into Italian, the addon commutes automatically the target language to Italian, so it returns a valid translation.

Anyway, this is a temporary configuration; if this option has no effect (it's experimental), try to commute manually to a stable configuration, using the gesture for swapping described below. It's experimental because in some situations (with short texts, typically), Google does not recognize the real source language correctly, and you have to swap languages manually via script, so to force the source language to be the previous target language (English in our example).

At least, in the speech settings parameters dialog (NVDA Menu >> Preferences >> Speech), you may want to check the "Automatic language switching (when supported)" option. This way, if you are using a multi-lingual synthesizer, the translation will be announced using the target language voice of the synthesizer.

Using

You can use this add-on in three ways:

  1. Select some text using selection commands (shift with arrow keys, for example) and press associated key to translate. translation result will be read with synthesizer which you are using.
  2. You can also translate text from the Clipboard.
  3. Press the dedicated shortcut key to translate the last spoken text.

Shortcuts

All following commands must be pressed after modifier key "NVDA+Shift+t":

  • T: Translate selected text,
  • Shift+t: translate text from the Clipboard,
  • S: swap source and target languages,
  • A: announce current configuration,
  • C: copy last result to clipboard,
  • I: identify the language of selected text,
  • L: translate the last spoken text,
  • O: open translation settings dialog
  • H: announces all available layered commands.

Changes for 4.7

  • Updated to be compatible with python3.11 and nvda 2024.1
  • Implemented speakOnDemand mode
  • Fixed case with caching failled translations
  • Added chinese mirror for translation

Changes for 4.4.2

  • Restore language detection and auto-swapping (Thanks to Cyrille for fix)
  • updated languages for translation (thanks to Cyrille)

Changes for 4.4

  • Instant translate is now compatible with NVDA 2019.3 (Python 3 versions of NVDA)

Changes for 4.3

  • nvda compatibility fix Now instant translate will be compatible with latest nvda builds.
  • found a way to use google as a translation service again.

Changes for 4.2

  • Restored working state with newer versions of nvda.
  • Restored automatic language detection.

Changes for 4.1

  • InstantTranslate is working again, now with Yandex translator service instead of Google.

Changes for 4.0

  • Translation is automatically performed after swapping.
  • Cache bug fixed.

Changes for 3.0

  • Change way how Shortcuts are used, now you can press instantTranslate modifier key "NVDA+Shift+t", and then single letter key to perform some action (see all Commands in the "Shortcuts" section).
  • Implemented swapping languages.
  • Changed configuration format, now we can change instant translate settings if we are in readonly pane, but remember that this will work before first restart of NVDA.
  • Removed limit on amount of text that can be translated.
  • Added shortcut t to the Instant Translate Settings menu item
  • The auto option is now in first position in source combo, and absent in target combo.
  • Added a checkbox for configuring copying translation results.
  • Store config file in the root of settings folder.
  • Source and target languages syncronized with what Google Translate currently exposes (22 Apr 2015).

Changes for 2.1

  • Now addon can translate text from clipboard when pressing nvda+shift+y.

Changes for 2.0

  • Added gui configurator where you can choose source and target languages.
  • Added addon menu item found under preferences menu.
  • Settings now is written in separate config file.
  • Translation results now automatically copies into the clipboard for future manipulations.

Changes for 1.0

  • Initial version.

instanttranslate's People

Contributors

abuffer avatar beqabeqa473 avatar cyrilleb79 avatar grisov avatar josephsl avatar leonardder avatar mhameed avatar ogomez92 avatar tspivey avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

instanttranslate's Issues

Allows role and state of controls to be ignored from "Last spoken" and "Auto-translation"

Many times, one may wish to translate the interface of a non-native language software, for example:

| Control name | Control role or state for chinese |
| Cancel | 按钮 |
| I agree | 复选框 已选中 |

For the above example: we only want the control name to be translated to Chinese, while the roles and states depend on the OS language, which in my case is Chinese, and do not need to be translated.
If a control's role and state are part of the translated text, automatic language detection will fail.

Thanks

Support saving settings in the active profile rather then globally

from #nvdaaddons/issues/12

When you swap your language preferences, or set a new language from the options page, the new selection won't saved on current active profile (if exist). But rather it saves and uses them globaly all the time.
steps to produce

  1. Create multiple profiles:
  2. Set source and target language from settings panel
  3. Activate a profile
  4. Repeat 2 with two new languages.
  5. Check, Your main settings also changed.
    I will create a pull request to show how I fixed it, but it is probably a very bad way of solving this problem. So please track if there's anything wrong with nvda unless this is a new feature, even so let's add it as a personaliozed feature and let users select if they wanna use settings globaly or not.

Automatic translation

it should be possible to turn on autotranslate mode in instanttranslate which would decorate speak method and translate text.

Do not cache empty translation results

If the translation result is empty, don't cache it.

Steps to reproduce

  1. Disconnect from the Internet.
  2. Try to translate a piece of text from one language to another.
  3. Connect to the network.
  4. Perform step (2).

Actual Behavior

Perform step (4), the translation result is empty.

Expected Behavior

Perform step (4) to get the translation result.

multiple translation profile pairs

make it possible to add several language pairs for translation from gui, which could be moved up/down, and could be activated, first 10 slots in the layerd gestured, or by defining a gesture manually

Cache issue

Hi Beqa,

Here is an issue:

STR:

  1. Set the source language to auto, the target language to French and the swap language to English; also ensure that auto-swapping is checked.
  2. Translate a French sentence, e.g. "NVDA est un lecteur d'écran formidable.".
  3. Set the swap language to Italian.
  4. Translate exactly the same French sentence as step 2.

Actual result

At step 2. translation is made in English as expected ("NVDA is a great screen reader.").
At step 4. translation is made in English.

Expected result

At step 4. translation is made in Italian.

Additional information

When you cache the result, you should search in the cache with all the inputs that were used to make this translation, i.e. source, target, swap, allow auto-swapping, is auto-swapped, replace underscores.
If you search the cache with only source and target, you may end up with various results if the other options are changed.

InstantTranslate error with NVDA 2019.2.1

Issue description

When running NVDA 2019.2.1 with Instant Translate, I get the following error in the log:

ERROR - eventHandler.executeEvent (10:21:14.907):
error executing event: selection on <NVDAObjects.IAccessible.sysListView32.ListItem object at 0x054668D0> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.pyo", line 155, in executeEvent
  File "eventHandler.pyo", line 92, in __init__
  File "eventHandler.pyo", line 100, in next
  File "NVDAObjects\IAccessible\__init__.pyo", line 1478, in event_selection
  File "NVDAObjects\IAccessible\sysListView32.pyo", line 304, in event_stateChange
  File "NVDAObjects\__init__.pyo", line 1016, in event_stateChange
  File "speech.pyo", line 352, in speakObjectProperties
  File "speech.pyo", line 459, in speakText
  File "C:\Users\CB232690\AppData\Roaming\nvda\addons\instantTranslate\globalPlugins\instantTranslate\__init__.py", line 319, in _localSpeak
AttributeError: 'module' object has no attribute 'SPEECH_ITEM_SEPARATOR'

Expected result

No error

Possible solutions

  1. Fix the error
  2. Drop the support of NVDA 2019.2.1 that becomes a bit old. If you choose this path, the transition to NVDA 2022.1 could be a good timing to drop Python 2 compatibility.

Context

I am using NVDA 2019.2.1 for test purpose only.

Translation Error

The following error is occurring on the translation server, preventing translations from happening

svn status
mn/add-ons/instantTranslate/nvda.po:207: duplicate message definition...
mn/add-ons/instantTranslate/nvda.po:205: ...this is the location of the first definition
msgmerge: found 1 fatal error
mr addon2svn: command failed

Add language slot option

Hi,

I came across several discussions about this feature in several Telegram groups, and since I know that you are planning to rewrite the add-on from scratch, I am opening this issue on GitHub to save it as history for future implementation in the add-on.

It will be a nice feature if you add a favorite language slot option. If the user wants to translate from English to Russian or from Russian to German, he can assign different slots and gestures to the slot to quickly switch to the favorite language selected for translation.

Perhaps no slot is required and all it takes is a gesture to create your favorite language set for translation, but how you choose to implement this is up to you.

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.