How to translate C# project comments from Chinese to English? - c#

We have an open source project hosted in GitHub, but the code comments are Chinese language. The customers need to review all source code include comments by English language. Is there any convinent way to translate all comments in these code files from Chinese language to English language? Thanks for any ideas, so we can avoid to translate them one by one.
#region Xml节点转换信息-----------***need to be translated***
/// <summary>
/// 把XML节点转换为ActivityEntity实体对象-----------***need to be translated***
/// </summary>
/// <param name="node">节点--------***need to be translated***</param>
/// <returns>实体---------***need to be translated***</returns>
internal TransitionEntity ConvertXmlTransitionNodeToTransitionEntity(XmlNode node)
{
//构造转移的基本属性------------***need to be translated***
TransitionEntity entity = new TransitionEntity();
entity.TransitionGUID = XMLHelper.GetXmlAttribute(node, "id");
return entity;
}
#endregion
By the way, the source code maybe include C#, Javascript, HTML, XML and some JSON files. The C# files is the first priority choice to need to be translated.
Question: The effect way is to find a toolkit to recoginze the comments part and using such as Google translateion API service to translate Chinese to English or auto-generate it again. We neednt to ask anyone to tell us comments are not useful, or why dont write English directly.

You could try https://github.com/riversun/JavaCommentTranslator
'comment_translator' is a java library that can translate comments in
the source code. You can translate comments written in national
languages into your familiar language.
These days you'll need to create a Microsoft Cognitive Services API key, and use https://github.com/tlehoux/microsoft-translator-java-api to work with it, ie delete https://github.com/riversun/JavaCommentTranslator/tree/master/src/main/mst/com/memetix/mst and use that instead.

Related

// comments in doxygen

I have a c# project that I need to document with doxygen. It picks up the comments autogenerated by visual studio's /// but unfortunately it does not pick up on the normal // comments. Is there a config setting that I am missing? Or is this just not possible?
/// is referred to as XML Documentation Comments. This is how Doxygen and other documentation-generating software locate areas of the code you want to be used as documentation.
To elaborate, if you have comments like // This is hacky, but I'll return to it later in your code you should change them to an XML comment section on the method, property, or object in question.
To me this is not a bug but a feature. There are comments that I do want to leave in the code and not extract and show everyone. The distinction between the /// and the // allows me to do this.

C# xml documentation: How to create Notes?

I want to achieve a similar thing to the yellow 'Note:' box in the remarks section on this MSDN page in my own documentation.
I'm using sandcastle and the sandcastle help file builder to generate a reference website out of the documentation tags. What do I have to write to achieve such a notes box?
/// <summary><c>Increment</c> method increments the stored number by one.
/// <note type="caution">
/// note description here
/// </note>
/// </summary>
Look at file "C:\Program Files\Sandcastle\Examples\Sandcastle\test.cs"
Type could be one of:
note
tip
caution
security
important
vb/VB/VisualBasic/visual basic note
cs/CSharp/c#/C#/visual c# note
cpp/c++/C++/CPP/visual c++ note
JSharp/j#/J#/visual j# note
implement
caller
inherit
Not a direct solution, but an alternative:
NDoc supports a <note> Tag. Since NDoc is outdated, you could have a look for this feature in NDoc3, which is definitely worth looking at since it is also also capable of creating plain HTML documentation, not only online documentation which assumes asp.net.

Online and automatic resource localization in C#

I have a c# winforms project with many forms, now I want to localize these forms to another language, is there any way or code that generates resource files for forms and translate them online?
Thanks
There are open source tools which allow to translate resx files. I haven't found a version which uses a online translation service such as google translate or the microsoft translator api or even the bablefish. But I think the Resx Translation Helper (open source project) should be very easy to modify. Note however, that the author explicitly discourage the usage of autogenerated translation:
It does NOT automatically translate because user-translation is currently still much better than automated translation.
if you will be able to generate resx file from your sources. maybe Crowdin.net will be suitable solution for online translations.
The Visual Localizer tool utilizes Google Translate, Microsoft Translator and MyMemory for this very purpose. It has also many other features regarding automatic localization in .NET.
You can use ReSharper plugin and/or RGreatEx - The ReSharper Great Extension
and U can easily Move strings to resource to translate them for specific language.

sample to create a html page with a language translator using c#

How can i create a simple aspx page with a dropdown have two enteries
1. Translate to greek
2. Translae to english
I'll be getting the data from a db table which is in English. While choosing the items from the dropdown the text should change accordingly. How an I achieve this ?
code snippets would be helpful
If you are storing only the English version of your site in the database you will need some language translation API. Google provides such service: it's called the Google AJAX Language API and allows you to translate text between different languages. Here's a sample in C# of how it could be used.
Take a look at Microsoft's Translator Widget
It does what you want (if I've read your post correctly and understand what you're after) pretty easily!

How do I add context help to an assembly

I have created a .NET C# component that I am going to sell as a developers tool. My question is, how do I add my own custom context help to the methods and properties.
So, when I press F1 over a method I want it to go to a specific web page. Is this even possible?
Use the Visual Studio SDK and the help integration kit
Part of the Visual Studio SDK is the Help Integration project type. Information about integrating with help here (MSDN). Same applies for VS 2005 and 2008.
Here's a link to the download, for earlier versions of VS (before '05).
There's an entire development center about the Visual Studio SDK.
The effort feels a lot higher than shipping a .Chm and/or IntelliSense files, but I understand you'd like to add examples, etc.
Consider if it's worth the effort
Are you providing enough information in the IntelliSense documentation files (.xml) for all of your component's assemblies?
More often than not, that's sufficient to provide a lot of information, including additional remarks, notes, etc.
I may just be biased to my development workflow and that of my co-workers, but I can't remember the last time that I saw anyone press "F1" in Visual Studio.
Plus, if you really ever do want a full-blown .Chm help file, your XML documentation comments can be turned into that with little effort thanks to tools like Sandcastle and formerly NDoc.
Aside from the traditional F1 help, I find that Sandcastle created CHM files are extremely helpful when deploying any reusable libraries and frameworks. GhostDoc has proven quite useful for creating the in-code XML needed for Sandcastle CHM files. Sandcastle also has the option of creating MSDN-style HTML help files as well as the tried-and-true CHM.
Context help is generated via the XML documentation in your code.
If you're unfamiliar with it, in C#.NET you can document a function by typing three successive forward-slashes before the method signature:
/// <summary>
/// What Foo() does...
/// </summary>
/// <param name="bar">What bar is...</param>
/// <returns>What the return int is...</returns>
public int Foo(string bar)
{
// Does something...
}
In VB.NET, I believe it's three apostrophes.
Assuming you're familiar with using xml comments to create the xml intellisense file and can use sandcastle to generate .chm files separately then the missing piece is F1 integration.
This article is ancient but indicates how to do it with VS 6.0 era help
The comments there direct you to the 2003 integration kit
Beyond that you seem to have to download the actual VS SDK.
This page seems pretty up to date (it has info on changes in 2010)

Categories