Nova

Extensions

Translate In Place
Run Code Run Inc.
Highlight a block of text and Translate in Place will translate it to any supported language you've chosen. TIP is powered by Google Translate and *your own* Google "Cloud Translation API" key. My understanding of their pricing (at the time this was written) is that it's free for the first 500,000-characters/month. See documentation for details and how-to. (Takes ~10 minutes to set up.)
Install
181 Installs
This extension is allowed to:
  • Send Network Requests

Readme

Translate In Place (TIP) will translate highlighted text into your currently selected target language. TIP is Powered by Google Translate and your own Google "Cloud Translation API" key. My understanding of their pricing (at the time this was written) is that it's free for the first 500,000-characters/month.

Since Google Cloud has hundreds of services, setting up a Cloud Translation API key takes a little effort through a somewhat convoluted maze, but I've tried to document process below. It should take about 10 minutes.

Google Cloud pricing is a little unclear, so you should definitely make yourself comfortable with the pricing as they describe it (not as I describe it), and continue to monitor what you are charged (e.g., through their 'Budget & Alerts' feature). Cloud Translation Pricing

Preferences

Your Google "Cloud Translate API" key should be entered in the Extension preferences.

The language you are translating from and to is set in the Project preferences. (It doesn't auto-detect the source language at this time.)

You can also set characters to appear before and after blocks of ➡️translated text⬅️ (e.g., if you wanted to get a rough translation now, but also wanted someone to review the translation later).

Registering for a Google 'Cloud Translate API' Key

Create a Google Cloud account if you don't have one already.

Depending on what you already have set up with Google, the steps to add their Translate API may vary. The process is a little arcane but should only take you 10 minutes. Hopefully the outline below is enough to get most people started but, regrettably, I can't offer tech support if it doesn't work out. (My family keeps me busy enough on that front. :-) )

If you want to test out your API Key, you can substitute it into this URL. If it works in the URL, it should work in this extension. If not, the API key has not been set up properly.

https://www.googleapis.com/language/translate/v2?key=YOUR_API_KEY&source=en&target=es&q=Hello+World

To create an API key, start on the Cloud Translate API page.

  • From that page, click the big blue "Try Translation free" button. (You may need to sign in again, etc.)

  • Confirm your country, organization, agree to terms, identity verification (text message).

  • Confirm credit card payment details (might not be charged, but needed to open the account).

  • If you see a dialog showing "Get started with an interactive tutorial," click: "Skip for now."

  • From the menu on the left (or possibly from the drop down "hamburger" in the top left corner), click "APIs & Services" > "Enabled APIs".

  • If this is a new account, you need to "Start a project" to put the Translation API service into. (For me this spun off and never came back. Several Google system errors. Had to start again.)

  • Once your project is created, go back to "Enabled APIs & Services". Google seems to enable a pile of APIs to start. I disabled all of them. (Tedious. It's fastest to open every service in a new tab and then go through and disable them tab-by-tab since the disabling takes a few seconds each.)

  • Go to the API Library (if you just deleted all the other APIs, it should prompt you to go there) and find the "Cloud Translation API." Enable it and it should take you back to the settings for this API in your account.

  • On the Cloud Translate API configuration screen it may show an alert telling you, you need to create credentials.

  • (NOTE: In hindsight, this next step may not have been needed.) Click the blue "create credentials" button in the banner. Create credentials for Cloud Translation API, probably with the options "Application Data", "No I'm not using them" (but read the details for yourself). Give the service a name (e.g., "translate"). Click done and it will create a "Service account."

  • Click the "Credentials" link in the left nav. At the top of the screen, click the "+ Create Credentials" link / drop-down-menu and select "API Key" from the menu. An API key will be created. Copy it! This is what you need to put into this extension's preferences to make it work.

EXTRA STEPS - As noted in the API Key creation dialog, the key is probably unrestricted. You may want to click "Edit API key" in that dialog to restrict it to only services you use.

  • You can set up a "Budget & Alert" monitor to email you when you are approaching your limit (I set mine to $1 since I'm expecting my translation needs to be well within the 'free' tier).

Hopefully that resulted in a functioning API Key for you! I went through creating an account twice just to make sure the steps worked consistently but if the key's not working for you... I'm afraid I don't know enough about Google Cloud to suggest how to fix it.

Localization

Translate in Place was localized using Translate in Place. If there are translations that could use improving, please send them along to me to correct. Thanks!

Warranty

None! While nothing has been done to deliberately compromise the security of your API key (which is stored in clear text in the preferences for this extension), or deliberately mis-translate your text to something meaningless or even rude, those things could happen. By using this extension you agree anything that happens that you don't like as a result of using Translate in Place is not the responsibility of the developer.


Changelog

Version 1.2.0

2023-03-30 - Added option to place markers before and after translated text (e.g., to mark the passage for later review).

Version 1.1.1

2022-08-18 - Fixing small things that only seem to become visible after a release. :-) - Fix: _l() function wasn't latest version that made all parameters localizable. - Removed extraneous slashes from ReadMe (not sure where they came from).

Version 1.1.0

2022-08-16 - Localizations for Français and Español. - List of languages in the project preferences makes use of enum-resolve so language names can appear in the user's language, in the alphabetical order for that language. - Small code improvements.

Version 1.0.0

2022-07-15 Première version. Versión inicial. الإصدار الأولي. आरंभिक रिलीज।. Erstveröffentlichung. 初回リリース。 Aanvanklike vrystelling. Initial release.


License

BSD 3-Clause License

Copyright (c) 2022, Colin Foster All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.