Front-end page processing method and related product

By determining the text and its translation attribute information on the front-end page and selecting the appropriate interface for translation, the problems of poor internationalization effect of network pages and the need for immediate dynamic content translation are solved, and efficient and flexible text translation is achieved.

CN119415198APending Publication Date: 2025-02-11MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411355665.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-25
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

In the prior art, the internationalization effect of network pages is poor, and it is impossible to cope with the need for immediate and flexible translation of frequently updated network applications and dynamically changing content.

Method used

By determining the text and its translation attribute information on the front-end page, selecting the appropriate interface from the pre-integrated multiple interfaces for text translation based on this information, realizing instant translation and flexible processing of text.

Benefits of technology

It improves the immediacy and efficiency of text translation in network pages, reduces the load on the back-end server, realizes a flexible translation mechanism that matches text attribute information, and improves the translation effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415198A_ABST
    Figure CN119415198A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a front-end page processing method and a related product. The front-end page processing method comprises the following steps: determining a text on a front-end page and translation attribute information of the text; determining a first interface from a plurality of interfaces according to the translation attribute information; the plurality of interfaces are pre-integrated in an application program corresponding to the front-end page, and the first interface is an interface with interface information matched with the translation attribute information; and calling the first interface to translate the text to obtain a text translation result of the text, and displaying the front-end page based on the text translation result. According to the method, the instantaneity, the accuracy and the flexibility of text translation in the front-end page are improved, and the instantaneity requirements of frequently updated network applications and dynamically changed contents on translation can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of language processing technology, and in particular to a front-end page processing method and related products. Background Art

[0002] Internationalization is the process of preparing, adjusting, and optimizing products and services at different levels, so that they can better adapt to the languages ​​of different regions without making engineering changes. As the pace of globalization accelerates, front-end applications need to support multiple languages ​​in order to provide a seamless and personalized experience for global users. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a front-end page processing method and related products to solve the technical problems in the prior art that the internationalization effect of web pages is poor, and that the web pages cannot cope with the frequent updates of network applications and the immediacy and flexibility requirements of translation for dynamically changing content.

[0004] To solve the above technical problems, the embodiments of the present application are implemented as follows: On the one hand, an embodiment of the present application provides a method for processing a front-end page, including: Determine the text on the front-end page, and translation attribute information of the text; According to the translation attribute information, a first interface is determined from a plurality of interfaces; the plurality of interfaces are pre-integrated in an application corresponding to the front-end page, and the first interface is an interface whose interface information matches the translation attribute information; The first interface is called to translate the text, a text translation result of the text is obtained, and the front-end page is displayed based on the text translation result.

[0005] On the other hand, an embodiment of the present application provides an electronic device, including a processor and a memory electrically connected to the processor, the memory storing a computer program, and the processor being used to call and execute the computer program from the memory to implement the above-mentioned front-end page processing method.

[0006] On the other hand, an embodiment of the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program can be executed by a processor to implement the above-mentioned front-end page processing method.

[0007] On the other hand, an embodiment of the present application provides a computer program product, including a computer program, and the computer program is executed by a processor to implement the above-mentioned front-end page processing method.

[0008] The technical solution of the embodiment of the present application is adopted, by determining the text on the front-end page and the translation attribute information of the text, and according to the translation attribute information, determining the first interface from multiple interfaces, and the multiple interfaces are pre-integrated in the application corresponding to the front-end page; then calling the first interface to translate the text, obtaining the text translation result of the text, and displaying the front-end page based on the text translation result. It can be seen that when the text changes on the front-end page (such as real-time changes in content such as user comments and real-time communication messages), the interface pre-integrated in the application corresponding to the front-end page can be used to achieve text translation without interacting with the back-end server, and the translation process does not depend on network conditions, which greatly improves the immediacy and efficiency of text translation in network pages. In addition, since the first interface is an interface whose interface information matches the translation attribute information of the text, implementing text translation through the first interface can make the translation mechanism adopted during text translation (including the interface for providing translation services) match the translation attribute information of the text, rather than all changed texts using a unified translation mechanism. For example, any text on the front-end page (whether static text or dynamically changing text) is translated using the same translation tool. Compared with this fixed translation mode, the technical solution of the present application greatly improves the flexibility and translation effect of text translation on web pages. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate one or more embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in one or more embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0010] Figure 1 is a schematic flow chart of a method for processing a front-end page according to an embodiment of the present application; Figure 2 is a schematic flow chart of a method for processing a front-end page according to another embodiment of the present application; Figure 3 is a schematic block diagram of a front-end page processing device according to an embodiment of the present application; Figure 4 It is a schematic block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0011] The embodiments of the present application provide a front-end page processing method and related products to solve the technical problems in the prior art of poor internationalization effect of web pages, inability to cope with frequently updated network applications and the immediacy and flexibility requirements of translation for dynamically changing content.

[0012] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.

[0013] In terms of application internationalization, related technologies use different internationalization methods for static text and dynamically changing text on the front-end page of an application. Static text refers to text content that remains unchanged on a page, such as text content written directly in an HTML (Hypertext Transfer Protocol) file. Dynamically changing text refers to text content that is generated when the application is running or dynamically obtained from a back-end server. Compared with static text, dynamically changing text may change according to user operations or other real-time data changes.

[0014] When internationalizing static text, front-end internationalization libraries are usually used to manage and apply translation resources. Developers need to prepare one or more resource files for each supported language, and the resource files need to contain all translation strings. In the front-end code, the translation strings are referenced through the API (Application Programming Interface) or components provided by the front-end internationalization library to achieve dynamic internationalization of the front-end page. The core idea of ​​front-end local internationalization is to extract all internationalizable texts (such as interface text, prompt messages, etc.) in the application and store them in different language files (usually in JSON format). In other words, during the application development process, all page texts are not directly hard-coded in the code, but exist in the form of identifiers and are mapped to specific translations in language files. These language files contain key-value pairs, where the key is the identifier of the text and the value is the translation of the corresponding language. When the application starts, the corresponding language file is dynamically loaded according to the user's language preference, and the corresponding text is displayed on the interface. This method supports runtime language switching, allowing users to select the preferred language when the application is running. The application dynamically loads the corresponding language file based on the user's selection and updates the page elements. However, this approach has certain limitations. For applications with frequently updated content, such as news portals and social platforms, each content update requires the simultaneous update of multilingual resource files, which not only increases the translation workload, but also increases the complexity of coordination and verification of translation accuracy. In the long run, it is a significant burden on team resources and time. Furthermore, as the number of languages ​​supported by the application increases, the number of language resource files that need to be loaded by the front end also increases accordingly, resulting in a longer initial loading time for the application, especially in environments with poor network conditions. It may also increase the bandwidth usage of the application, affecting the user's download speed.

[0015] When internationalizing dynamically changing text, it is usually implemented by the backend server. The server dynamically generates and provides content in the corresponding language based on the language preference requested by the client. Specifically, the server maintains a database or file of multilingual content, determines the user language preference based on the request header (such as 'Accept-Language') in the translation request sent by the frontend, retrieves the corresponding translation content from the database or file, and then returns the translation content to the frontend. In this method, the frontend is responsible for the display of the translated content, and the backend server is responsible for the internationalization of the content, which is conducive to the dynamic update and maintenance of the text content on the page and is suitable for applications with multilingual requirements. However, this backend real-time internationalization method also has certain limitations. First, all internationalization processing logic is completed on the server side, which means that the server needs to dynamically generate translated content for each translation request, which may have a significant impact on server performance when there are a large number of users or frequent requests, and increase response delays, especially when processing complex pages or large amounts of data. Second, because the translated content is generated on the server side and then transmitted to the client, the user experience is highly dependent on network conditions. When the network is unstable or slow, the page content display may have a significant delay, affecting the user's browsing experience. Thirdly, for scenarios that require immediate response to user operations on the client side for content internationalization, such as user input verification messages, instant feedback, etc., the backend processing may not be flexible and instant.

