CN112965772A - Web page display method and device and electronic equipment - Google Patents

Web page display method and device and electronic equipment Download PDF

Info

Publication number
CN112965772A
CN112965772A CN202110233356.XA CN202110233356A CN112965772A CN 112965772 A CN112965772 A CN 112965772A CN 202110233356 A CN202110233356 A CN 202110233356A CN 112965772 A CN112965772 A CN 112965772A
Authority
CN
China
Prior art keywords
translated
language
target
content
file
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.)
Pending
Application number
CN202110233356.XA
Other languages
Chinese (zh)
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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202110233356.XA priority Critical patent/CN112965772A/en
Publication of CN112965772A publication Critical patent/CN112965772A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • G06F9/454Multi-language systems; Localisation; Internationalisation
    • 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/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9577Optimising the visualization of content, e.g. distillation of HTML documents

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Human Computer Interaction (AREA)
  • Machine Translation (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention provides a web page display method, a web page display device and electronic equipment, wherein a file to be translated is generated based on target content needing to be translated, which is extracted from a web code in a current language; adding marking information for target content in the web code under the current language; translating the file to be translated into a target language to obtain a translated file in the target language; and generating the web page in the target language based on the translated file in the target language and the web code in the current language added with the labeled information. According to the method, people do not need to learn the method and the characteristics of each language scheme, the contents to be translated in the web code are translated into the file to be translated, and then the web page in the target language can be obtained through the translated file and the labeling information of the contents to be translated in the web code.

Description

Web page display method and device and electronic equipment
Technical Field
The invention relates to the technical field of page development, in particular to a web page display method and device and electronic equipment.
Background
The world wide Web, the Web, is an architecture by which linked documents located throughout the internet on hosts may be accessed. As the use range of a web is expanded, on the premise of meeting the language requirements of developers in the home country, the use requirements of people in other countries need to be met, and therefore a web multi-language scheme needs to be introduced. The web multi-language scheme can be understood as that the web codes of the websites or the pages in multiple languages are obtained aiming at the same website or page.
In a method for generating a Web multi-language scheme in the related art, respective corresponding multi-language schemes are usually set for different Web front-end and back-end schemes, and a scheme difference corresponding to each language is large, so that for each specific front-end scheme (such as vue, angular, act, and the like), a developer needs to learn the multi-language scheme corresponding to each front-end scheme; moreover, for each specific backend scheme (such as flash, django, etc.), research personnel also need to learn the multi-language scheme corresponding to each backend scheme; meanwhile, because the schemes corresponding to each language are different, research personnel are required to inquire the using method, the characteristics and the like of the schemes according to the schemes, and the multi-language scheme learning cost is high.
Disclosure of Invention
The invention aims to provide a web page display method, a web page display device and electronic equipment so as to reduce the learning cost of a web multi-language scheme.
In a first aspect, the present invention provides a method for displaying a web page, the method comprising: extracting target content to be translated from the web code in the current language; generating a file to be translated corresponding to target content, and adding marking information for the target content in a web code under the current language; wherein, the marking information is used for indicating that the target content needs to be translated; translating the file to be translated into a target language to obtain a translated file in the target language; wherein, the target language is different from the language of the current language; and when the web page is displayed under the target language, generating the web page under the target language based on the translated file under the target language and the web code under the current language added with the labeled information.
In an optional embodiment, the step of extracting target content to be translated from the web code in the current language includes: extracting content corresponding to the current language from the web code under the current language; editing the extracted content corresponding to the current language, and deleting the content which does not need to be translated in the content corresponding to the current language to obtain the target content which needs to be translated.
In an optional embodiment, the step of generating the to-be-translated file corresponding to the target content includes: formatting the extracted target content to obtain a template to be translated; and generating a file to be translated based on the template to be translated.
In an optional embodiment, the number of languages of the target language is at least one; the step of generating the file to be translated based on the template to be translated comprises the following steps: generating a file to be translated corresponding to at least one template to be translated according to the language number of the target language; wherein, one file to be translated corresponds to one target language.
In an optional implementation manner, the step of adding annotation information to the target content in the web code in the current language includes: determining labeling information based on the extracted target content and a preset labeling function; and in the web code in the current language, replacing the target content with the labeling information to obtain the web code added with the labeling information.
In an optional embodiment, the number of languages of the target language is at least one; the number of the files to be translated is the same as the language number of the target language; the step of translating the file to be translated into the target language to obtain the translated file in the target language includes: and for each target language, translating the target content in the file to be translated corresponding to the current target language into the current target language to obtain the translated file in the current target language.
In an optional embodiment, the step of generating a web page in the target language based on the translated file in the target language and the web code in the current language added with the markup information includes: according to the translated file in the target language, translating the target content marked by the marking information in the web code in the current language added with the marking information into the target language; and displaying the target content translated into the target language in the web page under the target language.
In an optional embodiment, after the step of translating the to-be-translated document into the target language to obtain the translated document in the target language, the method further includes: if the web code in the current language is detected to be modified, extracting the modified web code in the current language; extracting target content to be translated from the modified web code in the current language; generating a to-be-translated file marked with the content to be updated based on the target content extracted from the modified web code in the current language and the target content extracted from the web code in the current language before modification; and translating the contents to be updated in the files to be translated marked with the contents to be updated into a target language to obtain a translated file in the final target language.
In an optional embodiment, the web code in the current language before modification corresponds to a template to be translated; the step of generating the to-be-translated file labeled with the content to be updated based on the target content extracted from the modified web code in the current language and the target content extracted from the web code in the current language before modification includes: formatting the target content extracted from the modified web code in the current language to obtain a modified template to be translated; comparing the modified template to be translated with the template to be translated corresponding to the web code in the current language before modification, and determining the content to be updated in the modified template to be translated; in the modified template to be translated, the content to be updated and the content which does not need to be updated are placed in a distinguishing manner, and the template to be translated marked with the content to be updated is obtained; and generating a to-be-translated file marked with the to-be-updated content according to the to-be-translated template marked with the to-be-updated content.
In an optional embodiment, the web code in the current language corresponds to a multi-language solution library; the multi-language solution library stores preset marking functions corresponding to marking information; after the step of translating the file to be translated into the target language to obtain the translated file in the target language, the method further includes: saving the translated files under the target language to a multi-language solution library; the step of generating a web page in the target language based on the translated file in the target language and the web code in the current language added with the markup information includes: when a web page needs to be displayed under a target language, acquiring a translated file under the target language from a multi-language solution library; translating target contents in the web code in the current language added with the labeling information into a target language according to the translated file in the target language and a preset labeling function; and displaying the target content translated into the target language in the web page under the target language.
In a second aspect, the present invention provides a web page display apparatus, comprising: the content extraction module is used for extracting target content to be translated from the web code in the current language; the content marking module is used for generating a file to be translated corresponding to the target content and adding marking information to the target content in the web code under the current language; wherein, the marking information is used for indicating that the target content needs to be translated; the file translation module is used for translating the file to be translated into a target language to obtain a translated file in the target language; wherein, the target language is different from the language of the current language; and the page display module is used for generating the web page in the target language based on the translated file in the target language and the web code in the current language added with the labeled information when the web page is displayed in the target language.
In a third aspect, the present invention provides an electronic device comprising a processor and a memory, the memory storing machine executable instructions capable of being executed by the processor, the processor executing the machine executable instructions to implement the web page display method of any one of the preceding embodiments.
In a fourth aspect, the present invention provides a computer-readable storage medium having stored thereon computer-executable instructions that, when invoked and executed by a processor, cause the processor to carry out a method of displaying a web page as claimed in any one of the preceding embodiments.
The embodiment of the invention has the following beneficial effects:
the invention provides a web page display method, a web page display device and electronic equipment.A target content needing to be translated is extracted from a web code in a current language; generating a file to be translated corresponding to the target content, and adding marking information to the target content in the web code under the current language; the marking information is used for indicating that the target content needs to be translated; translating the file to be translated into a target language to obtain a translated file in the target language; wherein the target language is different from the current language; and then generating a web page in the target language based on the translated file in the target language and the web code in the current language added with the labeling information. According to the method, research personnel do not need to learn and inquire methods and characteristics of various language schemes, contents needing to be translated in the web codes are translated into files to be translated, and then the web pages in the target language can be obtained through the translated files and the labeling information of the contents needing to be translated in the web codes.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention as set forth above.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a web page display method according to an embodiment of the present invention;
FIG. 2 is a flow chart of another method for displaying a web page according to an embodiment of the present invention;
FIG. 3 is a flow chart of another method for displaying a web page according to an embodiment of the present invention;
FIG. 4 is a flow chart of another method for displaying a web page provided by an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a web page display apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the related art, in the method for generating the Web multi-language scheme, the multi-language schemes corresponding to different Web front-end and back-end schemes are usually set, and the scheme difference corresponding to each language is large, so that research personnel are required to inquire the using method, the characteristics and the like of the scheme for the scheme corresponding to each language, and meanwhile, the Web multi-language scheme is large, so that the multi-language scheme learning cost is high. Moreover, the existing web multilingual solution has the following problems:
1. different web front-end and back-end frameworks generally have own multi-language schemes, so that when a front end or a back end is contacted, a research and development staff needs to learn the multi-language schemes of the front end or the back end, a certain learning cost is needed to inquire the using method and characteristics of the front end or the back end, and the front end and the back end need to learn from the beginning when problems occur.
2. The schema provided by the front-end framework is often an example, i.e., tells us how to implement multi-lingual functionality.
3. Some web solutions internationalize the project, the original text is replaced with $ ("XXX"), where XXX is the ID (Identity Document) of the tag, usually a meaningless number or letter, making the code unreadable. For example, if a description page is all Chinese, the entire page cannot be read at all after replacement.
Based on the above problems, embodiments of the present invention provide a web page display method, apparatus, and electronic device; the technology can be applied to a page or a multi-language scheme generation scene of a webpage. To facilitate understanding of the embodiment, a detailed description is first made of a web page display method disclosed in the embodiment of the present invention, as shown in fig. 1, the method includes the following steps:
step S102, extracting target content needing translation from the web code under the current language.
The current language is generally a kind of language used for the text in the web code, and may be, for example, chinese, japanese, korean, or english. The web code usually includes a code corresponding to a programming language and also includes text content expressed by a certain language, and usually, if the text content in the web code is expressed by a current language, the content displayed in the text web page is also expressed by the current language. The web code can be a code corresponding to a front end of the web or a code corresponding to a back end of the web, wherein the front end of the web is a page usually seen when the web is accessed, and the whole layout including pictures, characters, frame distribution, videos, voices and the like in the page is the front end of the web; the web backend is more related to the corresponding business logic to be processed when interacting with the database, and how to realize functions, data access, platform stability and performance, and the like need to be considered.
The target content to be translated may refer to: text content corresponding to the current language in the web code under the current language; the current language corresponding to the extracted target content to be translated can be configured by the user through the terminal device.
Step S104, generating a file to be translated corresponding to the target content, and adding label information for the target content in the web code under the current language; wherein, the annotation information is used for indicating that the target content needs to be translated.
During specific implementation, the extracted target content is formatted or standardized to obtain the files to be translated, the number of the files to be translated is matched with the number of languages of the target language to be translated, if the files to be translated are 5 target languages, the number of the files to be translated is 5, the content of each file to be translated is the same, but the language type to be translated of each file to be translated is different.
And adding marking information for the target content in the web code under the current language so as to mark the target content to be translated in the web code under the current language. The above-mentioned label information may be set according to the development requirement, for example, the target content to be translated in the web code in the current language may be replaced, or the content to be translated may be labeled in the web code in the current language by using another symbol or identifier.
Step S106, translating the file to be translated into a target language to obtain a translated file in the target language; wherein the target language is different from the current language.
The target language is a language type that the user wants to use, the language type of the target language is different from that of the current language, and the target language can be multiple, so as to meet the international requirement. In specific implementation, translation software can translate target content in a current language in a file to be translated into a target language; or a professional can translate the target content in the current language in the file to be translated into the target language, so as to obtain the translated file in the target language.
And S108, when the web page is displayed under the target language, generating the web page under the target language based on the translated file under the target language and the web code under the current language added with the labeling information.
In a specific implementation, when a user wants to display a web page in a target language, first, according to a translated file in the target language, target content corresponding to markup information in a web code in a current language to which the markup information is added is translated into the target language, so that the target content translated into the target language is displayed in the web page in the target language. It should be noted that the target content corresponding to the annotation information in the web code is generally a page that needs to be displayed in a web page.
The web page display method provided by the embodiment of the invention comprises the steps of firstly extracting target content to be translated from web codes in the current language; generating a file to be translated corresponding to the target content, and adding marking information to the target content in the web code under the current language; the marking information is used for indicating that the target content needs to be translated; translating the file to be translated into a target language to obtain a translated file in the target language; wherein the target language is different from the current language; and then generating a web page in the target language based on the translated file in the target language and the web code in the current language added with the labeling information. According to the method, research personnel do not need to learn and inquire methods and characteristics of various language schemes, contents needing to be translated in the web codes are translated into files to be translated, and then the web pages in the target language can be obtained through the translated files and the labeling information of the contents needing to be translated in the web codes.
The embodiment of the invention also provides another web page display method, which is realized on the basis of the method of the embodiment; the method mainly describes a specific process of extracting target content to be translated from web codes in a current language (realized through steps S202-S204 described below), a specific process of generating a file to be translated corresponding to the target content (realized through steps S206-S208 described below), a specific process of adding label information to the target content in the web codes in the current language (realized through steps S210-S212 described below), and a specific process of generating a web page in the target language based on the translated file in the target language and the web codes in the current language to which the label information is added (realized through step S216 described below); as shown in fig. 2, the method comprises the following specific steps:
step S202, extracting the content corresponding to the current language from the web code under the current language.
In a specific implementation, the web code in the current language can only display the current language in the web page, and it can also be understood that the web code in the current language can provide a web scheme corresponding to the current language. When the web multilingual scheme is implemented, the text content corresponding to the current language needs to be extracted from the web code in the current language so as to be represented by replacing the text content corresponding to the current language with another language, and specifically, while the text content corresponding to the current language is extracted, the line number of the text content in the web code needs to be extracted so as to verify and confirm the extracted content corresponding to the current language.
And step S204, editing the extracted content corresponding to the current language, and deleting the content which does not need to be translated in the content corresponding to the current language to obtain the target content which needs to be translated.
The content that does not need to be translated in the content corresponding to the current language may be content such as a comment of a web code, a remark added by a user, and the like. In specific implementation, the text extraction tool can be used to edit the extracted content corresponding to the current language, so as to process the content that does not need to be translated, such as notes, comments and the like, and obtain the target content that needs to be translated. In some embodiments, in order to ensure that all the obtained target contents need to be translated, after editing processing is performed by using a text extraction tool, whether contents which do not need to be translated still exist in the target contents can be manually checked, and if the contents do not need to be translated, the contents which do not need to be translated are deleted.
And step S206, formatting the extracted target content to obtain a template to be translated.
According to a preset format, the extracted target content needing to be translated can be formatted, so that a professional or translation software can translate and edit the target content conveniently. The preset format can be set according to research and development requirements.
And step S208, generating a file to be translated based on the template to be translated.
The content contained in the file to be translated is the same as the content contained in the template to be translated, but only one template to be translated is contained, but the number of the files to be translated is multiple. In the concrete implementation, the number of languages of the target language is at least one; generating a file to be translated corresponding to at least one template to be translated according to the language number of the target language; wherein, one file to be translated corresponds to one target language. That is, when the number of languages of the target language is multiple, a plurality of documents to be translated need to be generated according to the template to be translated, for example, when the target language is korean, japanese and chinese, 3 documents to be translated, that is, the document to be translated corresponding to korean, the document to be translated corresponding to japanese and the document to be translated corresponding to chinese, are generated according to the template to be translated.
Step S210, determining the labeling information based on the extracted target content and the preset labeling function.
The preset labeling function may be set according to development requirements, and may be set to _ (), or () or the like, for example. In a specific implementation, the annotation information may be a combination of the target content and a preset annotation function, for example, if the target content is "please enter an account", then the annotation information may be "_ (please enter an account)". In this way, in order to enable fast and professional internationalization, attempts are made to simplify access to the contents and to simplify the annotation information required to be translated into multilingual text (i.e., target content).
Step S212, in the web code in the current language, replacing the target content with the labeling information to obtain the web code added with the labeling information.
Target contents in the web code in the current language are replaced by the labeling information, so that the web code added with the labeling information can be obtained, and the labeling information is used for labeling text contents needing to be translated in the web code in the current language.
Step S214, translating the file to be translated into a target language to obtain a translated file in the target language; wherein the target language is different from the current language.
In the specific implementation, the number of languages of the target language is at least one; the number of the files to be translated is the same as the language number of the target language; and for each target language, translating the target content in the file to be translated corresponding to the current target language into the current target language to obtain the translated file in the current target language. That is, for each target language corresponding to the to-be-translated document, the target content in the to-be-translated document needs to be translated into the target language corresponding to the to-be-translated document.
Step S216, when the web page needs to be displayed under the target language, translating the target content labeled by the label information in the web code under the current language added with the label information into the target language according to the translated file under the target language; and displaying the target content translated into the target language in the web page under the target language.
In a specific implementation, the steps S202 to S216 may be implemented by a preset tool chain, where the tool chain includes a plurality of tools, one tool may be understood as a packaged program, and an output of one program constitutes an entry of another program, so as to form a series of programs (i.e., the tool chain) to implement a specific function or achieve a specific purpose.
Specifically, a current language to be extracted may be set in the text extraction tool, then, the content corresponding to the current language is extracted from the web code in the current language through the text extraction tool, and the extracted content corresponding to the current language is edited to obtain a target content to be translated; replacing target content in the web code in the current language with the target content and a preset labeling function through a text labeling tool to obtain the web code added with labeling information; formatting the extracted target content through a translation template generation tool to obtain a template to be translated; generating a file to be translated based on a template to be translated through a file to be translated generating tool, and generating a plurality of files to be translated if a plurality of languages are required to be generated; then translating the file to be translated into a target language to obtain a translated file in the target language; and according to the translated file in the target language, translating the target content labeled by the label information in the web code in the current language added with the label information into the target language to obtain the web page in the target language.
Specifically, the web code is viewed by naked eyes, the target content needing to be translated is often time-consuming and easy to make mistakes, and the method uses the text extraction tool to extract the target content in the web code, so that the time consumption of text extraction is greatly reduced. Moreover, marking the text in the web code as the text requiring multiple languages is also a problem to be faced certainly, if the text is manually sorted, the situations of omission and error sorting are easy to occur, the efficiency is low, and the process is very complicated.
According to the web page display method, the translated file comprises the translated text of the content corresponding to the language currently used in the web code in the target language, the content corresponding to the language currently used in the web code can be translated into the target language through the translated file, so that the web page can be realized by the target language, and the realization scheme of the text page in the target language is obtained.
The embodiment of the invention also provides another web page display method, which is realized on the basis of the method of the embodiment; the method mainly describes a specific process of updating the translated file under the condition that the web code in the current language is modified (realized by the following steps S308-S314); as shown in fig. 3, the method comprises the following specific steps:
step S302, extracting target content needing translation from the web code under the current language.
And step S304, generating a file to be translated corresponding to the target content.
Step S306, translating the file to be translated into a target language to obtain a translated file in the target language; wherein the target language is different from the current language.
In step S308, if it is detected that the web code in the current language is modified, the modified web code in the current language is extracted.
Step S310, extracting target content needing to be translated from the modified web code in the current language; and adding annotation information for the target content in the modified web code in the current language.
After obtaining the translated file in the target language, if the web code in the current language is modified (for example, some part of code is updated or a new code is added), extracting the modified web code in the current language, and extracting target content to be translated from the modified web code in the current language; and then adding the label information to the target content in the modified web code in the current language to obtain the modified web code in the current language added with the label information. The manner of adding the label information is the same as the above steps S210-S212, and is not described herein again.
Step S312, a to-be-translated file labeled with the to-be-updated content is generated based on the target content extracted from the modified web code in the current language and the target content extracted from the web code in the current language before modification.
In specific implementation, the target content extracted from the modified web code in the current language may be compared with the target content extracted from the web code in the current language before modification, different contents from the target content extracted from the modified web code in the current language and the target content extracted from the web code in the current language before modification are determined, the determined different contents are determined as the contents to be updated, and then the file to be translated, to which the contents to be updated are marked, is generated. In a specific implementation, the web code in the current language before modification corresponds to a template to be translated (which can be implemented in step S206 and is not described herein again); the above step S312 can be realized by the following steps 10 to 12:
and step 10, formatting the target content extracted from the modified web code in the current language to obtain the modified template to be translated.
And 11, comparing the modified template to be translated with the template to be translated corresponding to the web code in the current language before modification, and determining the content to be updated in the modified template to be translated.
And determining different contents in the template to be translated corresponding to the web code in the current language before modification in the modified template to be translated as the contents to be updated in the modified template to be translated.
Step 12, distinguishing and placing the contents to be updated and the contents not to be updated in the modified template to be translated to obtain the template to be translated marked with the contents to be updated; and generating a to-be-translated file marked with the to-be-updated content according to the to-be-translated template marked with the to-be-updated content.
For example, in the modified template to be translated, the content to be updated is placed at the top, and is separated from the content which does not need to be updated by a separation line.
Step S314, translating the content to be updated in the file to be translated, to which the content to be updated is marked, into the target language, so as to obtain the translated file in the final target language.
In the concrete implementation, when the web code in the current language is modified, only the content to be updated needs to be translated, and the content, except the content to be updated, in the file to be translated, marked with the content to be updated uses the content in the translated file corresponding to the web code in the current language before modification, so as to obtain the final translated file in the target language.
Step S316, when the web page is displayed in the target language, the web page in the target language is generated based on the translated file in the final target language and the modified web code in the current language added with the annotation information.
According to the web page display method, if the web code in the current language is detected to be modified, the modified web code in the current language is extracted; extracting target content to be translated from the modified web code in the current language; adding marking information to the target content in the modified web code in the current language; generating a to-be-translated file marked with the content to be updated based on the target content extracted from the modified web code in the current language and the target content extracted from the web code in the current language before modification; translating the contents to be updated in the files to be translated marked with the contents to be updated into a target language to obtain a translated file in the final target language; and then generating a web page in the target language based on the translated file in the final target language and the modified web code in the current language added with the labeling information. In the method, when the web code in the current language is modified, all contents in the web code do not need to be seen again, and only the text to be translated is directly positioned to the newly added and modified text, namely the content to be updated, and then the content to be updated is translated, so that the updating cost of the translated file is saved. Meanwhile, the method covers the whole processes of text extraction, text labeling, translation file introduction and translation updating iteration schemes in the web multi-language scheme, and can solve the process problems in the web multi-language one by one.
The embodiment of the invention also provides another web page display method, which is realized on the basis of the method of the embodiment; the method mainly describes a specific process of adding label information to target content in web code in a current language (realized by the following steps S406), and a specific process of generating a web page in the target language based on a translated file in the target language and the web code in the current language added with the label information (realized by the following steps S412-S414); as shown in fig. 4, the method includes the steps of:
step S402, extracting target content needing translation from the web code under the current language.
And step S404, generating a file to be translated corresponding to the target content.
Step S406, determining labeling information based on the extracted target content and a preset labeling function; and in the web code in the current language, replacing the target content with the labeling information to obtain the web code added with the labeling information.
Step S408, translating the file to be translated into the target language to obtain the translated file in the target language.
Step S410, storing the translated file under the target language into a multi-language solution library.
In concrete implementation, the web code in the current language corresponds to a multi-language solution library; in an initial state, a preset labeling function corresponding to the labeling information is stored in the multi-language solution library. And when the translated file in the target language is obtained, saving the translated file in the target language into the multi-language solution library. The multi-language solution library comprises a plurality of target languages, and web solutions corresponding to the plurality of languages.
Step S412, when the web page needs to be displayed under the target language, the translated file under the target language is obtained from the multi-language solution library.
Step S414, translating the target content in the web code in the current language added with the labeling information into the target language according to the translated file in the target language and a preset labeling function; and displaying the target content translated into the target language in the web page under the target language.
In specific implementation, target content to be translated can be determined in the web code in the current language added with the labeling information through a preset labeling function; and then, translating the target content determined in the web code in the current language added with the labeling information into the target language through the translated file in the target language to obtain the web page in the target language.
According to the web page display method, the use method and the characteristics of the web page are not required to be inquired for different web multi-language schemes, and the web scheme corresponding to each language can be automatically obtained only by the preset labeling function stored in the multi-language solution library and the translated files corresponding to various languages, so that the learning cost is reduced. Meanwhile, the method enables the front end and the back end of the web to be consistent, has the minimum influence on the original web code, and does not influence the reading of the original web code at all.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a web page display apparatus, as shown in fig. 5, the apparatus includes:
and the content extraction module 50 is used for extracting target content to be translated from the web code in the current language.
The content tagging module 51 is configured to generate a to-be-translated file corresponding to the target content, and add tagging information to the target content in the web code in the current language; wherein, the annotation information is used for indicating that the target content needs to be translated.
The file translation module 52 is configured to translate a file to be translated into a target language to obtain a translated file in the target language; wherein the target language is different from the current language.
And a page display module 53, configured to, when displaying the web page in the target language, generate the web page in the target language based on the translated file in the target language and the web code in the current language to which the annotation information is added.
The web page display device firstly extracts target content to be translated from web codes in the current language; generating a file to be translated corresponding to the target content, and adding marking information to the target content in the web code under the current language; the marking information is used for indicating that the target content needs to be translated; translating the file to be translated into a target language to obtain a translated file in the target language; wherein the target language is different from the current language; and then generating a web page in the target language based on the translated file in the target language and the web code in the current language added with the labeling information. According to the method, research personnel do not need to learn and inquire methods and characteristics of various language schemes, contents needing to be translated in the web codes are translated into files to be translated, and then the web pages in the target language can be obtained through the translated files and the labeling information of the contents needing to be translated in the web codes.
Further, the content extracting module 50 is configured to: extracting content corresponding to the current language from the web code under the current language; editing the extracted content corresponding to the current language, and deleting the content which does not need to be translated in the content corresponding to the current language to obtain the target content which needs to be translated.
Further, the content labeling module 51 is configured to: formatting the extracted target content to obtain a template to be translated; and generating a file to be translated based on the template to be translated.
Specifically, the number of languages of the target language is at least one; the content labeling module 51 is further configured to: generating a file to be translated corresponding to at least one template to be translated according to the language number of the target language; wherein, one file to be translated corresponds to one target language.
Further, the content labeling module 51 is configured to: determining labeling information based on the extracted target content and a preset labeling function; and in the web code in the current language, replacing the target content with the labeling information to obtain the web code added with the labeling information.
Furthermore, the number of languages of the target language is at least one; the number of the files to be translated is the same as the language number of the target language; the document translation module 52 is configured to: and for each target language, translating the target content in the file to be translated corresponding to the current target language into the current target language to obtain the translated file in the current target language.
Further, the page display module 53 is configured to: according to the translated file in the target language, translating the target content marked by the marking information in the web code in the current language added with the marking information into the target language; and displaying the target content translated into the target language in the web page under the target language.
During specific implementation, the device further comprises a file updating module, wherein the file updating module is used for translating the file to be translated into the target language, obtaining the translated file in the target language, and extracting the modified web code in the current language if the web code in the current language is detected to be modified; extracting target content to be translated from the modified web code in the current language; generating a to-be-translated file marked with the content to be updated based on the target content extracted from the modified web code in the current language and the target content extracted from the web code in the current language before modification; and translating the contents to be updated in the files to be translated marked with the contents to be updated into a target language to obtain a translated file in the final target language.
Further, the file update module is further configured to: formatting the target content extracted from the modified web code in the current language to obtain a modified template to be translated; comparing the modified template to be translated with the template to be translated corresponding to the web code in the current language before modification, and determining the content to be updated in the modified template to be translated; in the modified template to be translated, the content to be updated and the content which does not need to be updated are placed in a distinguishing manner, and the template to be translated marked with the content to be updated is obtained; and generating a to-be-translated file marked with the to-be-updated content according to the to-be-translated template marked with the to-be-updated content.
In concrete implementation, the web code in the current language corresponds to a multi-language solution library; the multi-language solution library stores preset marking functions corresponding to marking information; the device also comprises a file storage module, a translation module and a multi-language solution library, wherein the file storage module is used for translating the file to be translated into the target language, and storing the translated file in the target language into the multi-language solution library after the translated file in the target language is obtained; the page display module 53 is further configured to: when a web page needs to be displayed under a target language, acquiring a translated file under the target language from a multi-language solution library; translating target contents in the web code in the current language added with the labeling information into a target language according to the translated file in the target language and a preset labeling function; and displaying the target content translated into the target language in the web page under the target language.
The web page display device provided by the embodiment of the invention has the same implementation principle and technical effect as the web page display method embodiment, and for brief description, the corresponding content in the method embodiment can be referred to where the device embodiment is not mentioned.
An embodiment of the present invention further provides an electronic device, which is shown in fig. 6 and includes a processor 101 and a memory 100, where the memory 100 stores machine executable instructions that can be executed by the processor 101, and the processor executes the machine executable instructions to implement the web page display method.
Further, the electronic device shown in fig. 6 further includes a bus 102 and a communication interface 103, and the processor 101, the communication interface 103, and the memory 100 are connected through the bus 102.
The Memory 100 may include a high-speed Random Access Memory (RAM) and may further include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, and the like can be used. The bus 102 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 6, but that does not indicate only one bus or one type of bus.
The processor 101 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 101. The Processor 101 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100, and completes the steps of the method of the foregoing embodiment in combination with the hardware thereof.
The embodiment of the present invention further provides a machine-readable storage medium, where the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to implement the web page display method.
The web page display method, the web page display apparatus, and the computer program product of the electronic device provided in the embodiments of the present invention include a computer-readable storage medium storing a program code, where instructions included in the program code may be used to execute the method described in the foregoing method embodiments, and specific implementations may refer to the method embodiments and are not described herein again.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, an electronic device, or a network device) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (13)

