CN111563223B - Webpage localization method and device - Google Patents

Webpage localization method and device Download PDF

Info

Publication number
CN111563223B
CN111563223B CN202010398978.3A CN202010398978A CN111563223B CN 111563223 B CN111563223 B CN 111563223B CN 202010398978 A CN202010398978 A CN 202010398978A CN 111563223 B CN111563223 B CN 111563223B
Authority
CN
China
Prior art keywords
localized
target object
information
localization
document
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
CN202010398978.3A
Other languages
Chinese (zh)
Other versions
CN111563223A (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.)
Beijing Feynman Software Technology Co ltd
Original Assignee
Beijing Feynman Software 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 Beijing Feynman Software Technology Co ltd filed Critical Beijing Feynman Software Technology Co ltd
Priority to CN202010398978.3A priority Critical patent/CN111563223B/en
Publication of CN111563223A publication Critical patent/CN111563223A/en
Application granted granted Critical
Publication of CN111563223B publication Critical patent/CN111563223B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/986Document structures and storage, e.g. HTML extensions

Abstract

The invention discloses a method and a device for localizing a hypertext markup language document and a webpage, wherein the method for localizing the webpage comprises the following steps: reading a hypertext markup language document; the hypertext markup language document includes document information and a document body; the document information comprises preset localization area information of the hypertext markup language document and address information of a resource file corresponding to the preset localization area; the document body comprises a target object to be localized and preset keywords, wherein the preset keywords are used for identifying the target object to be localized; acquiring current area information of a user agent; extracting a first resource file corresponding to the current target area information from the current target area information document information; extracting a target object to be localized from the hypertext markup language document according to a preset keyword; and carrying out localization processing on the target object to be localized according to the resource file. By implementing the method and the system for localizing the webpage, the load of the server is reduced.

Description

