CN102567384B - Webpage multi-language dynamic switching method and system based on webpage browser engine - Google Patents

Webpage multi-language dynamic switching method and system based on webpage browser engine Download PDF

Info

Publication number
CN102567384B
CN102567384B CN201010611502.XA CN201010611502A CN102567384B CN 102567384 B CN102567384 B CN 102567384B CN 201010611502 A CN201010611502 A CN 201010611502A CN 102567384 B CN102567384 B CN 102567384B
Authority
CN
China
Prior art keywords
text
multilingual
webpage
browser engine
label
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201010611502.XA
Other languages
Chinese (zh)
Other versions
CN102567384A (en
Inventor
刘超
刘啸
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Lianshang Network Technology Co Ltd
Original Assignee
Shanghai Zhangmen Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Zhangmen Science and Technology Co Ltd filed Critical Shanghai Zhangmen Science and Technology Co Ltd
Priority to CN201010611502.XA priority Critical patent/CN102567384B/en
Publication of CN102567384A publication Critical patent/CN102567384A/en
Application granted granted Critical
Publication of CN102567384B publication Critical patent/CN102567384B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Transfer Between Computers (AREA)
  • Machine Translation (AREA)

Abstract

The invention discloses a webpage multi-language dynamic switching method based on a webpage browser engine. The method comprises the steps of: intercepting text inside a label and carrying out translation and dynamic replacement when the browser engine loads a webpage and parses to an appointed multilingual label. The invention also discloses a system for realizing the method. The system comprises an intercepting module and a multilingual storage and query module, which are embedded in the browser engine, wherein the intercepting module is used for intercepting the text in the multilingual label and transmitting to the multilingual storage and query module when the webpage browser engine carries out page parse; and the multilingual storage and query module is used for translating the intercepted text into appointed language and updating the text content. According to the multi-language dynamic switching method and system, by amending the bottom-layer code of the browser engine, the webpage language is only needed to be replaced once when the HTML (Hyper Text Makeup Language) page is parsed and is not needed to be replaced again when the page is loaded again, thus the webpage language dynamic switching efficiency is increased.

Description

The multilingual dynamic switching method of webpage based on web browser engine and system
Technical field
The present invention relates to homepages language switching field, especially a kind of webpage based on browser kernel engine is multi-lingual dynamically to be cut Change method.The invention still further relates to realizing the system of the method.
Background technology
Multilingual switching at runtime to be realized in the browser interface of handheld device, the method generally adopting at present is to set The multi-lingual character string of standby end storage, then runs javascript script, according to current in the page that browser loads Language is arranged, and carries out dynamic replacement to the localized strings occurring in webpage.The shortcoming of this method is that browser adds every time During contained network page, be required for extra perform script and be replaced, this brings extra expense to system, slowed down webpage be loaded into The speed of display, and, javascript script is externally loaded localized strings, certainly will the cutting of running environment be related to Change, i.e. frequently redirecting between script interpretation environment and multi-lingual storage environment, therefore, language switching efficiency is than relatively low.
Content of the invention
The technical problem to be solved in the present invention is to provide that a kind of webpage based on web browser engine is multilingual dynamically cuts The side of changing, it can improve the efficiency of homepages language switching.
For solving above-mentioned technical problem, the multilingual switching at runtime side of the webpage based on web browser engine of the present invention Method, comprises the following steps:
1) define the Multilingual label of html webpage, the text in this label is the literary composition needing to carry out multilingual switching at runtime This;
2) build the dom tree of html webpage in browser engine before, insertion following steps:
When browser engine is resolved to Multilingual label, records this label, and intercept the text in this label;
According to the current language of the text, search the translation character string of the text, and replace this article with this translation character string This original character string.
The invention solves the problems that another technical problem be provide a kind of system for realizing claim 1 methods described.
For solving above-mentioned technical problem, the multilingual switching at runtime of the webpage based on the web browser engine system of the present invention System, includes:
Blocking module, is embedded in browser engine, in browser engine analyzing web page, multi-lingual to needing to carry out The text of speech switching at runtime is intercepted, and sends multi-lingual storage enquiry module to;
Multi-lingual storage enquiry module, is embedded in browser engine, for receiving the text that blocking module transmission comes, and root According to the current language of the text, content of text is translated and is updated.
A multilingual vocabulary is comprised, for storing the entry of different language in described multi-lingual storage enquiry module.
The present invention passes through to change the bottom code of browser engine, its html resolving is intercepted, in browser Engine carries out web analysis, when obtaining webpage character string, carries out multi-lingual inquiry and dynamic replacement, with traditional operation The method that javascript script carries out character string switching at runtime is compared, and the present invention only need to replace one in html page parsing Secondary, need not switch again and perform script in page heavy duty, so that display efficiency improves more than one times.
Brief description
Fig. 1 is the flow chart that existing webkit parses html;
After Fig. 2 is the replacement flow process of the insertion present invention, the flow chart that webkit parses html.
Specific embodiment
It is that the technology contents to the present invention, feature and effect have and more specifically understand, in conjunction with the feasible enforcement of the present invention one Example and accompanying drawing, details are as follows:
Webkit is a browser kernel engine increased income, and its source code clear in structure, it is easy to safeguard, is current main flow One of browser kernel, on pc platform and handheld device, application is quite varied, is based especially on the hand-held of Android platform Equipment, often first-selected webkit is as the core engine of its browser.The present embodiment have selected android1.5 as enforcement Platform.
The flow process of webkit original parsing html refers to shown in Fig. 1, comprises the following steps:
1) loader that webkit is carried using it, from network or local loading html source code.
2) htmltokenizer (html segmenter) of webkit carries out morphological analysis to this html source code, obtains each section Label (tag) and text object.
3) htmlparser (html resolver) receiving step 2 of webkit) analyze the morphology object obtaining, and solved Analysis and process, then with these morphology objects as node, generate dom tree.
4) webkit renders to dom tree, and is plotted on display screen.
The present embodiment is modified to the bottom code of webkit, newly embedded in blocking module and multi-lingual in webkit Storage enquiry module, blocking module is used for, when htmlparser parses, the text needing to carry out multilingual translation being intercepted, And send to multi-lingual storage enquiry module translated.Be stored with multi-lingual storage enquiry module multilingual vocabulary, for blocking Cut the text that sends of module and translate into the language specified.In addition, before modification webkit bottom code, the present invention is to html Need the label carrying out the inline text of multilingual translation to arrange in webpage, in the present embodiment, be about set to < multilang >, For example, in source code < multilang > text </multilang >, " text " is exactly the character needing to carry out multilingual translation String.
After the modification of webkit bottom code, also there is respective change in the flow process that webkit parses html, new process of analysis See shown in Fig. 2.Load html source code in webkit, and using htmltokenizer, it carried out after morphological analysis, The htmlparser of webkit parses to each literal node.When htmlparser is resolved to < multilang > mark During label, this label is inserted in dom tree, blocking module is just intercepted herein, records this label, then, When htmlparser is resolved to plain text " text ", blocking module just sends this character string " text " to multi-lingual storage inquiry mould Block.Multi-lingual storage enquiry module arranges (for example, Chinese) according to current language, searches and search translation word in multilingual vocabulary Symbol string, obtains " text " two word.Multi-lingual storage enquiry module is back to webkit this translation character string and is intercepted place, will be original Character string " text " replace with " text ", then, htmlparser by replace after character string be inserted in dom tree, by Webkit is rendered to dom tree and is drawn and is shown on screen, so, just completes dynamically replacing to inherited literal node Change.

