Codist icon indicating copy to clipboard operation
Codist copied to clipboard

Suggestion: Super Quick Info add translation

Open RC1844 opened this issue 5 years ago • 17 comments

Can you try to add web translation to QuickInfo's summary?

Just add translation and keep the original summary.

Snipaste_2020-10-15_12-37-47

RC1844 avatar Oct 15 '20 04:10 RC1844

I'd thought of that years ago. Unfortunately there's no way to obtain the translated XML documentation via the existing API of VS or roslyn.

wmjordan avatar Oct 15 '20 06:10 wmjordan

Unfortunately there's no way to obtain the translated XML documentation via the existing API of VS or roslyn.

@wmjordan Get summary in xml → Translate summary → Add Translated summary to Super Quick Info

Is it okay?

RC1844 avatar Oct 15 '20 07:10 RC1844

Where's the translation?

wmjordan avatar Oct 15 '20 07:10 wmjordan

Where's the translation?

@wmjordan The summary given Google Translation。 We don’t translate xml, just translate the summary part, don’t write xml, and don’t make any changes Can I speak Chinese?

RC1844 avatar Oct 15 '20 07:10 RC1844

How can you access the Google translation API in China?

Nowadays, you can select contents in the Quick Info, right click the selection to bring out a menu to Copy the selection and switch to online translation services.

wmjordan avatar Oct 15 '20 08:10 wmjordan

How can you access the Google translation API in China?

This is not the point. There are many alternatives in China, such as Baidu and Youdao.

Nowadays, you can select contents in the Quick Info, right click the selection to bring out a menu to Copy the selection and switch to online translation services.

too troublesome

RC1844 avatar Oct 15 '20 09:10 RC1844

@wmjordan Perhaps, I should create an extension for this. But I have not been able to find the API to get Comments. Maybe my direction is wrong, can you guide me? Thank you!

RC1844 avatar Oct 15 '20 09:10 RC1844

OK. I understood your request.

However, integrating the content into Quick Info is not so viable, since online service will usually not yet returns the translation to Codist when Quick Info is displayed. The result may be presented in another floating window asynchronously.

wmjordan avatar Oct 15 '20 09:10 wmjordan

I have not been able to find the API to get Comments

It is not an easy job. A lot of things have to be done. You can take a look at this file, which has covered most of the stuff, but not yet fully implemented (for instance, Deconstruct in C# 7 has not yet supported in Codist): https://github.com/wmjordan/Codist/blob/master/Codist/QuickInfo/CSharpQuickInfo.cs

wmjordan avatar Oct 15 '20 09:10 wmjordan

It's really not an easy job. I may need a long time to study. Thanks for your guidance.

RC1844 avatar Oct 15 '20 09:10 RC1844

You may take a look at #133 . The author of that issue had given quite a few links about the QuickInfoService in Roslyn. It shall be much easier to get you started from that class.

wmjordan avatar Oct 16 '20 03:10 wmjordan

nice. I will study it carefully, thank you.

RC1844 avatar Oct 16 '20 03:10 RC1844

Implementation of a translation service https://github.com/Kerwin1202/VsTranslator

alekseyaz avatar Oct 17 '20 10:10 alekseyaz

@alekseyaz Thank you. This can ease part of my work.

RC1844 avatar Oct 17 '20 10:10 RC1844

I just added a primitive google translate option, as an example can be found in the feature-translate branch https://github.com/alekseyaz/Codist/tree/feature-translate

Screenshot_3 Screenshot_4 Screenshot_5

alekseyaz avatar Oct 17 '20 15:10 alekseyaz

I just added a primitive google translate option, as an example can be found in the feature-translate branch

cool.

@alekseyaz Maybe it doesn't need me to do anything. Add xx seconds to display the translation or translation cache, add the translation to the asynchronous thread, even if the work is completed

RC1844 avatar Oct 17 '20 15:10 RC1844

Converted to async and HttpClient

alekseyaz avatar Oct 17 '20 22:10 alekseyaz

@RC1844 Do you know about any high quality free Chinese translation service API?

wmjordan avatar Jul 11 '23 02:07 wmjordan

@RC1844 Do you know about any high quality free Chinese translation service API?

Alibaba Cloud Machine Translation API Tencent Cloud Translation API Baidu Translate API Both have word limits.

libretranslate Self hosted, unlimited.

RC1844 avatar Jul 18 '23 01:07 RC1844