(Original) how to add traditional Chinese (Traditional Chinese) to a blog? (Web) (CSS) (JavaScript)

Source: Internet
Author: User

Abstract
Although traditional Chinese and Traditional Chinese texts are the same, it would be a great blessing for beginners to provide traditional Chinese and Traditional Chinese services at the same time.

Introduction
At present, I have added the instant translation of Simplified Chinese on the top of my blog, as shown in the following figure.

My blog does not provide traditional Chinese translation services, but I added them myself. But how does this happen?

There are two problems that must be solved:
1. How to put the four words "simplified Chinese" behind "management? This service seems to be integrated with the services of the original blog.
2. How can I use Google Translate to Translate traditional Chinese into traditional Chinese (or traditional Chinese )?

The first version that is not very successful (using the reverse location of CSS)
Because we do not have the source code of. aspx, we cannot directly add the word "simplified Chinese" after the management. It can only be in a limited place, such"Announcement" and "shoushou 』And"Shanwei 』In this case, HTML or Javascript is added, so I directly want to use the opposite position of CSS.

1 < Span Style = "Position: absolute; top: 194px; left: 335px; color: # acccb1" > :: </ Span >
2 < A ID = "Cn" Href = "Http://oomusou.cnblogs.com" Style = "Position: absolute; top: 196px; left: 352px; color: White; font-size: 12px" > Simplified Chinese </ A >
3 < Script Type = "Text/JavaScript" >
4 E = (Document. charset | Document. characterset );
5 Document. getelementbyid ( " CN " ). Href =   ' Http://translate.google.com/translate? U = ' + Document. url + ' & HL = ZH-tw & langpair = ZH-tw | ZH-CN ' + ' & TBB = 1 & Ie = ' + E;
6 </ Script >

I added the above Code in the announcement area. Since I was in IE7, IE7 looks pretty, but unfortunately it is not normal in IE6. I will discuss Firefox more, the javascript part is the part that uses Google Translate. I will explain it later.

The second version is successfully used (IE6, IE7, and Firefox versions are successfully used)
The following is a complete program example:

1 < Script Type = "Text/JavaScript" >
2 E = (Document. charset | Document. characterset );
3 URL =   ' Http://translate.google.com/translate? U = ' + Document. url + ' & HL = ZH-tw & langpair = ZH-tw | ZH-CN ' + ' & TBB = 1 & Ie = ' + E;
4
5 P = Document. getelementbyid ( " Header1_mylinks1_admin " ). Parentnode;
6 Dot = Document. createtextnode ( " :: " );
7 P. appendchild (DOT );
8 Anchor = Document. createelement ( " A " );
9 Anchor. setattribute ( " Href " , URL );
10 Txt = Document. createtextnode ( " Simplified Chinese " );
11 Anchor. appendchild (txt );
12 P. appendchild (Anchor );
13 </ Script >

Step 1:
Put the words "simplified Chinese" behind "management"
The initial idea is: if we can use JavaScript to find the word "manage" and use JavaScript to add "simplified Chinese 』, in this way, you do not need to specify the corresponding location.

5th rows

P = Document. getelementbyid ( " Header1_mylinks1_admin " ). Parentnode;

We use getelementbyid ("header1_mylinks1_admin") to find the word "manage". How can I find this ID? I am using Internet Explorer developer toolbar, which is a free-of-charge tool provided by Microsoft. If you want to change your blog or develop your own skin, this tool is indispensable. It allows us to view the architecture in HTML.

6th rows

Dot = Document. createtextnode ( " :: " );
P. appendchild (DOT );

Add ":" between "management" and "simplified Chinese" to the notebook 『::』.

8th rows

Anchor = Document. createelement ( " A " );
Anchor. setattribute ( " Href " , URL );
Txt = Document. createtextnode ( " Simplified Chinese " );

Create "simplified Chinese" for the notebook 』.

12 rows

P. appendchild (Anchor );

Add "simplified Chinese" to the notebook.

Step 2:
Use Google Translate
3rd rows

Url = 'HTTP: // translate.google.com/translate? U = '+ document. url +' & HL = ZH-TW & Langpair = ZH-tw | ZH-CN '+' & TBB = 1 & IE = '+ E;

To use Google Translate, You need to import several metric data.
U: URL to be rolled over
Hl: Statement of the source URL
Langpair, en-CN | ZH-TW
IE: indicates the encoding of the inbound network, which can be 29 rows.

E = (Document. charset | Document. characterset );

Obtain the encoding of the current website.

Conclusion
If you want to add traditional experiences and traditional experiences to your blog, you can use this method, or even use Google Translate to translate the content into English, however, the translation into English is not very good. The translation between Chinese and English is too large. If so, the English Department of the University will not need to enroll students.

See also
Why does W3C Dom not provide insertafter? (Web) (JavaScript)
(Original blog) How to Make a blog show classification in tree mode? (Web) (JavaScript)
(Original) How can I trigger a Google Adsense advertisement in a blog? (Web) (CSS) (JavaScript)

Reference
Internet Explorer developer Toolbar
Google Translate
Jian Rui moved to the international market with the help of adding translation functions to webpages: using Google translation and magic craftsman

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.