[0016] The front-end page processing method provided by the embodiment of the present application determines the text on the front-end page and the translation attribute information of the text, the translation attribute information includes at least one of the following: text type, text importance, translation urgency, translation accuracy expectation, user preference information; determines the first interface for translating the text according to the translation attribute information, and the first interface is pre-integrated in the application corresponding to the front-end page; then calls the first interface to translate the text, obtains the text translation result of the text, and displays the front-end page based on the text translation result. Among them, the first interface is an interface whose interface information matches the translation attribute information of the text.

[0017] It can be seen that when text changes occur on the front-end page (such as user comments, real-time communication messages, and other real-time changes), the text translation can be achieved using the interface pre-integrated in the application corresponding to the front-end page, without the need to interact with the back-end server, which greatly improves the immediacy of text translation in the web page. Especially when the page content changes frequently or the number of users using the front-end page is large, if translation requests are frequently sent to the server, it will have a significant impact on the server's performance, increase the server's response delay, and make it difficult to cope with the frequent updates of network applications and the immediacy of translation requirements for dynamically changing content.

[0018] Therefore, translating dynamically changing texts through an interface pre-integrated in the application not only reduces the load pressure on the back-end server, but the translation process is also independent of network conditions. That is, no matter when and where the text content is generated, it can be quickly captured and translated, thereby ensuring the instant effect of text translation on the web page.

[0019] In addition, the first interface is determined through the translation attribute information of the text, so that the text translation result can match at least one of the text type, text importance, translation urgency, translation accuracy expectation, and user preference information. Not all changed texts use a unified translation mechanism. For example, any text on the front-end page (whether static text or dynamically changing text) is translated using the same translation tool. Compared with this fixed translation mode, the technical solution of the present application greatly improves the flexibility and translation effect of text translation on web pages.

[0020] The front-end page processing method provided in the embodiment of the present application can be executed by an electronic device, or by software installed in the electronic device. Specifically, the electronic device can be a terminal device or a server device. Among them, the terminal device can include a smart phone, a laptop computer, a smart wearable device, a vehicle terminal, etc., and the server device can include an independent physical server, a server cluster composed of multiple servers, or a cloud server capable of cloud computing.

[0021] Figure 1 is a schematic flow chart of a method for processing a front-end page according to an embodiment of the present application, such as Figure 1 As shown, the front-end page processing method includes the following steps S102-S106: S102, determining the text on the front-end page and the translation attribute information of the text.

[0022] When executing this step, the text on the front-end page can be actively obtained, for example, whether there is text on the front-end page can be actively detected at a preset frequency (such as every 5 minutes), and when the text is detected on the front-end page, the text is obtained. Among them, "text on the front-end page" refers to the text on the front-end page that needs to be translated, which can be all or part of the text on the front-end page. The "text on the front-end page" mentioned in any of the following embodiments has the same meaning and will not be explained again.

[0023] Optionally, the text on the front-end page can also be passively acquired under certain triggering conditions, for example, when the front-end page is displayed for the first time, or when the text content on the front-end page changes, the application corresponding to the front-end application is triggered to acquire the text on the front-end page. If the acquisition is triggered when the front-end page is displayed for the first time, then the text on the front-end page is all the internationalizable text on the front-end page. If the acquisition is triggered when the text content on the front-end page changes, then the text on the front-end page is part or all of the changed text.

[0024] Optionally, the translation attribute information may include at least one of the following: text language type, text importance, translation urgency, translation accuracy expectation, and user preference information.

[0025] The text importance is used to characterize the importance of the text. The higher the text importance, the more important the text is and the higher the translation priority is. The translation urgency is used to characterize the urgency of the text translation. The higher the translation urgency, the more the text needs immediate translation and the higher the translation priority is. The expected translation accuracy is used to characterize the demand for translation accuracy of the text. The higher the expected translation accuracy, the higher the demand for translation accuracy of the text. User preference information refers to information that users can pre-set based on their own preferences for the front-end page, and may include at least one of the following: language type preference, page display language preference, translation accuracy preference, translation time preference, specific localization parameter preference, etc.

[0026] The translation accuracy and translation time can be set uniformly for all content on the front-end page, or can be set separately for different content. For example, the translation accuracy preference of the title and button on the front-end page can be set to 100%, and the translation time preference can be set to instant translation; the translation accuracy preference of the text content on the front-end page can be set to 80%, and the translation time preference can be set to delayed translation. If it is set to delayed translation, the specific delay time preference can be further set.

[0027] Optionally, when determining the text on the front page, the text type of the changed text can also be determined, and the text type includes static text or dynamically changed text. When determining the text type of the text on the front page, it can be determined according to the text attribute information of the text. The text attribute information includes at least one of the following: text position, text attribute identifier. The text position can be represented in the form of a specific content position or a coordinate position, and the specific content position is, for example, the title position on the front page, the text position, the label position of the page element, the button position, etc. The text attribute identifier includes an identifier for representing the text type. For example, if the text position of the text on the front page is the title position or the button position, etc., it can be determined that the text on the front page is static text; if the text position of the text on the front page is the text position, it can be determined that the text on the front page is dynamically changed text. The identifier used to represent the text type can be any identifier, for example, the identifier "1" is used to represent static text, and the identifier "2" is used to represent dynamically changed text.

[0028] S104, determining a first interface from a plurality of interfaces according to the translation attribute information, the plurality of interfaces being pre-integrated in an application corresponding to the front-end page, the first interface being an interface whose interface information matches the translation attribute information.

[0029] Optionally, multiple interfaces are pre-integrated in the application corresponding to the front-end page, and the interfaces can provide translation services for the text on the front-end page. The pre-integrated interfaces in the application can be understood as third-party services that can implement translation functions. By calling the pre-integrated interfaces in the application, the translation effect of the text on the front-end page can be achieved.

[0030] When determining the first interface, the interface information of multiple interfaces pre-integrated in the application can be determined first, and the interface information includes at least one of the following: the language type supported by the interface, the interface response speed, the translation accuracy, and the user evaluation information; and then, according to the interface information of the multiple interfaces, the first interface matching the translation attribute information is determined from the multiple interfaces. The interface response speed can be a fixed value or a dynamically changing value. For example, the interface response speed can be updated according to the user's feedback on the interface (such as comment information). The translation accuracy is similar to the interface response speed, and can also be updated according to the user's feedback on the interface (such as comment information). The user evaluation information may include the user's evaluation of one or more aspects of the interface, such as the evaluation of the interface response speed, the translation accuracy, etc.

[0031] Among them, the first interface matching the translation attribute information satisfies at least one of the following: the language type supported by the interface matches the text language type of the text, the interface response speed matches the translation urgency of the text, the translation accuracy of the interface matches the expected value of the translation accuracy of the text, the interface response speed and / or translation accuracy matches the text importance of the text, and the interface information matches the user preference information.

