Message Boards Message Boards

GROUPS:

TranslationCell - Instantly translate English text cells to your language!

Posted 5 months ago
817 Views
|
3 Replies
|
8 Total Likes
|

Note: Please check out this interesting post on a NotebookTranslate function(direct link to cloud notebook), by Thomas Colignatus.

Starting with version 11.1 the Wolfram Language includes a new text translation function, aptly named TextTranslation.

Recently I made a post which showed how you can use this function to query Wolfram|Alpha in any language.

But there is so much more you can do with this function. In this post I will share the idea of a TranslationCell function, which creates a regular text cell, with an attached button which lets you toggle from English to a specific language.

Let's start with a famous English quote from the recent past:

We choose to go to the Moon! We choose to go to the Moon in this decade and do the other things, not because they are easy, but because they are hard; because that goal will serve to organize and measure the best of our energies and skills, because that challenge is one that we are willing to accept, one we are unwilling to postpone, and one we intend to win, and the others, too.

And let's assign this quote to a variable named quote:

quote = "We choose to go to the Moon! We choose to go to the Moon in \
this decade and do the other things, not because they are easy, but \
because they are hard; because that goal will serve to organize and \
measure the best of our energies and skills, because that challenge \
is one that we are willing to accept, one we are unwilling to \
postpone, and one we intend to win, and the others, too."

I don't want to get to deeply into the implementation details, but if you are interested in them I recommend perusing the code for it on my GitHub project:

https://github.com/arnoudbuzing/prototypes/blob/master/Prototypes/Notebook.wl#L148

And if you want to try this function, simply install the paclet that has this function included:

PacletInstall["https://github.com/arnoudbuzing/prototypes/releases/download/v0.2.5/Prototypes-0.2.5.paclet"]

So let's take a look at an example:

TranslateCell[ quote, "Spanish" ]

This creates the following cell:

enter image description here

And clicking on the button will translate the English text to Spanish (this may take 1-2 seconds since it is calling a translation service):

enter image description here

Clicking the button again reverts to English (this is fast, because it stored the original text in the cell as metadata):

enter image description here

And of course this works for many languages, like Russian:

TranslationCell[ quote, "Russian" ]

enter image description here

Or Swedish:

TranslationCell[ quote, "Swedish" ]

enter image description here

Or Arabic:

TranslationCell[ quote, "Arabic" ]

enter image description here

It might be useful to extend this idea to support translation between any two languages ( "LanguageA" -> "LanguageB" ), so I think this will be the next improvement.

Let me know what you think! I am interested in feedback and additional ideas on how to use TextTranslation in the Wolfram Language!

3 Replies

enter image description here - Congratulations! This post is now a Staff Pick as distinguished by a badge on your profile! Thank you, keep it coming!

Hi Arnoud, From the documentation: "TextTranslation requires internet connectivity and uses external services that require Service Credits." I wrote this package to help manage one's funds on translating notebooks:

http://community.wolfram.com/groups/-/m/t/1313456

For a whole notebook, a user might also consider saving the notebook as html and see what Google Translate produces. But then it may be a hassle to go back to a notebook again.

That's a very interesting post (that somehow I had not seen before)! Thanks for sharing it (I will link to it at the top of my post)

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract