0

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.

Bes Ley
  • 1,685
  • 1
  • 20
  • 39
  • 3
    If you need to endup with *useful readable* comments there is nothing except ask developers to actually write them in English... Otherwise delete and auto-generate again (like https://stackoverflow.com/a/429804/477420). – Alexei Levenkov Nov 09 '17 at 03:46
  • I just pasted text into google translate and got great translation. – jdweng Nov 09 '17 at 03:59
  • @Alexei, The project is firstly not prepare to global users, now we have to change them to be more readable for every programmers. The auto-generation is realy a effective way. I will try it later. Thanks. – Bes Ley Nov 09 '17 at 05:52
  • 1
    @BesLey: the auto-generation is in my opinion a bit useless as it's not giving any useful additional info. `ConvertXmlTransitionNodeToTransitionEntity` would give me `Convert xml transition node to transition entity`, which is exactly the same but with space between words but it can be used as a base from which to extend. – user276648 Nov 09 '17 at 06:09
  • If possible I would advise to use English for all new comments, and update current Chinese comments little by little (eg if you work on a class, you update the main comment of the class, and maybe some of its main public methods). – user276648 Nov 09 '17 at 06:11
  • @user276648, Yes, the new comments is better to use English. But there are too many files already with Chinses. It's better to find a automation process rather than programmer's hands work. – Bes Ley Nov 09 '17 at 06:16
  • 1
    Similar question https://stackoverflow.com/questions/6064114/translating-comments-and-region-names-in-source-code – user276648 Nov 09 '17 at 06:21
  • @BesLey If in the future your code need to be reviewed by Chinese, do you again translate the comments back? Either way we have to make a compromise unless auto translation or recorded translation is implemented. – Gqqnbig Jan 27 '18 at 18:20

1 Answers1

0

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.

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84