[0032] If the language type supported by the interface includes the text language type of the text, it is determined that the language type supported by the interface matches the text language type of the text.

[0033] Different translation urgency levels require different interface response speeds. The higher the translation urgency level, the faster the interface response speed is required. If the interface response speed is greater than or equal to the interface response speed required by the translation urgency level, it is determined that the interface response speed matches the translation urgency level of the text.

[0034] If the translation accuracy of the interface is higher than or equal to the expected value of the translation accuracy of the text, it is determined that the translation accuracy of the interface matches the expected value of the translation accuracy of the text.

[0035] The correspondence between text importance and interface response speed can be pre-configured. Based on this correspondence, if the interface response speed of the interface is greater than or equal to the interface response speed corresponding to the text importance of the text, it is determined that the interface response speed of the interface matches the text importance of the text.

[0036] The correspondence between text importance and translation accuracy can be pre-configured. Based on this correspondence, if the translation accuracy of the interface is higher than or equal to the translation accuracy corresponding to the text importance of the text, it is determined that the translation accuracy of the interface matches the text importance of the text.

[0037] As to whether the interface information matches the user preference information, various user preference information may be pre-configured, and then the corresponding interface information may be selected for comparison according to the configured user preference information. For example, if the user preference information includes a translation accuracy preference, the translation accuracy and the translation accuracy preference in the interface information may be selected for comparison, and if the translation accuracy of the interface is higher than or equal to the translation accuracy preference, it is determined that the interface information matches the user preference information.

[0038] For example, multiple interfaces are pre-integrated in the application, such as Google Cloud Translation, Microsoft Translator, or other third-party translation service interfaces, to cover as many language types as possible and ensure translation quality, so as to select the most appropriate interface for text translation based on the translation attribute information of the text. For example, for formal documents that require high-precision translation (i.e., higher translation accuracy expectations), it is preferred to use interfaces with higher precision (i.e., higher translation accuracy) for services; while for scenarios such as real-time chats that require higher response speed (i.e., higher translation urgency), it is possible to choose interfaces with faster responses for services.

[0039] Alternatively, outside determining the first interface, it is also possible to determine the translation time of text according to the translation attribute information of text. The translation time can comprise instant translation or delayed translation, and if the translation time is instant translation, the text obtained is translated instantly. If the translation time is delayed translation, then the text can be delayed according to the preset delay time, or after monitoring other change texts on the front page, the text that needs to be translated in other change texts can be translated together. For example, for the text of delayed translation, when the text quantity of the change text on the front page is monitored to reach the preset quantity threshold, the text of all needs to be translated of delayed translation can be translated together.

[0040] S106, calling the first interface to translate the text, obtaining a text translation result of the text, and displaying a front-end page based on the text translation result.

[0041] Among them, when the front-end page is displayed based on the text translation result, the display information of the text translation result can be determined according to the user preference information, and then the front-end interface is displayed according to the display information. The display information includes at least one of the following: display position, display method, and display time. The display position may include the position where the text is located or the position near the text (such as the upper side, the left side, the right side, etc.). If the display position is the position where the text is located, the text can be replaced by the text translation result. If the display position is the position near the text, the text and its text translation result can be displayed at the same time. The display method may include any of the following: only displaying the text translation result, displaying the text and its text translation result at the same time, displaying the trigger mark corresponding to the text and the text translation result at the same time, and displaying the text and the link of the text translation result at the same time. If the display method is to display the trigger mark corresponding to the text and the text translation result at the same time, when the user clicks the trigger mark corresponding to the text translation result, the text translation result is displayed to the user. If the display method is to display the text and the link of the text translation result at the same time, when the user clicks the link of the text translation result, the text translation result is displayed to the user. The display time may include any of the following: immediate display or delayed display. If the display time is immediate display, the text translation result will be displayed immediately according to the determined display method after it is obtained. If the display time is delayed display, it can be displayed according to the pre-set delay time.

[0042] Optionally, if the translation time of the text is determined according to the translation attribute information of the text, when executing step S106, the first interface can be called to translate the text when the current time meets the translation time. Wherein, whether the current time meets the translation time can be judged by the specific type of the translation time. If the translation time is instant translation, it is determined that the current time meets the translation time. If the translation time is delayed translation, the text is delayed translated according to the preset delay time. For example, if the delay time is 5 minutes, when 5 minutes arrives, it is determined that the current time meets the translation time.

[0043] The technical solution of the embodiment of the present application is adopted, by determining the text on the front-end page and the translation attribute information of the text, and according to the translation attribute information, determining the first interface from multiple interfaces, and the multiple interfaces are pre-integrated in the application corresponding to the front-end page; then calling the first interface to translate the text, obtaining the text translation result of the text, and displaying the front-end page based on the text translation result. It can be seen that when the text changes on the front-end page (such as real-time changes in content such as user comments and real-time communication messages), the interface pre-integrated in the application corresponding to the front-end page can be used to achieve text translation without interacting with the back-end server, and the translation process does not depend on network conditions, which greatly improves the immediacy of text translation in network pages. In addition, since the first interface is an interface whose interface information matches the translation attribute information of the text, text translation is achieved by calling the first interface, so that the translation mechanism adopted during text translation (including the interface for providing translation services) can match the translation attribute information of the text, rather than all changed texts using a unified translation mechanism. For example, any text on the front-end page (whether static text or dynamically changing text) is translated using the same translation tool. Compared with this fixed translation mode, the technical solution of the present application greatly improves the flexibility and translation effect of text translation on web pages.

[0044] In one embodiment, in response to monitoring the changed text on the front-end page, the text attribute information of the changed text is analyzed, and then according to the analysis result of the text attribute information, it is determined whether the changed text contains the text on the front-end page (i.e., the text that needs to be translated). In the case where it is determined that the changed text contains the text on the front-end page, the text on the front-end page is obtained. The text attribute information includes at least one of the following: text change type, text position, text attribute identifier, importance identifier information used to describe the importance of the text, and urgency identifier information used to describe the urgency of translation. Among them, the text change type refers to the specific type of change that occurs in the dynamically changed text, and may include at least one of the following types: text content posted by users, notifications generated by the system, etc. The text position can be represented in the form of a specific content location or a coordinate position, and the specific content location is, for example, the location of the title on the front-end page, the location of the text, the location of the label of the page element, the location of the button, etc. The text attribute identifier includes an identifier of whether translation is required.

[0045] When determining whether the changed text contains text that needs to be translated based on the text change type, you can pre-set which text change type corresponds to the changed text that needs to be translated. For example, if you set that the text content posted by the user needs to be translated, then when it is detected that the text content posted by the user on the front-end page has changed (such as added or modified), it is determined that the changed text contains text that needs to be translated, and the text content posted by the user belongs to the text that needs to be translated.

[0046] When determining whether the changed text contains text that needs to be translated based on the text position, it is possible to pre-set which text positions correspond to the changed content that needs to be translated. For example, it is set that the text at the title position needs to be translated, and when it is detected that the text at the title position on the front-end page has changed, it is determined that the changed text contains text that needs to be translated, and the text at the title position belongs to the text that needs to be translated.

[0047] When determining whether the changed text contains text that needs to be translated based on the text attribute identifier, the text attribute identifier corresponding to each changed text can be queried. If the text attribute identifier is a pre-set specific identifier, for example, the text attribute identifier is "class=translate", then the changed text corresponding to the text attribute identifier is determined to be the text that needs to be translated.