Claims (2)

1. a kind of multilingual dynamic switching method of the webpage based on web browser engine is it is characterised in that comprise the following steps:
1) define the Multilingual label of html webpage, the text in this label is the text needing to carry out multilingual switching at runtime;
2) when browser engine is resolved to Multilingual label, record this label, and intercept the text in this label;
3) current language according to the text, searches the translation character string of the text, and replaces the text with this translation character string Character string originally;The described current language according to the text, the translation character string searching the text is in multilingual vocabulary Search translation character string;Described multilingual vocabulary, for storing the entry of different language;
4) browser engine builds the dom tree of html webpage.
2. a kind of webpage multilingual switching at runtime system realizing claim 1 methods described is it is characterised in that include:
Blocking module, is embedded in browser engine, in browser engine analyzing web page, multilingual dynamic to needing to carry out The text of state switching is intercepted, and sends multi-lingual storage enquiry module to;
Multi-lingual storage enquiry module, is embedded in browser engine, for receiving the text that blocking module transmission comes, and according to this The current language of text, is translated to content of text and is updated;
A multilingual vocabulary is included, for storing the entry of different language in described multi-lingual storage enquiry module.
CN201010611502.XA 2010-12-29 2010-12-29 Webpage multi-language dynamic switching method and system based on webpage browser engine Active CN102567384B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201010611502.XA CN102567384B (en) 2010-12-29 2010-12-29 Webpage multi-language dynamic switching method and system based on webpage browser engine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201010611502.XA CN102567384B (en) 2010-12-29 2010-12-29 Webpage multi-language dynamic switching method and system based on webpage browser engine

