Website translation function

The function is divided into two parts: 1. Get the content to be translated on the page;

      2. Match the content from the custom resource pack;

 

My website translation is to rewrite one of the methods when creating the html page,

Step 1: Get the content on the page to translate:

    In MVC, there is such a class: System.Web.Mvc.WebViewPage, which is responsible for rendering the methods or properties we wrote in Razor. I will override a method in this WebViewPage class, WriteLiteral() This method excludes the methods and attributes defined in the view, and traverses the html (the content length is not fixed). At this point, I can write the traversed content. I In this step, the content in the html tag is obtained, and then the content is translated by word segmentation

 

There are many ways to find out the content of the tag, such as using regular, html parsing, and parsing the content after ToChar. I think of these three (what else can you do).

 

Resource pack, that is, pure manual translation. I know that I can call the translation interface on the Internet, or take down the interface of Baidu Translate and use it. But it is not recommended to do so. There is a charging interface provided, but I don't want to use it often. My resource pack is a copy of Microsoft's resource pack. Defined as an XML file. Because Microsoft's resource pack can only contain one language, if I want to use ten languages, I have to create ten files, which is very inconvenient, so I thought of using this method. When manually translated, it is compiled into an excel file, and the server uses an xml file

 

Need to try to divide the content into the smallest words, that is to prevent matching problems

 

This is my first time writing a blog, so please forgive me for not writing well.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325020351&siteId=291194637