1. A method for displaying a web page, the method comprising:
extracting target content to be translated from the web code in the current language;
generating a file to be translated corresponding to the target content, and adding marking information to the target content in the web code under the current language; wherein the annotation information is used for indicating that the target content needs to be translated;
translating the file to be translated into a target language to obtain a translated file in the target language; wherein the target language is different from the current language;
and when the web page is displayed under the target language, generating the web page under the target language based on the translated file under the target language and the web code under the current language added with the labeled information.
2. The method of claim 1, wherein the step of extracting the target content to be translated from the web code in the current language comprises:
extracting content corresponding to the current language from the web code under the current language;
editing the extracted content corresponding to the current language, and deleting the content which does not need to be translated in the content corresponding to the current language to obtain the target content which needs to be translated.
3. The method according to claim 1, wherein the step of generating the to-be-translated file corresponding to the target content comprises:
formatting the extracted target content to obtain a template to be translated;
and generating the file to be translated based on the template to be translated.
4. The method according to claim 3, wherein the number of languages of the target language is at least one; the step of generating the file to be translated based on the template to be translated comprises the following steps:
generating a file to be translated corresponding to at least one template to be translated according to the language number of the target language; wherein, one of the files to be translated corresponds to a target language.
5. The method of claim 1, wherein the step of adding annotation information to the target content in the web code in the current language comprises:
determining labeling information based on the extracted target content and a preset labeling function;
and replacing the target content with the labeling information in the web code in the current language to obtain the web code added with the labeling information.
6. The method according to claim 1, wherein the number of languages of the target language is at least one; the number of the files to be translated is the same as the language number of the target language;
the step of translating the file to be translated into the target language to obtain the translated file in the target language comprises the following steps:
and for each target language, translating the target content in the file to be translated corresponding to the current target language into the current target language to obtain a translated file in the current target language.
7. The method of claim 1, wherein the step of generating a web page in the target language based on the translated file in the target language and the web code in the current language with added annotation information comprises:
according to the translated file in the target language, translating the target content labeled by the label information in the web code in the current language added with the label information into the target language;
and displaying the target content translated into the target language in the web page under the target language.
8. The method according to claim 1, wherein after the step of translating the file to be translated into the target language to obtain the translated file in the target language, the method further comprises:
if the web code in the current language is detected to be modified, extracting the modified web code in the current language;
extracting target content to be translated from the modified web code in the current language;
generating a to-be-translated file marked with to-be-updated content based on the target content extracted from the modified web code in the current language and the target content extracted from the web code in the current language before modification;
translating the content to be updated in the file to be translated marked with the content to be updated into a target language to obtain a final translated file in the target language.
9. The method of claim 8, wherein the web code in the current language before modification corresponds to a template to be translated; the step of generating a to-be-translated file labeled with content to be updated based on the target content extracted from the web code in the current language after modification and the target content extracted from the web code in the current language before modification includes:
formatting the target content extracted from the modified web code in the current language to obtain a modified template to be translated;
comparing the modified template to be translated with a template to be translated corresponding to the web code in the current language before modification, and determining the content to be updated in the modified template to be translated;
in the modified template to be translated, distinguishing and placing the content to be updated and the content which does not need to be updated, and obtaining the template to be translated marked with the content to be updated; and generating a to-be-translated file marked with the to-be-updated content according to the to-be-translated template marked with the to-be-updated content.
10. The method of claim 1, wherein the web code in the current language corresponds to a multi-lingual solution library; a preset labeling function corresponding to the labeling information is stored in the multi-language solution library;
after the step of translating the file to be translated into the target language to obtain the translated file in the target language, the method further comprises:
saving the translated files in the target language to the multi-language solution library;
the step of generating a web page in the target language based on the translated file in the target language and the web code in the current language added with the labeling information includes:
when a web page needs to be displayed under the target language, acquiring a translated file under the target language from the multi-language solution library;
translating the target content in the web code in the current language added with the labeling information into a target language according to the translated file in the target language and the preset labeling function;
and displaying the target content translated into the target language in the web page under the target language.
11. A web page display apparatus, characterized in that the apparatus comprises:
the content extraction module is used for extracting target content to be translated from the web code in the current language;
the content marking module is used for generating a file to be translated corresponding to the target content and adding marking information to the target content in the web code under the current language; wherein the annotation information is used for indicating that the target content needs to be translated;
the file translation module is used for translating the file to be translated into a target language to obtain a translated file in the target language; wherein the target language is different from the current language;
and the page display module is used for generating the web page in the target language based on the translated file in the target language and the web code in the current language added with the labeling information when the web page is displayed in the target language.
12. An electronic device comprising a processor and a memory, the memory storing machine executable instructions executable by the processor, the processor executing the machine executable instructions to implement the web page display method of any one of claims 1 to 10.
13. A computer-readable storage medium having stored thereon computer-executable instructions that, when invoked and executed by a processor, cause the processor to implement the web page display method of any of claims 1 to 10.
CN202110233356.XA 2021-03-02 2021-03-02 Web page display method and device and electronic equipment Pending CN112965772A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110233356.XA CN112965772A (en) 2021-03-02 2021-03-02 Web page display method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110233356.XA CN112965772A (en) 2021-03-02 2021-03-02 Web page display method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN112965772A true CN112965772A (en) 2021-06-15