Publications (2)

Publication Number Publication Date
CN102567384A CN102567384A (en) 2012-07-11
CN102567384B true CN102567384B (en) 2017-02-01

Family

ID=46412821

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201010611502.XA Active CN102567384B (en) 2010-12-29 2010-12-29 Webpage multi-language dynamic switching method and system based on webpage browser engine

Country Status (1)

Country Link
CN (1) CN102567384B (en)

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10083156B2 (en) 2013-03-13 2018-09-25 International Business Machines Corporation Mobile enablement of webpages
US10346501B2 (en) 2013-03-13 2019-07-09 International Business Machines Corporation Mobile enablement of existing web sites
US9563448B2 (en) * 2013-03-13 2017-02-07 International Business Machines Corporation Mobilizing a web application to take advantage of a native device capability
CN104714968A (en) * 2013-12-16 2015-06-17 中国银联股份有限公司 Method and device for internationalizing web page
CN105488041B (en) * 2014-09-15 2018-08-24 北京畅游天下网络技术有限公司 The method for realizing the multilingual display of browser interface
CN104281711B (en) * 2014-10-27 2018-04-27 浪潮(北京)电子信息产业有限公司 The multilingual treating method and apparatus of WEB application
CN104915204A (en) * 2015-06-08 2015-09-16 小米科技有限责任公司 Web processing method and device
CN106254681B (en) * 2016-09-22 2019-12-20 青岛海信移动通信技术股份有限公司 Language type switching method and terminal for ring names
CN106372065B (en) * 2016-10-27 2020-07-21 新疆大学 Multi-language website development method and system
CN107203405A (en) * 2017-06-23 2017-09-26 郑州云海信息技术有限公司 A kind of method and apparatus for checking multilingual definition
CN109901886B (en) * 2019-01-23 2022-06-03 北京达佳互联信息技术有限公司 Page language switching method, system, device and computer readable storage medium
CN110096432A (en) * 2019-03-21 2019-08-06 平安普惠企业管理有限公司 Test text replacement method, device, computer equipment and storage medium
CN110362370B (en) * 2019-06-14 2022-10-18 平安科技(深圳)有限公司 Webpage language switching method and device and terminal equipment
CN111401000B (en) * 2020-04-03 2023-06-20 上海一者信息科技有限公司 Real-time translation previewing method for online auxiliary translation
CN113438542B (en) * 2021-05-28 2022-11-08 北京智慧星光信息技术有限公司 Subtitle real-time translation method, system, electronic equipment and storage medium
CN113742550B (en) * 2021-08-20 2024-04-19 广州市易工品科技有限公司 Browser-based data acquisition method, device and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1745379A (en) * 2003-01-28 2006-03-08 法国电信公司 Method and system for supplying an automatic web content translation service
CN101615181A (en) * 2008-06-27 2009-12-30 国际商业机器公司 Create the system and method for internationalization network application
US7784026B1 (en) * 2002-06-05 2010-08-24 Adobe Systems Incorporated Web application internationalization
CN102693322A (en) * 2012-06-01 2012-09-26 杭州海康威视数字技术股份有限公司 Multi-language supporting webpage processing method, webpage loading method and systems

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7784026B1 (en) * 2002-06-05 2010-08-24 Adobe Systems Incorporated Web application internationalization
CN1745379A (en) * 2003-01-28 2006-03-08 法国电信公司 Method and system for supplying an automatic web content translation service
CN101615181A (en) * 2008-06-27 2009-12-30 国际商业机器公司 Create the system and method for internationalization network application
CN102693322A (en) * 2012-06-01 2012-09-26 杭州海康威视数字技术股份有限公司 Multi-language supporting webpage processing method, webpage loading method and systems

Also Published As

Publication number Publication date
CN102567384A (en) 2012-07-11

Similar Documents