Webpage localization method and device
Technical Field
The invention relates to the field of browser page display, in particular to a method and a device for localizing a hypertext markup language document and a web page.
Background
In order for a website to serve users in different country regions, a large website typically needs to display different content according to different countries or regions, i.e. to localize the web page content according to the current regional settings of the browser. The traditional localization processing method is essentially that a browser is matched with a webpage server, and the server provides (or dynamically generates) content matched with the current area for a user according to the current area setting of the browser or the selection of the user. This localization method always requires the cooperation of the server to be completed, and thus has many problems. Firstly, when a client disconnects from a network, a localization process cannot be performed because a server cannot be connected, secondly, the localization is completed by the server, which is affected by the network speed, resulting in the rendering of content to be blocked, thereby affecting the user experience, and when the web page content is dynamically generated by a script, the server is requested to regenerate the web page due to the change of the localization area, which results in that all the content except localization is regenerated, and finally, the load pressure of the server is increased. In order to improve the defects, in the prior art, a script is used for loading and translating web page contents, however, when the script function of a browser is forbidden, localization processing cannot be realized, and because the script is an explanatory programming language, the execution efficiency is lower, and the execution of the script is performed after the whole page is loaded, when the localization is realized by adopting the script on a computer system with lower performance, a user can see that the page is displayed as original non-localized contents and then becomes localized contents, so that the web page interface friendliness is poor, localization of the web page contents is realized by the script, and in order to facilitate the localization processing of the script, all elements needing to be subjected to localization processing are required to be endowed with specific attributes, but the prior web page coding is complicated and the subsequent maintenance is difficult. Therefore, the localization of the webpage content is realized through the script, and the burden of a server is reduced, but the problems of poor webpage interface friendliness, difficult webpage coding and maintenance and the like still exist.
Disclosure of Invention
Therefore, the technical problem to be solved by the invention is to overcome the defects of poor webpage interface friendliness and difficult webpage coding and maintenance in the prior art, thereby providing a method and a device for localizing the hypertext markup language document and the webpage.
The first aspect of the invention provides a web page localization method, which comprises the following steps: reading a hypertext markup language document; the hypertext markup language document includes: document information and a document body; the document information includes: preset localization area information of the hypertext markup language document and address information of a resource file corresponding to the preset localization area; the document body comprises a target object to be localized and preset keywords, wherein the preset keywords are used for identifying the target object to be localized; acquiring current area information of a user agent; extracting a first resource file corresponding to the current region information from document information of the hypertext markup language document according to the current region information; extracting a target object to be localized from the hypertext markup language document according to a preset keyword; and carrying out localization processing on the target object to be localized according to the first resource file.
Optionally, the hypertext markup language document further comprises: default area information for identifying default area information of a web page; after the step of obtaining the current area information of the user agent, before the step of extracting the first resource file corresponding to the current area information from the document information of the hypertext markup language document according to the current area information, the method further comprises: extracting default region information from the hypertext markup language document; judging whether the default area information and the current area information are the same; and if the default area information and the current area information are different, executing the step of extracting the first resource file corresponding to the current area information from the document information of the hypertext markup language document according to the current area information.
Optionally, the preset keywords include: specifying localization area information, where the specifying localization area information is used to identify specified localization area information of a target object to be localized, and after the step of extracting the target object to be localized from the hypertext markup language document according to the preset keyword, before the step of performing localization processing on the target object to be localized according to the first resource file, the method includes: judging whether the designated localization area information is the same as the current area information; if the appointed localization area is different from the current area information, extracting a second resource file corresponding to the appointed localization area information from the document information of the hypertext markup language document according to the appointed localization area information; and carrying out localization processing on the target object to be localized according to the second resource file.
Optionally, if the target object to be localized is not specified by the preset keyword identification to localize the region information, or if the specified localized region information is the same as the current region information, executing the step of localizing the target object to be localized according to the first resource file.
Optionally, the first resource file is a dictionary structure, and the dictionary structure comprises an interface, wherein the interface comprises a target object to be localized and current region information; the step of carrying out localization processing on the target object to be localized according to the first resource file comprises the following steps: and inquiring a character string corresponding to the target object to be localized in the dictionary structure of the first resource file through the interface, and returning the character string.
The embodiment of the invention provides a web page localization method, which comprises the following steps: reading a hypertext markup language document; the hypertext markup language document includes: document information and a document body; the document information includes: preset localization area information of the hypertext markup language document and address information of a resource file corresponding to the preset localization area; the document body comprises a target object to be localized and a preset keyword, the preset keyword is used for identifying the target object to be localized, and the preset keyword comprises: designating localization area information for identifying designated localization area information for the target object to be localized; extracting the target object to be localized from the hypertext markup language document according to the preset keywords; judging whether the preset keywords comprise appointed localization area information of the target object to be localized; if the preset keyword comprises appointed localization area information of the target object of the area to be localized, extracting a second resource file corresponding to the current area information from document information of the hypertext markup language document according to the appointed localization area information; and carrying out localization processing on the target object to be localized according to the second resource file.
Optionally, the second resource file is a dictionary structure, and the dictionary structure comprises an interface, wherein the interface comprises a target object to be localized and appointed localization area information; the step of carrying out localization processing on the target object to be localized according to the second resource file comprises the following steps: and inquiring a character string corresponding to the target object to be localized in the dictionary structure of the second resource file through the interface, and returning the character string.
A third aspect of the present invention provides a hypertext markup language document comprising: document information and a document body; the document information includes: preset localization area information of the hypertext markup language document, address information of a resource file corresponding to the preset localization area; the document body comprises a target object to be localized and preset keywords, wherein the preset keywords are used for identifying the target object to be localized.
Optionally, the preset keywords include: localization area information for identifying designated area information for localizing a target object to be localized.
A fourth aspect of the present invention provides a web page localization apparatus, including: the hypertext markup language document reading module is used for reading the hypertext markup language document; the hypertext markup language document includes: document information and a document body; the document information includes: preset localization area information of the hypertext markup language document, address information of a resource file corresponding to the preset localization area; the document body comprises a target object to be localized and preset keywords, wherein the preset keywords are used for identifying the target object to be localized; the current region information acquisition module is used for acquiring the current region information of the user agent; the resource file acquisition module is used for extracting a first resource file corresponding to the current region information from document information of the hypertext markup language document according to the current region information; the target object extraction module is used for extracting the target object to be localized from the hypertext markup language document according to the preset keywords; and the localization processing module is used for carrying out localization processing on the target object to be localized according to the first resource file.
A fifth aspect of the present invention provides a computer apparatus comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to perform the web page localization method as provided in the first aspect of the invention, and/or the second aspect of the invention.
A sixth aspect of the invention provides a computer readable storage medium storing computer instructions for causing a computer to perform a method of localising web pages as provided in the first aspect of the invention, and/or in the second aspect of the invention, or a hypertext markup language document as provided in the first aspect of the invention.
The technical scheme of the invention has the following advantages:
1. according to the webpage page localization method, when the hypertext markup language document is analyzed, the first resource file corresponding to the current area information of the user agent is firstly obtained according to the document information, when the document body of the hypertext markup language document is analyzed, the target object to be localized is obtained according to the preset keyword, then the localization processing is carried out on the target object through the first resource file, before the document body is analyzed, the first resource file is loaded and stored locally, when the browser analyzes the document body, the target object to be localized is extracted according to the keyword, and then the localization processing is carried out on the target object to be localized according to the first resource file, and because the resource file at the moment is already stored locally, the user agent can complete the localization processing on the webpage page without matching of a server, the load of the server is reduced, even if the network is disconnected, the localization processing on the webpage is synchronously carried out in the loading process of the webpage, and the condition that the original webpage is displayed first and then the localized webpage is loaded is not occurred.
2. According to the webpage page localization method, localization area information is designated for the target object to be localized through the keywords, when the target object to be localized identified by the designated localization area information is analyzed, localization processing is carried out on the target object to be localized according to the second resource file corresponding to the designated localization area information, and different contents can be flexibly converted into different languages according to different designated localization area information.
3. The hypertext markup language document provided by the invention defines the preset localization area information and the address information of the resource file corresponding to the preset localization area in the document information, so that when the document is analyzed later, the resource file can be loaded according to the actual requirement, and the localization processing is carried out on the webpage according to the loaded resource file. In the document body, a target object to be localized in the document is identified by a preset keyword, and the original text is not modified, so that the readability of localization related codes is improved, and the maintenance complexity of the codes is reduced.
4. The hypertext markup language document provided by the invention is used for identifying the keywords of the target objects to be localized in the document, and also comprises the localization area information, and the localization area information is specified for the specific target objects, so that the subsequent localization processing of the webpage is more flexible.
5. According to the webpage page localization device, when the hypertext markup language document is analyzed, the first resource file corresponding to the current region information is firstly obtained according to the document information, when the document main body of the hypertext markup language document is analyzed, the target object to be localized is obtained according to the preset keyword, then the target object is localized through the first resource file, before the document main body is analyzed, the first resource file is firstly loaded and stored locally, when the browser analyzes the document main body, the target object to be localized is extracted according to the keyword, then the localization processing is carried out on the target object to be localized according to the resource file, and because the resource file at the moment is already stored locally, the user agent can complete the localization processing of the webpage page, the cooperation of the server is not needed, the load of the server is reduced, the webpage localization processing can be realized even if the network is disconnected, and the condition that the original webpage is firstly displayed and then the localized webpage is loaded is not appeared in the loading process of the webpage.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIGS. 1-4 are flowcharts illustrating specific examples of a method for localizing a web page in an embodiment of the present invention;
FIG. 5 is a block diagram illustrating a web page localization apparatus according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made apparent and fully in view of the accompanying drawings, in which some, but not all embodiments of the invention are shown. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In addition, the technical features of the different embodiments of the present invention described below may be combined with each other as long as they do not collide with each other.
Example 1
The present embodiment provides a hypertext markup language document comprising: document information and a document body;
the document information includes: the method comprises the steps of presetting localization area information of a hypertext markup language document and address information of a resource file corresponding to the preset localization area.
In a specific embodiment, the code of the hypertext markup language (HTML) document provided by the embodiment of the present invention is as follows:
in the above code, the content in the < head > tag is document information in which a rel attribute optional value is newly added based on a link (link) element: l10n, each link element of the rel attribute including the l10n keyword may specify a location (URL) where a localization resource file corresponding to a preset localization area (localization area may be expressed as: locale) is located. In the document information, a plurality of preset locales can be defined, and the position of the localized resource file corresponding to each preset locale is defined, for example, in the code, two preset locales are defined, which are respectively: zh_CN and zh, and the position of the resource file corresponding to the zh_CN is/steps/l 10n/zh_CN.json, and the position of the resource file corresponding to the zh is/steps/l 10n/zh.json. It should be noted that, in many areas, the same language may be used, but due to cultural differences, the usage habits of the words and the languages are different, for example, four locales of zh_tw (chinese traditional+taiwan), zh_sg (chinese traditional+singapore), zh_hk (chinese traditional+hong kong), zh_mo (chinese traditional+chinese australian), and the like, generally have very similar localization characteristics (all of traditional chinese, and names, places, professional terms, etc. are close to each other), but the localization characteristics of the four locales and the chinese continental zh_cn are greatly different, so zh_tw, zh_sg, zh_hk, zh_mo may be uniformly defined as zh, and distinguished from zh_cn, and the localization resource files corresponding to the two are also different.
The document body comprises a target object to be localized and preset keywords, wherein the preset keywords are used for identifying the target object to be localized.
In the above code, the content in the < body > tag is the document body, in which the content is expressed by "< -! The keyword L10N [ [ … ] ] ] ] ] "identifies the target object to be localized, i.e.," < -! The character string contained in L10N [ [ … ] ] ] ] "is a target object to be localized, and in the case where possible," ] > "must not be contained in the target object to be localized, but when" ] > "appears in the target object to be localized, HTML character entities should be used to represent, for example: < -! L10N [ [ Use < ])! L10N [ [ as the starting tag for L10N section and use ] ] > as the end tag for L10N section ] > to avoid errors in extracting the target object to be localized.
The target object to be localized may be a string identifier customized by the encoder, such as "myTitle" in the code, or default text, such as "Welcome to the world of < em > hybrid OS </SUB > ], in the code! In the preferred embodiment, it is proposed to define the target object to be localized in the second manner, by which the target object to be localized is defined, so that not only the readability of the original HTML document can be enhanced, but also the browser can still display the default text even if the localization cannot be performed due to the lack of the resource file later.
The hypertext markup language document provided by the embodiment of the invention defines the preset localization area information and the address information of the resource file corresponding to the preset localization target area in the document information, so that when the document is analyzed later, the resource file can be loaded according to actual requirements, and the localization processing is carried out on the webpage according to the loaded resource file. In the document body, a target object to be localized in the document is identified by a preset keyword, and the original text is not modified, so that the readability of localization related codes is improved, and the maintenance complexity of the codes is reduced.
In an alternative embodiment, the preset keywords in the HTML document include: and designating localization area information for identifying designated area information for localizing the target object to be localized. For example:
<!L10N[zh_TW[Welcome to the world of<em>HybridOS</em>!]]>,
in the HTML code, the preset keyword includes zh TW, namely, locale, when the subsequent pair of' Welcome to the world of < em > hybrid OS </em > ]! "when localization processing is performed," localization processing is performed based on the locale designated zh_tw.
The keyword used for identifying the target object to be localized in the file can also comprise the localization area information, and the localization area information is specified for the specific target object, so that the subsequent localization processing of the webpage is more flexible.
Example 2
The embodiment of the invention provides a web page localization method, which is suitable for carrying out localization processing on web page contents in the process of analyzing a hypertext markup language document by a browser analyzer, and as shown in fig. 1, comprises the following steps:
step S101: reading a hypertext markup language document; the hypertext markup language document includes: document information and a document body; the document information includes: preset localization area information of the hypertext markup language document and address information of a resource file corresponding to the preset localization area; the document body includes a target object to be localized and a preset keyword, where the preset keyword is used to identify the target object to be localized, and a detailed description of the hypertext markup language document is described in the above embodiment 1.
Step S102: current region information of the user agent is acquired. The current area information of the user agent refers to the language currently supported by the browser, and the current area information can be locale defined by an operating system or locale specified by a user for a specific Web app, wherein the priority of the current area information is higher than that of the locale defined by the operating system.
Step S103: and extracting a first resource file corresponding to the current region information from the document information of the hypertext markup language document according to the current region information. In a specific embodiment, if there is no resource file corresponding to the current region information, a resource file most similar to the localization feature of the current region is loaded, for example, when the current region information is zh_cn, but there is no resource file corresponding to zh_cn, a resource file corresponding to zh may be loaded.
Step S104: and extracting the target object to be localized from the hypertext markup language document according to the preset keywords. In a specific embodiment, in the process of parsing the hypertext markup language document, when a preset keyword is encountered, extracting a character string identified by the preset keyword, where the character string is a target object to be localized.
Step S105: and carrying out localization processing on the target object to be localized according to the first resource file.
According to the webpage page localization method provided by the embodiment of the invention, when the hypertext markup language document is analyzed, the first resource file corresponding to the current area information of the user agent is firstly obtained according to the document information, when the document body of the hypertext markup language document is analyzed, the target object to be localized is obtained according to the preset keywords, then the target object is localized through the first resource file, before the document body is analyzed, the first resource file is loaded and stored locally, when the browser analyzes the document body, the target object to be localized is extracted according to the keywords, and then the localization processing is carried out on the target object to be localized according to the first resource file, and as the first resource file is already stored locally, the cooperation of a server is not needed, the load of the server is reduced, the localization processing of the webpage can be realized even if the network is disconnected, and the localization processing of the webpage is synchronous in the loading process of the webpage, and the condition that the original webpage is displayed first and then the localized webpage is loaded is not occurred.
In a specific embodiment, a plurality of preset locales and resource files corresponding to the preset locales are defined in the document information, and when the step S103 is executed, after the first resource file is loaded, the other local resource files can be cached first, so that the resource files can be quickly loaded from the local cache when needed in the future, and the locale switching under the offline condition can be supported.
In an alternative embodiment, the hypertext markup language document further comprises: default area information for identifying default area information of a web page; for details, see the code in embodiment 1 above, "< html lang=" en_us ">" defines the default area information of the hypertext markup language document as "en_us", indicating that the default area used when writing the hypertext markup language document is "en_us".
As shown in fig. 2, after the step S102, before the step S103, the method further includes:
step S106: default region information is extracted from the hypertext markup language document.
Step S107: it is determined whether the default region information and the current region information are the same, that is, whether the language supported by the current browser is the same as the language used when writing the hypertext markup language document.
If the default area information and the current area information are not the same, step S103 is performed. In one embodiment, if the default region information is the same as the current information and no localized region information is specified in the hypertext markup language document, no operation is performed, and if the default region information is the same as the current region information but the localized region information is specified in the hypertext markup language document, steps S108-S110 are performed.
In an alternative embodiment, the preset keywords include: specific localization area information for identifying specific localization area information of a target object to be localized is described in detail in the above-described embodiment 1.
As shown in fig. 3, after step S104, before step S105, it includes:
step S108: it is determined whether the specified localized area information is identical to the current area information. Taking the code provided in example 1 above as an example, "< -! L10N [ zh_TW [ Welcome to the world of < em > hybrid OS </em > ]! In "] >," zh_TW "is the specific localization area information," Welcome to the world of < em > hybrid OS </em > ]! "is the target object to be localized, the line code indicates that" Welcome to the world of < em > hybrid OS </em > ]! Localization is performed "according to the criteria of" zh_tw ".
If the designated localization area is not identical to the current area information, step S109 and step S110 are executed.
Step S109: the second resource file corresponding to the specified localization area information is extracted from the document information of the hypertext markup language document according to the specified localization area information, as described in detail in step S103 above.
Step S110: and carrying out localization processing on the target object to be localized according to the second resource file.
If the preset keyword does not identify the designated localization area information of the target object to be localized, or if the designated localization area information is the same as the current area information, the above step S105 is performed.
According to the webpage page localization method provided by the embodiment of the invention, the localization area information is designated for the target object to be localized through the keywords, when the target object to be localized identified by the designated localization area information is analyzed, the localization processing is carried out on the target object to be localized according to the second resource file corresponding to the designated localization area information, and different contents can be flexibly converted into different languages according to different designated localization area information.
In an optional embodiment, the first resource file is a dictionary structure, the dictionary structure includes an interface, the interface includes a target object to be localized and current localization information, and the step S105 specifically includes: and inquiring a character string corresponding to the target object to be localized in the first resource file dictionary structure through the interface, and returning the character string. In a specific embodiment, when no character string corresponding to the target object to be localized exists in the resource file dictionary, the original text is returned. In a specific embodiment, when the dictionary structure of the first resource file does not exist, a preset keyword for specifying a target object to be localized in the hypertext markup language document is removed through the interface, and only default localization area information content is reserved.
In an optional embodiment, the second resource file is a dictionary structure, the dictionary structure includes an interface, the interface includes a target object to be localized and information specifying a localization area, and the step S110 specifically includes: and inquiring a character string corresponding to the target object to be localized in the second resource file dictionary structure through the interface, and returning the character string.
Example 3
The embodiment of the invention provides a web page localization method, as shown in fig. 4, comprising the following steps:
step S201, reading a hypertext markup language document; the hypertext markup language document includes: document information and a document body; the document information includes: preset localization area information of the hypertext markup language document and address information of a resource file corresponding to the preset localization area; the document body comprises a target object to be localized and preset keywords, the preset keywords are used for identifying the target object to be localized, and the preset keywords comprise: and specifying localization area information for identifying specified localization area information of the target object to be localized. For a detailed description of the hypertext markup language document, see embodiment 1 above.
Step S202, extracting a target object to be localized from the hypertext markup language document according to a preset keyword, wherein the detailed description is as shown in the step S104.
Step S203, judging whether the preset keyword includes the designated localization area information of the target object to be localized, taking the code provided in the above embodiment 1 as an example, "< -! L10N [ zh_TW [ Welcome to the world of < em > hybrid OS </em > ]! In "] >," zh_TW "is the specific localization area information," Welcome to the world of < em > hybrid OS </em > ]! "is the target object to be localized, the line code indicates that" Welcome to the world of < em > hybrid OS </em > ]! Localization is performed "according to the criteria of" zh_tw ".
If the preset keyword includes the designated localization area information of the target object of the to-be-localized area, step S204 is performed, and if the preset keyword does not include the designated localization area information of the target object of the to-be-localized area, no operation is performed.
Step S204, extracting a second resource file corresponding to the current region information from the document information of the hypertext markup language document according to the specified localization region information, wherein the detailed description is as shown in the step S103.
Step S205, the localization processing is carried out on the target object to be localized according to the second resource file.
According to the webpage page localization method provided by the embodiment of the invention, the localization area information is designated for the target object to be localized through the keywords, when the target object to be localized identified by the designated localization area information is analyzed, the target object to be localized is subjected to localization processing according to the second resource file corresponding to the designated localization area information, and different contents can be flexibly converted into different languages according to different designated localization area information.
Example 4
The present embodiment provides a web page localization apparatus, as shown in fig. 5, including:
a hypertext markup language document reading module 101 for reading a hypertext markup language document; the hypertext markup language document includes: document information and a document body; the document information includes: preset localization area information of the hypertext markup language document and address information of a resource file corresponding to the preset localization area; the document body comprises a target object to be localized and preset keywords, wherein the preset keywords are used for identifying the target object to be localized. The detailed description is given to the description of step S101 in the above-described embodiment 2.
The current area information obtaining module 102 is configured to obtain current area information of the user agent. The detailed description is given to the description of step S102 in the above-described embodiment 2.
A resource file obtaining module 103, configured to extract, from document information of the hypertext markup language document, a resource file corresponding to the current region information according to the current region information, where a detailed description is given in the above description of step S103 in embodiment 2.
The target object extracting module 104 to be localized is configured to extract the target object to be localized from the hypertext markup language document according to the preset keyword, and the detailed description of step S104 is described in the above embodiment 2.
The localization processing module 105 is configured to perform localization processing on the target object to be localized according to the first resource file, and the detailed description is described in the above embodiment 2 with reference to step S105.
According to the webpage page localization device provided by the embodiment of the invention, when the hypertext markup language document is analyzed, the first resource file corresponding to the current region information is firstly obtained according to the document information, when the document body of the hypertext markup language document is analyzed, the target object to be localized is obtained according to the preset keyword, then the localization processing is carried out on the target object through the first resource file, before the document body is analyzed, the first resource file is firstly loaded and stored locally, when the browser analyzes the document body, the target object to be localized is extracted according to the keyword, and then the localization processing is carried out on the target object to be localized according to the first resource file, and because the first resource file at the moment is already stored locally, the user agent can complete the localization processing on the webpage page without matching with a server, the load of the server is reduced, the localization processing of the webpage can be realized even if the network is disconnected, and the localization processing on the webpage is synchronous in the loading process of the webpage, and the condition that the original webpage is firstly displayed and then the localization processing on the localized webpage is carried out is avoided.
Example 5
An embodiment of the present invention provides a computer device, as shown in fig. 6, where the computer device mainly includes one or more processors 31 and a memory 32, and one processor 31 is illustrated in fig. 6.
The computer device may further include: an input device 33 and an output device 34.
The processor 31, the memory 32, the input device 33 and the output device 34 may be connected by a bus or otherwise, for example in fig. 6.
The processor 31 may be a central processing unit (Central Processing Unit, CPU). The processor 31 may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination thereof. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The memory 32 may include a storage program area that may store an operating system, at least one application program required for functions, and a storage data area; the storage data area may store data created from the use of the web page localization apparatus, etc. In addition, the memory 32 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 32 may optionally include memory located remotely from processor 31, which may be connected to the netpage page localization apparatus via a network. The input device 33 may receive a user entered calculation request (or other numeric or character information) and generate key signal inputs related to the netpage page localization device. The output device 34 may include a display device such as a display screen for outputting the calculation result.
Example 6
An embodiment of the present invention provides a computer-readable storage medium storing computer instructions, where the computer-readable storage medium stores computer-executable instructions, or the hypertext markup language document provided in embodiment 1, that can perform the web page localization method in any of the above-described method embodiments. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a Flash Memory (Flash Memory), a Hard Disk (HDD), or a Solid State Drive (SSD); the storage medium may also comprise a combination of memories of the kind described above.
It is apparent that the above examples are given by way of illustration only and are not limiting of the embodiments. Other variations or modifications of the above teachings will be apparent to those of ordinary skill in the art. It is not necessary here nor is it exhaustive of all embodiments. While still being apparent from variations or modifications that may be made by those skilled in the art are within the scope of the invention.