Family

ID=76277513

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110233356.XA Pending CN112965772A (en) 2021-03-02 2021-03-02 Web page display method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN112965772A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114371905A (en) * 2022-01-14 2022-04-19 武汉源启科技股份有限公司 Page rendering method and device
CN114462430A (en) * 2022-01-18 2022-05-10 北京星辰天合科技股份有限公司 Entry extraction method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104915204A (en) * 2015-06-08 2015-09-16 小米科技有限责任公司 Web processing method and device
US20160085746A1 (en) * 2014-09-24 2016-03-24 International Business Machines Corporation Selective machine translation with crowdsourcing
US20170031876A1 (en) * 2015-07-27 2017-02-02 Adp, Llc Web Page Generation System
CN107451128A (en) * 2017-08-04 2017-12-08 深圳Tcl新技术有限公司 Multilingual code adaptation method, equipment and storage medium
CN110263351A (en) * 2019-06-17 2019-09-20 深圳前海微众银行股份有限公司 A kind of multi-language translation method of webpage, device and equipment
CN110334323A (en) * 2019-04-26 2019-10-15 网易(杭州)网络有限公司 Translate data processing method, device, equipment and computer readable storage medium
WO2020248849A1 (en) * 2019-06-14 2020-12-17 平安科技(深圳)有限公司 Webpage language switching method and apparatus, and terminal device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160085746A1 (en) * 2014-09-24 2016-03-24 International Business Machines Corporation Selective machine translation with crowdsourcing
CN104915204A (en) * 2015-06-08 2015-09-16 小米科技有限责任公司 Web processing method and device
US20170031876A1 (en) * 2015-07-27 2017-02-02 Adp, Llc Web Page Generation System
CN107451128A (en) * 2017-08-04 2017-12-08 深圳Tcl新技术有限公司 Multilingual code adaptation method, equipment and storage medium
CN110334323A (en) * 2019-04-26 2019-10-15 网易(杭州)网络有限公司 Translate data processing method, device, equipment and computer readable storage medium
WO2020248849A1 (en) * 2019-06-14 2020-12-17 平安科技(深圳)有限公司 Webpage language switching method and apparatus, and terminal device
CN110263351A (en) * 2019-06-17 2019-09-20 深圳前海微众银行股份有限公司 A kind of multi-language translation method of webpage, device and equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
关春园,徐宏亮: "《多元化视角下的日语研究》", 31 January 2015 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114371905A (en) * 2022-01-14 2022-04-19 武汉源启科技股份有限公司 Page rendering method and device
CN114462430A (en) * 2022-01-18 2022-05-10 北京星辰天合科技股份有限公司 Entry extraction method and device

