Technical Principles of QBlog in the autumn color Park: page content filling and multi-language translation process demonstration example (10)

Source: Internet
Author: User

Review:

1. Analysis of QBlog technology principles in the autumn Garden: Opening part: Overall understanding (1) -- introduces the role of the overall folder and file

2: Analysis of QBlog technical principles of the autumn color Garden: Understanding the whole site processing process (2)-introducing the business processing process of the autumn color Garden

3: Analysis of QBlog technical principles in the autumn color Park: UrlRewrite's principle of URL without a suffix (3) -- introduces how to implement URL without a suffix

4: Analysis of QBlog technical principles in the autumn Garden: URL redirection System of UrlRewrite (4) -- introduce how to locate the processing program in the URL

5. Technical Principles of QBlog in the autumn color Park: Module-based page base class design (5)-Introduction to creating base classes and custom lifecycles

6: Analysis of QBlog technology principles in the autumn Garden: Module Page Base-Lifecycle Process (6)-Introduction to internal services of the basic Lifecycle

7. Technical Principles of QBlog in the autumn Garden: Module-based lifecycle-page loading (7)-Introduction to html Loading Principles

8. Technical Principles of QBlog in the autumn Garden: webpage processing-content filling (8)-How to fill html content

9: Analysis of QBlog technology principles in the autumn Garden: unique multi-language translation mechanism (9)-Introduction to the principles of html multi-language translation

 

Ps: QBlog: Http://www.cyqdata.com/download/article-detail-427

 

Review in the previous section:

Analysis of QBlog technical principles in the last section: the unique multi-language translation mechanism (9) introduces the multi-language translation mechanism of QBlog in the autumn garden,

The coder's labor force was seriously liberated and the translation duties were separated from the art industry.

In the next 10 days, this article demonstrates the complete content filling and page translation.

 

Start:

 

I. Overall solution:

 

From the top down, the following content is more than the previous example:

1: database 1: myspace. mdb, which uses the database of the autumn garden, contains a lot of data.

2: Language. ashx: Multilingual processing program for translation.

3: UrlRewriteEntity: added static content item with an SQL and table Enumeration

 

OK. There are not many added items. The others are the content of the previous example. You can look back without knowing it.

 

2. Multilingual translation

 

1: As in the previous example, one-time batch translation code:

Private void Translate (XmlHelper doc)
{
System. Xml. XmlNodeList list = doc. GetList ("*", "key"); // obtain all nodes with the key tag
System. Xml. XmlAttribute attr = null;
If (list! = Null & list. Count> 0)
{
String key = null;
For (int I = 0; I <list. Count; I ++)
{
Attr = list [I]. Attributes ["key"];
Key = attr. Value;
List [I]. InnerXml = _ Language. Get (key); // Translation
List [I]. Attributes. Remove (attr); // Remove the key attribute
}
}
List = doc. GetList ("*", "keyvalue"); // obtain all nodes with the keyvalue tag
If (list! = Null & list. Count> 0)
{
String key = null;
For (int I = 0; I <list. Count; I ++)
{
Attr = list [I]. Attributes ["keyvalue"];
Key = attr. Value;
List [I]. Attributes ["value"]. InnerXml = _ Language. Get (key); // Translation
List [I]. Attributes. Remove (attr); // Remove the keyvalue attribute
}
}
}

 

2: In the HttpCustom business process, you need to add the call Translation Line.

Private void Page_PreLoad ()
{
If (_ Document. Load (Context. Server. MapPath ("Skin/system_health/index.html ")))
{
CssAndImg (_ Document );
Translate (_ Document );
}
}

 

3: rewrite the URL and redirect the language switching path to the Lanuage. ashx handler.

Public void HttpUrlRewrite (HttpContext context)
{
String url = context. Request. Url. ToString ();
If (url. Contains (". css") | url. Contains (". jpg") | url. Contains (". png") // place the image in css and jpg.
{
Return;
}
If (url. Contains ("lang "))
{
Context. RewritePath ("~ /Language. ashx ", null," url = "+ url );
}
Else
{
// -- Perform a lot of Url logic processing here
Context. RewritePath ("~ /Default. ashx ", null," url = "+ url );
}
}

 

4: Process Language. ashx and return to the original page.

Public class Language: HttpCustom
{
Protected override void Page_Load ()
{
String url = Request ["url"];
String lanKey = url. Substring (url. LastIndexOf ('/') + 1 );
Language. SetToCookie (lanKey. Substring (0, 1). ToUpper () + lanKey. Substring (1 ));
Context. Response. Redirect (Context. Request. UrlReferrer. ToString ());

}
}

 

OK. If multi-language processing is over, what is the preview effect? Don't worry. Wait until the content is filled.

 

3. Page Content Filling

 

1: Create conventions similar to CMS syntax

Example:

<Ul class = "evt_hots_list" name = "catelist" id = "16" count = "8">
<Li> <a href = "http://www.cyqdata.com/"> omitted content </a> </li>
</Ul>

Note:

1: catelist, an agreed tag, name category list

2: id, which is the id of the category.

3: count, which is the number of loops

4: Li's line is used for decoration, because it is replaced.

NOTE: If any tag is added with catelist + id, a circular output of classification can be obtained. count is optional.

 

2: organize HTML and set labels for displaying categories according to conventions.

For example:

<Ul class = "evt_plist" name = "catelist" id = "12" count = "40">
<! -- Health and education -->
<Li> <a target = "_ blank" title = "" href = "#"> Education </a> </li>
</Ul>
<Ul class = "evt_plist" name = "catelist" id = "13" count = "40">
<! -- Health and Harmony -->
<Li> <a target = "_ blank" title = "" href = "#"> harmony </a> </li>
</Ul>
<Ul class = "evt_plist" name = "catelist" id = "14" count = "40">
<! -- Health-private language -->
<Li> <a target = "_ blank" title = "" href = "#"> private language </a> </li>
</Ul>

After a few rows are put securely, the system automatically obtains the content filling list with the category id of 12, 13, and 14.

 

3: Write a common code processing in the background

OK. Now the self-filling function similar to CMS is well written, and the programmer is easy and the artist is also easy.

 

Iv. Final F5 Preview

 

1: access, the content list appears

 

2: English Translation

 

The translation only translates the interface, but the content is not translated. Do you want to translate the content? Write an English article by yourself. Haha!

 

V. Summary

This section is a basic summative article with no detailed text explanation. It aims to provide a sample code for the overall process, focusing on the source code.

In the next section, we will continue the next process.QBlog.

 

6. Download source code

 

Finally, the public is expecting the source code to be downloaded.

: Section 10 of the title of the autumn garden. rar

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.