[0048] When determining whether the changed text contains text that needs to be translated based on the importance identification information used to describe the importance of the text, it can be pre-set which type of changed text corresponding to the importance identification information needs to be translated. For example, the importance identification information is represented by three levels: high, medium, and low, and the text content with the importance identification information of "high" and "medium" is pre-set to need to be translated. Then, when it is detected that the text content with the importance identification information of "high" and / or "medium" on the front-end page has changed, it is determined that the changed text contains text that needs to be translated, and the changed text content belongs to the text that needs to be translated.

[0049] When determining whether the changed text contains text that needs to be translated based on the urgency identification information used to describe the urgency of translation, it can be pre-set which type of changed text corresponding to the urgency identification information needs to be translated. For example, the urgency identification information is represented by "one", "two", and "three", and the translation urgency corresponding to the urgency identification information "one" is the highest, followed by two, and the translation urgency corresponding to the urgency identification information "three" is the lowest. In addition, it is pre-set that the text content with the urgency identification information of "one" and "two" needs to be translated, then when it is monitored that the text content with the urgency identification information of "one" and / or "two" on the front-end page has changed, it is determined that the changed text contains text that needs to be translated, and the changed text content belongs to the text that needs to be translated.

[0050] Optionally, when monitoring whether there is changed text on the front-end page, the DOM tree corresponding to the front-end page can be monitored in real time. When changes are detected in the DOM nodes in the DOM tree, including addition, deletion or attribute changes of DOM nodes, it is determined that there is changed text on the front-end page, and the text content corresponding to the changed DOM node is the changed text.

[0051] For example, using the MutationObserver interface (a monitoring interface) to accurately monitor changes in the DOM tree, first create a MutationObserver instance and provide it with a callback function. The callback function will be called when the monitored DOM tree changes, and is responsible for checking whether the changes in the DOM tree involve text content that needs to be translated. Here, preset rules or identification information can be used to assist in the check, such as specific CSS classes or data attributes. When it is determined that the changed text contains text that needs to be translated, the callback function triggers the translation process.

[0052] When a DOM node change is detected, the callback function of the MutationObserver interface is called and receives an array of all relevant change records. Each record object is used to describe a specific DOM tree change, including the text change type, the changed node (or text position), and the specific content of the changed text. These record objects are traversed in the callback function, and whether to trigger translation is determined based on the information recorded in the record object.

[0053] Optionally, the types of changes in the DOM tree that need to be monitored are pre-configured. For example, at least one of the following items is pre-configured for monitoring: the addition (such as content dynamically added to the front-end page) or deletion of DOM nodes, changes in text nodes in DOM nodes (such as updated text content), changes in element attribute identifiers, etc. Element attribute identifiers may include text attribute identifiers, translation attribute identifiers, etc. By pre-configuring the types of changes in the DOM tree that need to be monitored, rather than monitoring all DOM nodes in the DOM tree, not only can the changed text on the front-end page be effectively captured, but also resources will not be over-consumed, thereby avoiding the problem of poor display of the front-end page due to excessive resource consumption.

[0054] Although all DOM trees corresponding to the front-end page can be monitored, in some cases, monitoring specific elements can greatly improve monitoring efficiency. Therefore, in actual applications, a portion of the DOM tree can be selectively monitored based on the structure of the application and internationalization requirements. For example, if the dynamically updated text only appears in a specific text position, then only the text at the specific text position on the front-end page can be monitored. Specifically, only the DOM tree corresponding to the text at the specific text position can be monitored to improve monitoring efficiency and reduce unnecessary monitoring and processing processes.