Claims (10)

1. A method for localizing a web page, comprising:
reading a hypertext markup language document; the hypertext markup language document includes: document information and a document body; the document information includes: preset localization area information of the hypertext markup language document and address information of a resource file corresponding to the preset localization area; the document body comprises a target object to be localized and a preset keyword, wherein the preset keyword is used for identifying the target object to be localized;
acquiring current area information of a user agent;
extracting a first resource file corresponding to the current region information from document information of the hypertext markup language document according to the current region information;
extracting the target object to be localized from the hypertext markup language document according to the preset keywords;
and carrying out localization processing on the target object to be localized according to the first resource file.
2. The web page localization method of claim 1, wherein the hypertext markup language document further comprises: default area information, wherein the default area information is used for identifying default area information of the webpage;
after the step of obtaining the current area information of the user agent, before the step of extracting the first resource file corresponding to the current area information from the document information of the hypertext markup language document according to the current area information, the method further comprises:
extracting the default region information from the hypertext markup language document;
judging whether the default area information and the current area information are the same or not;
and if the default area information is different from the current area information, executing the step of extracting a first resource file corresponding to the current area information from the document information of the hypertext markup language document according to the current area information.
3. The web page localization method of claim 1, wherein the preset keywords comprise: specifying localization area information for identifying the specified localization area information for the target object to be localized,
after the step of extracting the target object to be localized from the hypertext markup language document according to the preset keyword, before the step of localizing the target object to be localized according to the first resource file, the method comprises:
judging whether the designated localization area information is the same as the current area information;
if the appointed localization area is different from the current area information, extracting a second resource file corresponding to the appointed localization area information from the document information of the hypertext markup language document according to the appointed localization area information;
and carrying out localization processing on the target object to be localized according to the second resource file.
4. The web page localization method of claim 3, wherein,
and if the designated localization area information is the same as the current area information, executing the step of carrying out localization processing on the target object to be localized according to the first resource file.
5. The web page localization method as claimed in any one of claims 1-4, wherein the first resource file is a dictionary structure comprising an interface, the interface comprising a target object to be localized and the current region information;
the step of carrying out localization processing on the target object to be localized according to the first resource file comprises the following steps:
and inquiring a character string corresponding to the target object to be localized in the dictionary structure of the first resource file through the interface, and returning the character string.
6. A method for localizing a web page, comprising:
reading a hypertext markup language document; the hypertext markup language document includes: document information and a document body; the document information includes: preset localization area information of the hypertext markup language document and address information of a resource file corresponding to the preset localization area; the document body comprises a target object to be localized and a preset keyword, the preset keyword is used for identifying the target object to be localized, and the preset keyword comprises: designating localization area information for identifying designated localization area information for the target object to be localized;
extracting the target object to be localized from the hypertext markup language document according to the preset keywords;
judging whether the preset keywords comprise appointed localization area information of the target object to be localized;
if the preset keyword includes the specified localization area information of the target object of the area to be localized,
extracting a second resource file corresponding to the current region information from document information of the hypertext markup language document according to the specified localized region information;
and carrying out localization processing on the target object to be localized according to the second resource file.
7. The web page localization method as claimed in claim 3 or claim 6, wherein the second resource file is a dictionary structure including an interface therein, the interface including a target object to be localized and the specified localization area information;
the step of localizing the target object to be localized according to the second resource file includes:
and inquiring a character string corresponding to the target object to be localized in the dictionary structure of the second resource file through the interface, and returning the character string.
8. A web page localization apparatus, comprising:
the hypertext markup language document reading module is used for reading the hypertext markup language document; the hypertext markup language document includes: document information and a document body; the document information includes: preset localization area information of the hypertext markup language document and address information of a resource file corresponding to the preset localization area; the document body comprises a target object to be localized and a preset keyword, wherein the preset keyword is used for identifying the target object to be localized;
the current region information acquisition module is used for acquiring the current region information of the user agent;
a resource file acquisition module, configured to extract, according to the current region information, a first resource file corresponding to the current region information from document information of the hypertext markup language document;
the target object extraction module to be localized is used for extracting the target object to be localized from the hypertext markup language document according to the preset keywords;
and the localization processing module is used for carrying out localization processing on the target object to be localized according to the first resource file.
9. A computer device, comprising:
at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to perform the web page localization method of any one of claims 1-7.
10. A computer-readable storage medium storing computer instructions for causing the computer to perform the web page localization method of any one of claims 1-7.
CN202010398978.3A 2020-05-12 2020-05-12 Webpage localization method and device Active CN111563223B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010398978.3A CN111563223B (en) 2020-05-12 2020-05-12 Webpage localization method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010398978.3A CN111563223B (en) 2020-05-12 2020-05-12 Webpage localization method and device