Publication Publication Date Title
CN102567384B (en) Webpage multi-language dynamic switching method and system based on webpage browser engine
US8417512B2 (en) Method, used by computers, for developing an ontology from a text in natural language
US10878190B2 (en) Structured dictionary population utilizing text analytics of unstructured language dictionary text
US9195644B2 (en) Short phrase language identification
Müller et al. Multi-level annotation in MMAX
US20080077565A1 (en) Method for finding at least one web service, among a plurality of web services described by respective semantic descriptions, in different forms or languages
CN106354484A (en) Browser compatibility method and browser
CN111831384A (en) Language switching method and device, equipment and storage medium
CN104331438A (en) Method and device for selectively extracting content of novel webpage
Uzun et al. Comparison of python libraries used for web data extraction
US10558631B2 (en) Enhancing textual searches with executables
EP1835417A1 (en) Web service with associated lexical tree
US9645816B2 (en) Multi-language code search index
US20150154162A1 (en) Website content and seo modifications via a web browser for native and third party hosted websites
CN104778232A (en) Searching result optimizing method and device based on long query
KR101802051B1 (en) Method and system for constructing schema on natural language processing and knowledge database thereof
KR101045481B1 (en) Method and program recording medium for extracting data of web page using partial matching Xpath
CN103631886A (en) Method and device for inputting on browser side
Declerck et al. Cross-linking Austrian dialectal Dictionaries through formalized Meanings
US20150324333A1 (en) Systems and methods for automatically generating hyperlinks
KR100898242B1 (en) Automatic link generation system and method using multi-link
CN111159518B (en) News data acquisition method and device, computer equipment and storage medium
KR20160050652A (en) Method for constructing treebank of new language and method thereof
CN102314459A (en) System and method for displaying multimedia data by using embedded element
CN106897271B (en) News text noise removing method and system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
ASS Succession or assignment of patent right

Owner name: SHANGHAI GUOKE ELECTRONIC CO., LTD.

Free format text: FORMER OWNER: SHENGLE INFORMATION TECHNOLOGY (SHANGHAI) CO., LTD.

Effective date: 20120709

C41 Transfer of patent application or patent right or utility model
TA01 Transfer of patent application right

Effective date of registration: 20120709

Address after: 201203 Shanghai City, Pudong New Area Shanghai City, Guo Shou Jing Road, Pudong New Area Zhangjiang hi tech Park No. 356

Applicant after: Shanghai Guoke Electronic Co., Ltd.

Address before: 201203 Shanghai City, Pudong New Area Shanghai City, Guo Shou Jing Road, Pudong New Area Zhangjiang hi tech Park No. 356

Applicant before: Shengle Information Technology (Shanghai) Co., Ltd.

ASS Succession or assignment of patent right

Owner name: SHANGHAI SHENGXUAN NETWORK TECHNOLOGY CO., LTD.

Free format text: FORMER OWNER: SHANGHAI GUOKE ELECTRONIC CO., LTD.

Effective date: 20130318

C41 Transfer of patent application or patent right or utility model
TA01 Transfer of patent application right

Effective date of registration: 20130318

Address after: 201203 Shanghai Guo Shou Jing Road, Zhangjiang High Tech Park of Pudong New Area No. 356 building 3 room 126

Applicant after: Shanghai Shengxuan Network Technology Co., Ltd.

Address before: 201203 Shanghai Guo Shou Jing Road, Pudong New Area Zhangjiang hi tech Park No. 356

Applicant before: Shanghai Guoke Electronic Co., Ltd.

C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C41 Transfer of patent application or patent right or utility model
TA01 Transfer of patent application right

Effective date of registration: 20160616

Address after: 201203 Shanghai Zhang Heng Road, Lane 666, No. 7, building 1, Pudong New Area

Applicant after: SHANGHAI ZHANGMEN TECHNOLOGY CO., LTD.

Address before: 201203 Shanghai Guo Shou Jing Road, Zhangjiang High Tech Park of Pudong New Area No. 356 building 3 room 126

Applicant before: Shanghai Shengxuan Network Technology Co., Ltd.

C14 Grant of patent or utility model
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20170314

Address after: 200000 room N2025, building No. 2, Xincheng Road, mud town, Shanghai, Pudong New Area, China, 24

Patentee after: Shanghai Lian Shang network technology Co., Ltd

Address before: 201203 Shanghai Zhang Heng Road, Lane 666, No. 7, building 1, Pudong New Area

Patentee before: SHANGHAI ZHANGMEN TECHNOLOGY CO., LTD.