[0055] For example, suppose we develop a social networking platform with multilingual support, which contains multiple types of text content, such as user-posted content, system-generated notifications, and static text. In order to achieve real-time internationalization of these text contents, we first define a set of simple and intuitive marking rules. For example, for all static text, such as navigation bar and footer information, we can add a specific class name to these elements in the HTML template, such as `class="translate". In this way, when the real-time DOM monitoring component of this system detects DOM changes in the page, it will scan all elements with the "translate" class name and automatically extract the text content in these elements as text to be translated, and carry out subsequent translation processes, such as generating translation requests and sending them to the interface. For dynamically changing content, such as user comments or real-time notifications, a more flexible marking method can be used, such as using HTML5 custom data attributes to identify which content is newly generated and needs to be translated. For example, you can add the attribute data-translate="true" to the container element of each user comment. In this way, not only can this attribute be added dynamically when the content is created, but the DOM monitoring component can also easily identify the newly added content through this identification information and then translate it.

[0056] In addition, when judging whether the changed text contains text that needs to be translated, it can also be determined based on user preference information, which includes user-defined text that needs to be translated and / or text that does not need to be translated. For example, if the user defines certain professional terms that do not need to be translated, when judging whether the changed text contains text that needs to be translated, it can be determined based on the user preference information that the specific professional terms in the changed text do not belong to the text that needs to be translated. This method can achieve the flexibility of dynamically changing the translation of text and avoid unnecessary translation processes.

[0057] In this embodiment, by monitoring the changed text on the front-end page, analyzing the text attribute information of the changed text, and judging whether the changed text contains text that needs to be translated based on the analysis result of the text attribute information, the text that needs to be translated is obtained when it is determined that the changed text contains text that needs to be translated. Not only can it respond to changes in page content in real time, but also can capture content updates triggered by user interaction or new content dynamically generated by application logic in real time, and translate the text that needs to be translated, thereby ensuring that the front-end page always maintains the latest international status, providing users with a smooth and seamless multilingual experience.

[0058] In one embodiment, the translation attribute information includes the importance of the text, and the text attribute information includes importance identification information used to describe the importance of the text. When determining the translation attribute information of the text, the following steps A1-A3 may be performed: Step A1, obtaining importance identification information for describing the importance of the text according to the text attribute information of the text.

[0059] In the text attribute information, the importance identification information may be represented by a specific attribute of a DOM node, such as a specific attribute "data-priority" or "data-importance".

[0060] Step A2, determining the text importance level of the text according to the importance level identification information and the preset corresponding relationship between the text importance level and the importance level identification information.

[0061] Step A3, determining the text importance of the text according to the text importance level of the text.

[0062] The representation method of the text importance level is not limited. For example, the text importance level can be represented by numbers 0 to 10. The larger the number, the higher the text importance level. For another example, multiple levels such as high, medium, and low are used to represent the text importance level.

[0063] Optionally, the importance of the text may be directly represented by the text importance level. For example, the text importance level is divided into high, medium and low levels, which means that the corresponding text importance levels are high, medium and low.

[0064] Optionally, a correspondence between the text importance level and the text importance degree can be preset, and then the text importance degree can be determined according to the correspondence. For example, the text importance level is divided into multiple levels such as 1, 2, and 3. In the correspondence between the text importance level and the text importance degree, the text importance degree corresponding to the text importance level "1" is high, the text importance degree corresponding to the text importance level "2" is medium, and the text importance degree corresponding to the text importance level "3" is low; and so on.

[0065] In one embodiment, after determining the text importance level of the text, the importance identification information and the text importance level can be comprehensively analyzed, so as to determine the text importance of the text according to the analysis results. Optionally, respective weights are set in advance for the importance identification information and the text importance level, and then the text importance is determined according to the importance identification information, the text importance level and the respective corresponding weights. The text importance can be characterized by a variety of methods such as scores and levels. Taking the score as an example, when determining the text importance, the determination method is to calculate the text importance score.

[0066] When calculating the text importance score, optionally, the importance identification information and the text importance level are converted into corresponding numerical forms, respectively, wherein the importance identification information is converted into the corresponding importance value, and the text importance level is converted into the corresponding text importance level value. The correspondence between the importance identification information and the importance value, and the correspondence between the text importance level and the text importance level value can be preset. For example, the importance identification information is "data-priority", which means that the text needs to be processed first, and the corresponding importance value is 10; the importance identification information is "data-importance", which means that the text is of high importance, and the corresponding importance value is 8; and so on. The calculation method of the text importance score P can be represented by the following formula: P=a*P1+b*P2 Among them, P1 represents the importance value corresponding to the importance identification information, P2 represents the text importance level value, a represents the weight corresponding to the importance identification information (or importance value), and b represents the weight corresponding to the text importance level (or text importance level value).

[0067] In this embodiment, the text importance of the text is determined by importance identification information and text importance level, and then the interface used to translate the text is determined according to the text importance, so that the interface providing translation services for the text can be flexibly adjusted according to the importance of the text, rather than all texts using a unified interface for translation, thereby improving the flexibility of text translation.

[0068] In one embodiment, the translation attribute information includes translation urgency, and the text attribute information includes urgency identification information for describing the translation urgency. When determining the translation attribute information of the text, the following steps B1-B3 may be performed: Step B1, acquiring urgency identification information for describing the urgency of translation according to text attribute information of the text.

[0069] In the text attribute information, the urgency identification information may be represented by a specific attribute of the DOM node, such as a specific attribute "data-urgency" or "data-deadline".

[0070] Step B2: determining the translation urgency level of the text according to the urgency identification information and the preset correspondence between the translation urgency level and the urgency identification information.

[0071] Step B3, determining the translation urgency of the text according to the translation urgency level of the text.

[0072] The representation method of the translation urgency level is not limited. For example, the translation urgency level can be represented by numbers 0 to 10. The larger the number, the higher the translation urgency. For another example, multiple levels such as high, medium, and low are used to represent the translation urgency level.

[0073] Optionally, the translation urgency level may be directly used to represent the translation urgency. For example, the translation urgency level is divided into high, medium and low levels, which means that the corresponding translation urgency levels are high, medium and low.

[0074] Optionally, a correspondence between the translation urgency level and the translation urgency degree may be preset, and then the translation urgency degree may be determined based on the correspondence. For example, the translation urgency level is divided into multiple levels such as 1, 2, and 3. In the correspondence between the translation urgency level and the translation urgency degree, the translation urgency level "1" corresponds to a high translation urgency degree, the translation urgency level "2" corresponds to a medium translation urgency degree, and the translation urgency level "3" corresponds to a low translation urgency degree; and so on.

[0075] In one embodiment, after determining the translation urgency level of the text, the urgency identification information and the translation urgency level can be comprehensively analyzed, so as to determine the translation urgency of the text according to the analysis results. Optionally, respective weights are set in advance for the urgency identification information and the translation urgency level, and then the translation urgency is determined according to the urgency identification information, the translation urgency level and the respective weights. The translation urgency can be characterized by a variety of methods such as scores and levels. Taking the score as an example, when determining the translation urgency, the determination method is to calculate the translation urgency score.

[0076] When calculating the translation urgency score, optionally, the urgency identification information and the translation urgency level are respectively converted into corresponding numerical forms, wherein the urgency identification information is converted into the corresponding urgency value, and the translation urgency level is converted into the corresponding translation urgency level value. The correspondence between the urgency identification information and the urgency value, and the correspondence between the translation urgency level and the translation urgency level value can be preset. For example, the urgency identification information is "data-urgency", which means that the translation demand is very urgent, and the corresponding urgency value is 10; the urgency identification information is "data-deadline", which means that the translation demand is not very urgent, that is, it can be delayed, and the corresponding urgency value is 6; and so on. The calculation method of the translation urgency score K can be represented by the following formula: K=c*K1+d*K2 Among them, K1 represents the urgency value corresponding to the urgency identification information, K2 represents the translation urgency level value, c represents the weight corresponding to the urgency identification information (or urgency value), and d represents the weight corresponding to the translation urgency level (or translation urgency level value).

[0077] In this embodiment, the translation urgency of the text is determined by the urgency identification information and the translation urgency level, and then the interface for providing translation services for the text is determined according to the translation urgency, so that the interface for providing translation services for the text can be flexibly adjusted according to the translation urgency of the text, rather than all texts using a unified interface to achieve translation, thereby improving the flexibility of text translation.

[0078] In one embodiment, when calling the first interface to translate the text, a first translation request corresponding to the text may be generated first, and then the first translation request may be sent to the first interface, where the first translation request is used to request the first interface to translate the text. When generating the first translation request, the first translation request matching the first interface may be generated according to the rule requirements of the first interface for the request.

[0079] Wherein, the first translation request includes the text to be translated. If the first interface only supports one translation language type, the first translation request may not include the translation language type corresponding to the text. If the first interface supports multiple translation language types, the first translation request includes not only the text but also the translation language type corresponding to the text. The first translation request is used for the first interface to translate the text according to the translation language type. In addition, the first translation request may also include formatting requirements for the translation, etc.

[0080] In the case where the translation strategy includes the translation time, if the translation time is immediate translation, a first translation request is immediately generated, and the first translation request is sent to the first interface for translation. If the translation time is delayed translation, the first translation request may not be generated first, and the first translation request may be generated when the delay time arrives, or the first translation request may be generated immediately, and the first translation request may be sent to the first interface when the delay time arrives.

[0081] Optionally, the first translation request includes multiple, for example, when the content is changed on the front-end page, the changed content includes multiple texts, and at this time, a respective first translation request is generated for each text, and multiple first translation requests are obtained. Based on this, before sending the first translation request to the first interface, in response to multiple first translation requests, the similarity of the texts included in the multiple first translation requests is determined. In the case where the similarity reaches a preset similarity threshold, multiple first translation requests whose text similarity reaches the preset similarity threshold can be merged into one first translation request. For first translation requests with exactly the same text, one of the first translation requests can be sent to the first interface at will, and the other first translation requests can be deleted. For multiple first translation requests with different texts but similarity reaching a preset similarity threshold, one of the first translation requests can be selected according to a preset screening method and sent to the first interface, and the other first translation requests can be deleted. The preset screening method includes any of the following: random screening method, selecting the first translation request corresponding to the text with the least text content, selecting the first translation request corresponding to the text with the highest sentence fluency, selecting the first translation request corresponding to the text with the number of punctuation marks not exceeding the maximum value (such as 5); and so on.

[0082] When sending the multiple first translation requests to the first interface, in order to avoid blocking other interactions on the front-end page, the multiple first translation requests may be sent in an asynchronous manner.

[0083] In this embodiment, by merging translation requests corresponding to texts with the same or similar text content, the number of calls to the first interface can be reduced, and the translation workload of the first interface can be reduced, thereby improving the translation efficiency of dynamically changing texts on the front-end page.

[0084] In one embodiment, after determining the translation attribute information of the text, if it is determined according to the translation attribute information that the expected value of the translation accuracy of the text is higher than or equal to a preset threshold value, and / or the text language type of the text belongs to a preset type of text, a second translation request corresponding to the text is generated, and the second translation request is sent to a server located on the network side. Wherein, the second translation request includes the text to be translated and the translation language type, and the second translation request is used by the server to translate the text according to the translation language type and return the translation result. The server located on the network side may also be referred to as a back-end server.

[0085] Preset type texts are usually texts that require high translation accuracy or high security, such as database query results, real-time generated reports, texts that require customized translation engines to translate, texts that require manual proofreading, texts involving sensitive content, etc.

[0086] Since the translation tools maintained by the backend server are more numerous, more comprehensive, and more secure, the translation of texts with high translation accuracy requirements (such as expected translation accuracy greater than or equal to the preset threshold) or high security through the backend server is more accurate and efficient. For example, if the text includes professional terms, the backend server can provide stronger translation capabilities to translate the professional terms. For another example, if the text involves sensitive content, the backend server can ensure the high security of the text during the translation process. Through this hybrid translation mode (i.e., a combination of front-end translation and back-end translation), when processing different types of text, the most appropriate translation mode can be selected according to needs, thereby optimizing the translation results and user experience.

[0087] In one embodiment, after calling the first interface to translate the text and obtaining the text translation result of the text, user feedback information on the text translation result can be received, and at least one of the following optimizations can be performed based on the feedback information: modifying the translation method of the text by the first interface, modifying the text translation result, and replacing the first interface.

[0088] In terms of receiving feedback information, a mechanism that facilitates users to provide feedback information can be pre-integrated into the application, which can provide an entry for inputting feedback information on the front-end page, such as a "Feedback" button. In this way, whether it is an evaluation of the overall translation effect or a suggestion for a specific translation paragraph, the user can input feedback information by clicking the "Feedback" button on the front-end page, or view other users' feedback information by clicking the "Feedback" button on the front-end page.

[0089] After receiving the feedback information, the feedback information can be summarized and analyzed to identify common translation problems, user-preferred translation styles, etc., so as to adjust the translation algorithm, optimize the translation model, and even directly correct specific translation errors based on the analysis results.

[0090] In addition, after optimizing the translation strategy, an optimization notification may be sent to the user to inform the user that the feedback information provided by the user has been processed and the optimization measures taken, thereby improving the user experience and facilitating the optimization of the translation mechanism.

[0091] Figure 2 is a schematic flow chart of a method for processing a front-end page according to another embodiment of the present application, such as Figure 2 As shown, the front-end page processing method is applied to an electronic device and may include the following steps S201-S209: S201, obtain the text on the front page and determine the text type of the text. If the text type is static text, execute step S202; if the text type is dynamically changing text, execute step S204.

[0092] The text on the front-end page refers to the text that needs to be translated on the front-end page. Static text refers to the text content that remains unchanged on the page, such as the text content written directly in the HTML file. When the front-end page is displayed for the first time, all the text on the front-end page that supports internationalization can be determined as the text that needs to be translated.

[0093] Dynamically changing text refers to text content that is generated when the application is running or dynamically obtained from the backend server, such as text content that changes due to user interaction actions (such as clicks, input, etc.) and text content that is dynamically updated by the application itself.

[0094] When determining the text type of a text, it can be determined based on the text attribute information of the text. The text attribute information includes at least one of the following: text position, text attribute identifier. The text position can be represented in the form of a specific content position or a coordinate position. The specific content position is, for example, the title position on the front page, the text position, the label position of the page element, the button position, etc. The text attribute identifier includes an identifier for representing the text type. For example, if the text position of the text is the title position or the button position, etc., it can be determined that the text is static text; if the text position of the text is the text position, it can be determined that the text is dynamically changing text. The identifier used to represent the text type can be any identifier, for example, the identifier "1" is used to represent static text, and the identifier "2" is used to represent dynamically changing text.

[0095] S202: Determine the translation language type of the text.

[0096] Among them, the electronic device can intelligently determine the translation language type of the text, for example, according to the location information of the current location, determine the common language of the current location as the translation language type; for another example, determine the translation language type according to the language preference in the user preference information. Alternatively, the translation language type can be selected by the user, for example, after the front-end page is displayed, the user selects the target language to be translated through the language selection button on the front-end page, and the electronic device determines the target language selected by the user as the translation language type.

[0097] S203, determining the text translation result corresponding to the text according to the language file matching the translation language type in the front-end internationalization library, and then jumping to step S208.

[0098] The front-end internationalization library stores language files corresponding to a plurality of translation language types, and each language file includes text translation results corresponding to each static content and matching the translation language type.

[0099] S204, determining the text importance, translation urgency and user preference information of the text.

[0100] Among them, the text importance is used to characterize the importance of the text. The higher the text importance, the more important the text is, and the higher the translation priority is. The translation urgency is used to characterize the translation urgency of the text. The higher the translation urgency, the more the text needs immediate translation, and the higher the translation priority is. User preference information refers to information that the user can pre-set according to his or her own preferences for the front-end page, and may include at least one of the following: language type preference, page display language preference, translation accuracy preference, translation time preference, specific localization parameter (such as date and time format preference) preference, etc. The method for determining the text importance and translation urgency has been described in detail in the above embodiments and will not be repeated here.

[0101] The user preference information can be pre-configured by the user, and the application provides the user with an entry for configuring the user preference information. After the user inputs the user preference information, the application stores the user preference information in the front end.

[0102] In this step, the text importance, translation urgency and user preference information are only part of the translation attribute information. In practical applications, it is possible to flexibly configure the determination of part or all of the translation attribute information of the text, and to perform subsequent processes based on the determined part or all of the translation attribute information.

[0103] S205 , selecting a first interface for translating the text and a translation time of the text from a plurality of interfaces according to the text importance, translation urgency and user preference information of the text.

[0104] Among them, multiple interfaces are pre-integrated in the application corresponding to the front-end page. The translation time may include instant translation or delayed translation. If the translation time is instant translation, the acquired text is translated instantly. If the translation time is delayed translation, the text can be delayed translated according to the preset delay time, or it can be translated together with the text in other changed texts after monitoring other changed texts on the front-end page. For example, for delayed translated texts, when the number of texts of the changed texts on the front-end page is monitored to reach a preset number threshold, all delayed translated texts are translated together.

[0105] Optionally, the first interface and translation time can be determined based on user preference information. For example, the user preference information includes: the preferred language is Class A language, all dynamically changed content is translated in real time, and the translation accuracy is 80%. Then, the translation language type can be directly determined as Class A language, the translation time is real-time translation, and the first interface is the interface with a translation accuracy of 80% based on the user preference information.

[0106] If the first interface and translation time cannot be accurately determined based on the user preference information, the first interface and translation time can be further determined in combination with the importance of the text and the urgency of the translation. For example, for texts with high importance and high urgency of translation, the translation process will be triggered immediately, the first interface will be called for real-time translation, and the text translation results will be fed back to the user as soon as possible. For content with lower priority (such as texts with lower importance and lower urgency of translation), a strategy of delayed translation can be adopted, or the translation can be started after a direct request from the user, thereby optimizing resource allocation and application performance.

[0107] S206: Generate a translation request corresponding to the text according to the translation time, and send the translation request to the first interface.

[0108] The first interface translates the text according to the translation request to obtain a text translation result.

[0109] S207: Obtain the text translation result returned by the first interface.

[0110] S208, displaying a front-end page based on the text translation result.

[0111] Among them, the display information of the text translation result can be determined according to the user preference information, and then the front-end interface can be displayed according to the display information. The display information includes at least one of the following: display location, display method, and display time. The display location may include the location of the text or the vicinity of the text (such as the top, left, right, etc.). If the display location is the location of the text, the text can be replaced by the text translation result. If the display location is the vicinity of the text, the text and its text translation result can be displayed at the same time. The display method may include any of the following: only displaying the text translation result, displaying the text and its text translation result at the same time, displaying the trigger identifiers corresponding to the text and the text translation result at the same time, and displaying the text and the link to the text translation result at the same time.

[0112] S209, receiving user feedback on the text translation result, and optimizing the translation mechanism according to the feedback information.

[0113] Among them, optimizing the translation mechanism may include at least one of the following: modifying the translation method of the first interface to the text, modifying the text translation result, and replacing the first interface.

[0114] It can be seen that in this embodiment, the translation strategy (including the first interface and translation time) of the text can be comprehensively determined in combination with the text importance, translation urgency and user preference information of the text, which can not only ensure the accuracy of the translation result, but also make the translation result meet the user preference. At the same time, the display mode of the text translation result is determined based on the user preference information, so that the text translation result and the front-end page can be presented to the user in a seamless and natural way as much as possible, for example, by showing it to the user through a smooth animation effect, or showing a link or trigger mark of the text translation result next to the text, thereby providing a smooth and personalized translation result display mode. And it can flexibly and efficiently process various types of texts in the front-end page, whether it is static text or dynamically changing text, it can achieve accurate international translation, which greatly improves the globalization level of the application.

[0115] In addition, by providing users with a configuration entry for user preference information, users are supported to customize the multilingual experience according to their personal preferences, including page language, preferred date and time format, currency display method, etc. User preference information is stored in the front end and applied to the front end translation mechanism to ensure that users can get a consistent personalized experience every time they visit the front end page. In addition, by providing users with a feedback mechanism, users can trigger the system to continuously optimize the translation mechanism based on their own language preferences, the way the translation results are displayed, and their evaluation and feedback on the translation results, forming an interactive and self-improving ecosystem.

[0116] In summary, specific embodiments of the present subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recorded in the claims can be performed in a different order and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing can be advantageous.

[0117] The above is a front-end page processing method provided in an embodiment of the present application. Based on the same idea, an embodiment of the present application also provides a front-end page processing device.

[0118] Figure 3 is a schematic block diagram of a front-end page processing device according to an embodiment of the present application, such as Figure 3 As shown, the processing device of the front-end page includes: A first determination module 31 is used to determine the text on the front-end page and the translation attribute information of the text; A second determination module 32 is used to determine a first interface from a plurality of interfaces according to the translation attribute information; the plurality of interfaces are pre-integrated in the application corresponding to the front-end page, and the first interface is an interface whose interface information matches the translation attribute information; The translation module 33 is used to call the first interface to translate the text, obtain a text translation result of the text, and display the front-end page based on the text translation result.

[0119] In one embodiment, the translation attribute information includes at least one of the following: text language type, translation urgency, translation accuracy expectation, text importance, and user preference information; When the second determination module 32 determines the first interface from the multiple interfaces according to the translation attribute information, the second determination module 32 performs the following steps: Determine interface information of the multiple interfaces; the interface information includes at least one of the following: the type of translation language supported by the interface, the interface response speed, and the translation accuracy; According to the interface information, an interface that satisfies at least one of the following items with the translation attribute information is determined as the first interface from among the multiple interfaces: the language type supported by the interface matches the language type of the text, the interface response speed matches the translation urgency, the translation accuracy matches the expected translation accuracy, the interface response speed and / or the translation accuracy matches the importance of the text, and the interface information matches the user preference information.

[0120] In one embodiment, the translation attribute information includes text importance; When determining the text on the front-end page and the translation attribute information of the text, the first determination module 31 performs the following steps: According to the text attribute information of the text, obtaining importance identification information for describing the importance of the text; the text attribute information includes the importance identification information; Determining the text importance level of the text according to the importance level identification information and the correspondence between the preset text importance level and the importance level identification information; The importance of the text is determined according to the text importance level of the text.

[0121] In one embodiment, the translation attribute information includes translation urgency; When determining the text on the front-end page and the translation attribute information of the text, the first determination module 31 performs the following steps: According to the text attribute information of the text, acquiring urgency identification information for describing the urgency of the translation; the text attribute information includes the urgency identification information; Determining the translation urgency level of the text according to the urgency identification information and the correspondence between the preset translation urgency level and the urgency identification information; The translation urgency level is determined according to the translation urgency level of the text.

[0122] In one embodiment, when the translation module 33 calls the first interface to translate the text, the translation module 33 performs the following steps: Generating a first translation request corresponding to the text; the first translation request includes the text and a translation language type; The first translation request is sent to the first interface; the first translation request is used by the first interface to translate the text according to the translation language type.

[0123] In one embodiment, the apparatus further comprises: A merging module is used to determine the similarity of the texts included in the multiple first translation requests in response to the multiple first translation requests before sending the first translation request to the first interface; if the similarity reaches a preset similarity threshold, merge the multiple first translation requests into one first translation request.

[0124] In one embodiment, the apparatus further comprises: A generating module, configured to generate a second translation request corresponding to the text after determining the text on the front-end page and the translation attribute information of the text, if it is determined according to the translation attribute information that the expected value of the translation accuracy of the text is higher than or equal to a preset threshold value and / or the text language type of the text belongs to a preset type of text; the second translation request includes the text and the translation language type; The sending module is used to send the second translation request to a server located on the network side; the second translation request is used by the server to translate the text according to the translation language type and return the translation result.

[0125] The device of the embodiment of the present application is used to determine the text on the front-end page and the translation attribute information of the text, and determine the first interface from multiple interfaces according to the translation attribute information, and the multiple interfaces are pre-integrated in the application corresponding to the front-end page; then the first interface is called to translate the text, and the text translation result of the text is obtained, and the front-end page is displayed based on the text translation result. It can be seen that when the text changes on the front-end page (such as real-time changes in content such as user comments and real-time communication messages), the interface pre-integrated in the application corresponding to the front-end page can be used to achieve text translation without interacting with the back-end server, and the translation process does not depend on network conditions, which greatly improves the immediacy of text translation in network pages. In addition, since the first interface is an interface whose interface information matches the translation attribute information of the text, the translation of the text is achieved by calling the first interface, so that the translation mechanism adopted when translating the text (including the interface for providing translation services) can match the translation attribute information of the text, rather than all changed texts using a unified translation mechanism. For example, any text on the front-end page (whether static text or dynamically changing text) is translated using the same translation tool. Compared with this fixed translation mode, the present application greatly improves the flexibility and translation effect of text translation on web pages.

[0126] Those skilled in the art should understand that Figure 3 The front-end page processing device in can be used to implement the front-end page processing method described above, and the detailed description thereof should be similar to the description of the method part above. To avoid tediousness, it will not be repeated here.

[0127] Based on the same idea, the embodiment of the present application also provides an electronic device, such as Figure 4 As shown. The electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors 401 and memory 402, and the memory 402 may store one or more storage applications or data. Among them, the memory 402 may be a temporary storage or a permanent storage. The application stored in the memory 402 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the electronic device. Furthermore, the processor 401 can be configured to communicate with the memory 402 to execute a series of computer executable instructions in the memory 402 on the electronic device. The electronic device may also include one or more power supplies 403, one or more wired or wireless network interfaces 404, one or more input and output interfaces 405, and one or more keyboards 406.

[0128] Specifically in this embodiment, the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions for the electronic device, and the one or more programs are configured to be executed by one or more processors, including the following computer executable instructions: Determine the text on the front-end page, and translation attribute information of the text; According to the translation attribute information, a first interface is determined from a plurality of interfaces; the plurality of interfaces are pre-integrated in an application corresponding to the front-end page, and the first interface is an interface whose interface information matches the translation attribute information; The first interface is called to translate the text, a text translation result of the text is obtained, and the front-end page is displayed based on the text translation result.

[0129] The technical solution of the embodiment of the present application is adopted, by determining the text on the front-end page and the translation attribute information of the text, and according to the translation attribute information, determining the first interface from multiple interfaces, and the multiple interfaces are pre-integrated in the application corresponding to the front-end page; then calling the first interface to translate the text, obtaining the text translation result of the text, and displaying the front-end page based on the text translation result. It can be seen that when the text changes on the front-end page (such as real-time changes in content such as user comments and real-time communication messages), the text translation can be realized by using the interface pre-integrated in the application corresponding to the front-end page, without the need to interact with the back-end server, and the translation process does not depend on network conditions, which greatly improves the immediacy of text translation in network pages. In addition, since the first interface is an interface whose interface information matches the translation attribute information of the text, the translation of the text is achieved by calling the first interface, so that the translation mechanism adopted when translating the text (including the interface for providing translation services) can match the translation attribute information of the text, rather than all changed texts using a unified translation mechanism. For example, any text on the front-end page (whether static text or dynamically changing text) is translated using the same translation tool. Compared with this fixed translation mode, the present application greatly improves the flexibility and translation effect of text translation on web pages.

[0130] The embodiment of the present application further proposes a computer-readable storage medium, which stores one or more computer programs, and the one or more computer programs include instructions. When the instructions are executed by an electronic device including multiple application programs, the electronic device can execute each process of the embodiment of the front-end page processing method, and is specifically used to execute: Determine the text on the front-end page, and translation attribute information of the text; According to the translation attribute information, a first interface is determined from a plurality of interfaces; the plurality of interfaces are pre-integrated in an application corresponding to the front-end page, and the first interface is an interface whose interface information matches the translation attribute information; The first interface is called to translate the text, a text translation result of the text is obtained, and the front-end page is displayed based on the text translation result.

[0131] The technical solution of the embodiment of the present application is adopted, by determining the text on the front-end page and the translation attribute information of the text, and according to the translation attribute information, determining the first interface from multiple interfaces, and the multiple interfaces are pre-integrated in the application corresponding to the front-end page; then calling the first interface to translate the text, obtaining the text translation result of the text, and displaying the front-end page based on the text translation result. It can be seen that when the text changes on the front-end page (such as real-time changes in content such as user comments and real-time communication messages), the text translation can be realized by using the interface pre-integrated in the application corresponding to the front-end page, without the need to interact with the back-end server, and the translation process does not depend on network conditions, which greatly improves the immediacy of text translation in network pages. In addition, since the first interface is an interface whose interface information matches the translation attribute information of the text, the translation of the text is achieved by calling the first interface, so that the translation mechanism adopted when translating the text (including the interface for providing translation services) can match the translation attribute information of the text, rather than all changed texts using a unified translation mechanism. For example, any text on the front-end page (whether static text or dynamically changing text) is translated using the same translation tool. Compared with this fixed translation mode, the present application greatly improves the flexibility and translation effect of text translation on web pages.

[0132] An embodiment of the present application provides a computer program product, including a computer program, which is executed by a processor to implement the various processes of the above-mentioned front-end page processing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0133] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0134] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0135] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0136] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0137] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0138] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0139] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0140] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0141] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0142] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0143] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0144] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0145] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A method for processing a front-end page, characterized in that: include: Determine the text on the front-end page, and translation attribute information of the text; According to the translation attribute information, determining a first interface from a plurality of interfaces, the plurality of interfaces being pre-integrated in an application corresponding to the front-end page, the first interface being an interface whose interface information matches the translation attribute information; The first interface is called to translate the text, a text translation result of the text is obtained, and the front-end page is displayed based on the text translation result.

2. The method according to claim 1, characterized in that: The translation attribute information includes at least one of the following: text language type, translation urgency, translation accuracy expectation, text importance, and user preference information; and determining the first interface from a plurality of interfaces according to the translation attribute information includes: Determine interface information of the multiple interfaces; the interface information includes at least one of the following: language type supported by the interface, interface response speed, and translation accuracy; According to the interface information, an interface that satisfies at least one of the following items with the translation attribute information is determined as the first interface from among the multiple interfaces: the language type supported by the interface matches the language type of the text, the interface response speed matches the translation urgency, the translation accuracy matches the expected translation accuracy, the interface response speed and / or the translation accuracy matches the importance of the text, and the interface information matches the user preference information.

3. The method according to claim 1, characterized in that The translation attribute information includes the importance of the text; the text on the front-end page is determined, and the translation attribute information of the text includes: According to the text attribute information of the text, obtaining importance identification information for describing the importance of the text; the text attribute information includes the importance identification information; Determining the text importance level of the text according to the importance level identification information and the correspondence between the preset text importance level and the importance level identification information; The importance of the text is determined according to the text importance level of the text.

4. The method according to claim 1, characterized in that: The translation attribute information includes translation urgency; The determining of the text on the front-end page and the translation attribute information of the text includes: According to the text attribute information of the text, acquiring urgency identification information for describing the urgency of the translation; the text attribute information includes the urgency identification information; Determining the translation urgency level of the text according to the urgency identification information and the correspondence between the preset translation urgency level and the urgency identification information; The translation urgency level is determined according to the translation urgency level of the text.

5. The method according to claim 1, characterized in that The calling the first interface to translate the text includes: Generating a first translation request corresponding to the text; the first translation request includes the text and a translation language type; The first translation request is sent to the first interface; the first translation request is used by the first interface to translate the text according to the translation language type.

6. The method according to claim 5, characterized in that Before sending the first translation request to the first interface, the method further includes: In response to a plurality of first translation requests, determining similarities of texts included in the plurality of first translation requests; When the similarity reaches a preset similarity threshold, the multiple first translation requests are merged into one first translation request.

7. The method according to claim 1, characterized in that After determining the text on the front-end page and the translation attribute information of the text, the method further includes: If it is determined according to the translation attribute information that the expected value of the translation accuracy of the text is higher than or equal to a preset threshold, and / or the text language type of the text belongs to a preset type of text, generating a second translation request corresponding to the text; the second translation request includes the text and the translation language type; The second translation request is sent to a server located on the network side; the second translation request is used by the server to translate the text according to the translation language type and return the translation result.

8. An electronic device, characterized in that: It comprises a processor and a memory electrically connected to the processor, the memory stores a computer program, and the processor is used to call and execute the computer program from the memory to implement the front-end page processing method as described in any one of claims 1-7.

9. A computer-readable storage medium, characterized in that: The storage medium is used to store a computer program, and the computer program can be executed by a processor to implement the front-end page processing method as described in any one of claims 1-7.

10. A computer program product, characterized in that It includes a computer program, which is executed by a processor to implement the front-end page processing method as described in any one of claims 1-7.