Publications (2)

Publication Number Publication Date
CN111563223A CN111563223A (en) 2020-08-21
CN111563223B true CN111563223B (en) 2023-09-19

Family

ID=72073442

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010398978.3A Active CN111563223B (en) 2020-05-12 2020-05-12 Webpage localization method and device

Country Status (1)

Country Link
CN (1) CN111563223B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1609799A (en) * 2003-10-23 2005-04-27 微软公司 Resource manifest
EP1962204A1 (en) * 2007-02-21 2008-08-27 Axalto SA A personal token having enhanced abilities for delivering HTML data
CN101676904A (en) * 2008-09-19 2010-03-24 中兴通讯股份有限公司 Multilingual method of Web application system and device
CN101950251A (en) * 2010-09-14 2011-01-19 浙江大学 Localization method for mobile Widget
CN105138555A (en) * 2015-07-20 2015-12-09 新浪网技术(中国)有限公司 Webpage multi-language internationalization loading method and apparatus
CN105320687A (en) * 2014-07-29 2016-02-10 腾讯科技(北京)有限公司 Webpage display method and device
CN106874519A (en) * 2017-03-20 2017-06-20 百度在线网络技术(北京)有限公司 Webpage representation method and apparatus

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030084401A1 (en) * 2001-10-16 2003-05-01 Abel Todd J. Efficient web page localization
US9411793B2 (en) * 2010-07-13 2016-08-09 Motionpoint Corporation Dynamic language translation of web site content
US9465799B2 (en) * 2011-10-10 2016-10-11 Red Hat, Inc. Server-side internationalization and localization of web applications using a scripting language

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1609799A (en) * 2003-10-23 2005-04-27 微软公司 Resource manifest
EP1962204A1 (en) * 2007-02-21 2008-08-27 Axalto SA A personal token having enhanced abilities for delivering HTML data
CN101676904A (en) * 2008-09-19 2010-03-24 中兴通讯股份有限公司 Multilingual method of Web application system and device
CN101950251A (en) * 2010-09-14 2011-01-19 浙江大学 Localization method for mobile Widget
CN105320687A (en) * 2014-07-29 2016-02-10 腾讯科技(北京)有限公司 Webpage display method and device
CN105138555A (en) * 2015-07-20 2015-12-09 新浪网技术(中国)有限公司 Webpage multi-language internationalization loading method and apparatus
CN106874519A (en) * 2017-03-20 2017-06-20 百度在线网络技术(北京)有限公司 Webpage representation method and apparatus

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
Fault Localization for Dynamic Web Applications.;IEEE transactions on pattern analysis and machine intelligence;第38卷(第2期);全文 *
Social Risk Index to Hurricanes in Coastal Regions of Rhode Island:;Alolade Campbell;Natacha Thomas;Christopher Hunter;Cynthia Levesque;Transportation research record;第2009卷(第1期);全文 *
基于HTML5材料数据平台的离线技术研究与开发;程旭;刘复星;田玉靖;;计算机光盘软件与应用(第21期);全文 *
基于HTML5的Application Cache技术研究;刘艳平;俞海英;;微型机与应用(第20期);全文 *
多语言Web网站的结构与实现方法;杨成甫;陈朴;吴健;孙玉芳;;计算机应用研究(第02期);全文 *