Similar Documents

Publication Publication Date Title
CN108595389B (en) Method for converting Word document into txt plain text document
CN113609820B (en) Method, device and equipment for generating word file based on extensible markup language file
US7149971B2 (en) Method, apparatus, and system for providing multi-language character strings within a computer
US9384389B1 (en) Detecting errors in recognized text
CN111177184A (en) Structured query language conversion method based on natural language and related equipment thereof
US7231600B2 (en) File translation
CN111176650B (en) Parser generation method, search method, server, and storage medium
CN112965772A (en) Web page display method and device and electronic equipment
WO2019042349A1 (en) Translation method, mobile terminal and storage device of operating system framework
CN114238575A (en) Document parsing method, system, computer device and computer-readable storage medium
WO2022134577A1 (en) Translation error identification method and apparatus, and computer device and readable storage medium
CN110543641B (en) Chinese and foreign language information comparison method and device
CN111241096A (en) Text extraction method, system, terminal and storage medium for EXCEL document
CN103440231A (en) Equipment and method for comparing texts
CN111679825A (en) Cascading style sheet generation method and device, computer equipment and storage medium
CN113127776A (en) Breadcrumb path generation method and device and terminal equipment
US7503036B2 (en) Testing multi-byte data handling using multi-byte equivalents to single-byte characters in a test string
CN113297425B (en) Document conversion method, device, server and storage medium
CN112686000B (en) Format conversion method of electronic book document, electronic equipment and storage medium
US11030387B1 (en) Device dependent rendering of PDF content including multiple articles and a table of contents
CN113283233A (en) Text error correction method and device, electronic equipment and storage medium
CN111443979B (en) Document processing method, device, computer equipment and storage medium
CN111158805B (en) Delphi software source language translation system, method, equipment and medium
CN116522966B (en) Text translation method and system based on multilingual vocabulary entry
US11416671B2 (en) Device dependent rendering of PDF content

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20210615

RJ01 Rejection of invention patent application after publication