Also Published As

Publication number Publication date
CN111563223A (en) 2020-08-21

Similar Documents

Publication Publication Date Title
US8769405B2 (en) Reduced glyph font files
WO2018133452A1 (en) Webpage rendering method and related device
US20120079374A1 (en) Rendering web page text in a non-native font
US9563611B2 (en) Merging web page style addresses
EP3316149A1 (en) Information acquiring method and apparatus, device, and computer storage medium
CN107798001B (en) Webpage processing method, device and equipment
CN104375808A (en) Method and device for displaying interfaces
CN111367595B (en) Data processing method, program running method, device and processing equipment
CN112306620B (en) Multi-language loading method and device for user-defined form control
CN111831384A (en) Language switching method and device, equipment and storage medium
CN105589959A (en) Form processing method and form processing system
CN112487763A (en) SVG-based OFD file online display method, server side and system
CN113419721B (en) Web-based expression editing method, device, equipment and storage medium
CN113360106B (en) Webpage printing method and device
CN111563223B (en) Webpage localization method and device
US10095791B2 (en) Information search method and apparatus
CN113139145B (en) Page generation method and device, electronic equipment and readable storage medium
CN114238475A (en) Data processing method of data warehouse
CN114417226A (en) Page generation method, display method, device, electronic equipment and storage medium
CN107656985B (en) Webpage query method and system
CN111639504A (en) Multi-language translation method, device and equipment for webpage
CN111857934A (en) Page loading method and device, electronic equipment and storage medium
CN114548079B (en) Text display method and device and readable storage medium
CN113722642B (en) Webpage conversion method and device, electronic equipment and storage medium
CN113051504B (en) Document preview method, device, apparatus, storage medium and program product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant