Page translation method and device, electronic equipment and readable storage medium

By obtaining and translating text data from the rendering tree of the display module, the development and maintenance challenges of multilingual compatibility for electronic devices are solved, enabling fast and stable page translation, reducing workload and maintenance difficulty.

CN120996054APending Publication Date: 2025-11-21AUTEL INTELLIGENT TECHNOLOGY CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511078460.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-01
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

In existing technologies, when electronic devices are compatible with multiple languages, the workload of page development is large and the difficulty of later maintenance is high, especially given the diverse language requirements of users around the world, making development and maintenance complex.

Method used

By retrieving text data from the drawing tree of the display module and storing it in a data table, and then using a translation tool to translate it, the text attributes in the drawing information are updated, thus achieving page translation without directly modifying the content of the application module.

Benefits of technology

It reduces the workload of page development, lowers the difficulty of later maintenance, avoids the risk of anomalies caused by modifying application modules, and improves the speed and stability of page translation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120996054A_ABST
    Figure CN120996054A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of translation, and discloses a page translation method, a page translation device, electronic equipment and a computer readable storage medium, the method is applied to the electronic equipment, the electronic equipment comprises an application program module, a translation management module and a display module, and the method comprises the following steps: responding to a translation instruction; the method comprises the following steps: acquiring a drawing tree from a display module through a translation management module, acquiring text data from the drawing tree, storing the text data into a data table, translating the text data, storing the translated text data into the data table, acquiring drawing information sent to the display module by an application program module, and searching the data table to acquire translated text data corresponding to the drawing information; and the drawing information is updated according to the translated text data, and the updated target drawing information is sent to the display module, so that the display module displays the translated page view. By means of the mode, the application program module can be compatible with multiple languages, and the workload of page development is effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of translation technology, specifically to a page translation method, a page translation device, an electronic device, and a computer-readable storage medium. Background Technology

[0002] With the development of economic globalization, more and more products are being sold globally. Due to the diversity of languages ​​used by users around the world, products usually need to be compatible with multiple languages ​​to meet the needs of users worldwide, especially products such as mobile phones, tablets, and smart home devices.

[0003] Currently, electronic devices are mainly compatible with multiple languages ​​by developing corresponding pages for different languages. However, when the number of languages ​​that an electronic device needs to be compatible with is large, developers need to develop corresponding pages for each language during the page development stage, which results in a large workload for page development and greater difficulty in later maintenance. Summary of the Invention

[0004] In view of the above problems, embodiments of this application provide a page translation method, a page translation device, an electronic device, and a computer-readable storage medium to solve the problems of large workload in page development and high difficulty in later maintenance in the prior art.

[0005] According to a first aspect of the embodiments of this application, a page translation method is provided, applied to an electronic device. The electronic device includes an application module, a translation management module, and a display module. The method includes: responding to a translation instruction, obtaining a drawing tree of the current page view from the display module through the translation management module; traversing the drawing tree to obtain text data included in the current page view and storing the text data in a preset data table; translating the text data by calling a translation tool through the translation management module to obtain translated text data corresponding to the text data and storing it in the preset data table; obtaining drawing information of the current page view sent by the application module to the display module, wherein the drawing information includes text attributes; searching the data table according to the content corresponding to the text attributes in the drawing information to obtain the translated text data corresponding to the content of the text attributes in the drawing information, thereby obtaining target translated text data corresponding to the drawing information; updating the text attributes of the drawing information according to the target translated text data to obtain target drawing information; and sending the target drawing information to the display module so that the display module redraws and displays the translated page view according to the target drawing information.

[0006] In one alternative approach, the translation management module invokes a translation tool to translate the text data, obtaining the translated text data corresponding to the original text data. Specifically, this includes: obtaining the language type used by the electronic device to obtain the target language type; and invoking the translation tool to translate the text data according to the target language type to obtain the translated text data corresponding to the original text data.

[0007] In one alternative approach, the text data is stored in a preset data table, specifically including: searching the preset data table based on the text data; if the text data does not exist in the data table, then storing the text data in the data table.

[0008] In one optional approach, there are multiple pieces of drawing information. The process involves searching a data table based on the content corresponding to the text attributes in the drawing information to obtain the translated text data corresponding to the text attributes, thus obtaining the target translated text data corresponding to the drawing information. Specifically, this includes: traversing the text data in the data table and performing the following steps for each piece of text data in the data table: comparing the text data in the data table with the content corresponding to the text attributes in each piece of drawing information; if the text data in the data table is the same as the content corresponding to the text attributes in the drawing information, then the translated text data corresponding to the text data in the data table is determined as the target translated text data corresponding to the drawing information.

[0009] In one optional approach, the translation management module calls a translation tool to translate the text data, obtaining translated text data corresponding to the original text data, and storing it in a preset data table. Specifically, this includes: marking the text data in the data table, generating tag information corresponding to the text data, and storing it in the data table; calling the translation tool to translate the text data according to the tag information, generating translated text data corresponding to the tag information; and storing the translated text data in the data table according to the tag information.

[0010] In an optional embodiment, after sending the target drawing information to the display module, the method further includes: in response to a restore command, obtaining the target drawing information from the display module; searching a data table based on the content of the text attributes in the target drawing information to obtain the text data corresponding to the content of the text attributes in the target drawing information, thereby obtaining target text data; updating the target drawing information based on the target text data; and sending the updated target drawing information to the display module so that the display module redraws and displays the restored page view based on the updated target drawing information.

[0011] In an optional embodiment, the method further includes: in response to a translation function activation command, acquiring a translation button and its location information, wherein the translation button is used to activate the translation command; drawing a target view by a display module based on the translation button and its location information; and overlaying the target view onto the current page view to display the translation button on the current page view.

[0012] In an alternative approach, the method further includes: hiding the target view in response to a translation function shutdown command.

[0013] In one alternative approach, after translating the text data by calling the translation tool through the translation management module to obtain the translated text data corresponding to the text data, the method further includes: if the translated text data corresponding to the text data is empty, then prompting that there is no text data to be translated in the current page view.

[0014] In one alternative approach, the drawing tree is traversed to obtain the text data included in the current page view. Specifically, this includes: traversing the drawing tree to obtain all leaf nodes in the drawing tree; and extracting text from the leaf nodes to obtain the text data included in the current page view.

[0015] According to a second aspect of the embodiments of this application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the page translation method described in any of the preceding claims.

[0016] According to a third aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the page translation method described in any of the preceding claims.

[0017] This application embodiment acquires and translates text data, then updates the rendering information using the corresponding translated text data. This allows the display module to redraw and display the translated page view based on the updated rendering information. This enables the application module to be compatible with multiple languages. Compared to developing pages for multiple languages ​​to achieve application module compatibility, this effectively reduces the workload of page development and lowers the difficulty of subsequent maintenance. Furthermore, page updates are achieved by updating rendering information, without requiring modification of the application module's content, effectively avoiding the risk of anomalies due to modifications to the application module's content. In addition, the text data is obtained from the display device's rendering tree. Compared to directly obtaining text data from the rendering information, the rendering tree only contains the content displayed in the current page view. By traversing the content (e.g., text, images, etc.) in the rendering tree, all text data displayed in the current page view can be quickly obtained, effectively accelerating the text data acquisition speed and thus speeding up page translation.

[0018] The above description is merely an overview of the technical solutions of the embodiments of this application. In order to better understand the technical means of the embodiments of this application and to implement them in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the embodiments of this application more obvious and understandable, specific implementation methods of this application are described below. Attached Figure Description

[0019] The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0020] Figure 1 A schematic diagram of the structure of the electronic device provided in the embodiment of this application is shown.

[0021] Figure 2 A flowchart illustrating the page translation method provided in the first embodiment of this application is shown;

[0022] Figure 3 A schematic diagram of the structure of a page view according to an embodiment of this application is shown;

[0023] Figure 4 A flowchart illustrating the page translation method provided in the second embodiment of this application is shown;

[0024] Figure 5 A flowchart illustrating the page translation method provided in the third embodiment of this application is shown;

[0025] Figure 6 A schematic diagram of the structure of the page translation device provided in an embodiment of this application is shown. Detailed Implementation

[0026] Exemplary embodiments of the present application will now be described in more detail with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be implemented in various forms and should not be limited to the embodiments set forth herein.

[0027] Taking automotive diagnostic equipment as an example, during the development of diagnostic pages on such equipment, multilingual support is required to meet the needs of users in different countries. In existing technologies, this is typically achieved by adding business logic for multiple language types to the program corresponding to the diagnostic page, or by developing separate language-specific pages for each language type. This allows the automotive diagnostic equipment to call the corresponding program to generate the page based on the user's selected language, thus displaying the text content on the diagnostic equipment in the user's chosen language.

[0028] While existing methods allow automotive diagnostic equipment to be compatible with multiple languages ​​to meet the needs of users worldwide, the sheer number of languages ​​means that if business logic is added to the corresponding program for each language, the program will contain multiple business logic lines. Furthermore, only the text attributes will be displayed in different language types, while other content will be largely the same, resulting in complex programs and significantly increasing the difficulty of later maintenance. Developing separate pages for each language would require developers to create multiple pages, with only the text displayed in different language types. This not only increases the workload of page development but also necessitates updating each language's corresponding page when the content is updated, making later maintenance extremely difficult.

[0029] Therefore, to reduce the workload of page development and lower the difficulty of later maintenance, this application provides a page translation method. This application first obtains text data from the rendering tree of the display module and stores it in a data table. Then, it translates the text data in the data table. Finally, it replaces the text attribute content in the rendering information sent by the application module to the display module with the translated text, thereby achieving page translation. By obtaining text data from the rendering tree of the display module for translation, modifications to the application itself can be avoided. When the user's selected language changes, the application itself does not need any changes; it only needs to obtain the text data from the rendering tree of the display module and call the corresponding translation tool for translation. The translation tool can translate the displayed content into any content according to the user's selection. Therefore, the page translation method proposed in this application is more applicable, and page development does not require generating programs corresponding to multiple languages, effectively reducing the workload of page development while satisfying the diversity of users' habitual languages.

[0030] Furthermore, the text data on the page is obtained from the rendering tree of the display module, and the updating of the text data on the page is achieved by updating the rendering information sent to the display device by the application module. The entire page translation process does not directly interact with or modify the application corresponding to the page. While ensuring that the display device can render the translated page normally, it does not need to modify the application corresponding to the page, avoiding the risk of page abnormalities due to application modification and improving page stability.

[0031] According to a first aspect of the embodiments of this application, a page translation method is provided. This method is executed by an electronic device, which may be a smart home device, a mobile phone, a tablet, or the like. Specifically, as... Figure 1 As shown, Figure 1 The diagram illustrates the structure of an electronic device provided in an embodiment of this application. Specific embodiments of this application do not limit the specific implementation of the electronic device. The electronic device 1 may include a processor 11 and a memory 12.

[0032] The memory 12 is used to store the computer program 13. The memory 22 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device. The computer program 13 may include computer-executable instructions.

[0033] The processor 11 is used to execute the computer program 13 to implement the above-described page translation method embodiment.

[0034] Processor 11 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application. Electronic device 1 may include one or more processors of the same type, such as one or more CPUs; or it may include processors of different types, such as one or more CPUs and one or more ASICs.

[0035] Electronic devices also include application modules and display modules. Application modules are computer programs designed on electronic devices to complete specific tasks. Specifically, they can be application software downloaded by the user via the network or system software on the electronic device.

[0036] When an application module needs to display its corresponding page view, it generates drawing information corresponding to the page view and sends this drawing information to the display module. The display module then shows the page view corresponding to the application module to the user. This drawing information is used to cache the page content and interaction logic within the application module. It is typically stored as view objects and includes not only the content currently displayed in the page view but also content that is only displayed in specific scenarios.

[0037] The display module is a component on an electronic device used to display the page view, such as a display panel connected to the electronic device. When the display module receives drawing information sent by the application module, it generates a drawing tree corresponding to the page view based on the drawing information, and then draws the page view based on the drawing tree, thus displaying the corresponding page view on the display panel. The drawing tree is the data used by the display module to draw the final page view. Buttons that are only displayed in certain specific scenarios are added to the drawing tree only when those specific scenarios occur. Furthermore, the drawing tree only stores the content displayed in the page view, such as control position information, text and images within the controls, and control types. The interaction logic for interactive controls such as buttons, drop-down menus, and input boxes is not stored in the drawing tree but is stored in the application module.

[0038] Taking a video capture page as an example, the information in the page view typically needs to include a start button to start video recording, a stop button to stop video recording, and confirm and cancel buttons for the user to confirm whether to stop video recording. The data corresponding to these buttons are stored in the rendering information, including but not limited to button position information, text and images within the buttons, and the content of the corresponding interaction logic.

[0039] However, in the preview screen, the current page view only displays the Start button. The Stop recording button only appears in the page view after the user clicks the Start button. Similarly, the Confirm and Cancel buttons only appear in the page view via pop-ups or other means after the user clicks the Stop recording button. Therefore, before the user clicks the Start button, the drawing tree only stores the data corresponding to the Start button. Only when the user clicks the Start button and causes a change in the page view will the drawing tree store the data corresponding to the Stop recording button. Furthermore, the drawing tree only stores button position information, text, and images within the buttons; the content of the button's interaction logic is not stored in the drawing tree.

[0040] To enable the translation of page views on electronic devices, the devices also include a translation management module for page translation. This translation management module and the application module can be two functional modules within the same application software; that is, the translation management module can be a function within the application software or a plugin integrated into it. Alternatively, the translation management module can be a standalone translation software, meaning the translation management module and the application module are two independent software programs on the electronic device.

[0041] Specifically, the translation management module translates the page view currently displayed on the electronic device by executing the page translation method proposed in the embodiments of this application. The following embodiments will provide a detailed description of this page translation method. Specifically, as... Figure 2 As shown, Figure 2 A flowchart of a page translation method provided in the first embodiment of this application is shown. The method includes the following steps:

[0042] Step S100: In response to the translation instruction, obtain the drawing tree of the current page view from the display module through the translation management module.

[0043] The current page view is the page view currently displayed by the display module. It typically displays text, images, and other content. Users can obtain the information they need through the text and images displayed in the page view. Figure 3 Taking the automotive diagnostic equipment shown as an example, Figure 3 The diagram shows the structure of the page view. Users can determine which type of vehicle a control is associated with by the text data displayed on the page view. For example, when a user needs to diagnose a fault in an Audi vehicle, they can click on the control with the text data "Audi" on the page view to jump to the diagnostic interface corresponding to the Audi vehicle type, thereby diagnosing the fault in the Audi vehicle.

[0044] The translation command is used to open the translation management module. Users can open the translation management module by clicking the translation button displayed on the page view, and then translate the current page view through the translation management module. Figure 3 Taking the shown view interface as an example, the language used in the current page view is English. If the user cannot understand the content displayed in the current page view because they do not know English, they need to use the translation management module to translate the text data in the current page view into a language that the user can understand.

[0045] The translation button can be controlled by enabling or disabling the translation function. When a user needs to translate the page, the translation function is enabled, and the translation button is displayed on the currently shown view. The user can then click the button to activate the translation command, allowing the translation management module to translate the currently displayed view. During page development, the translation button can be directly integrated into the page content and placed within the corresponding logic, or it can be displayed as a floating window.

[0046] Specifically, in order to reduce the workload of page development, the translation button can be displayed through the following steps (steps S001 to S003):

[0047] Step S001: In response to the translation function activation command, obtain the translation button and its location information, wherein the translation button is used to activate the translation command.

[0048] Step S002: Draw the target view using the display module based on the translation button and its position information.

[0049] Step S003: Overlay the target view onto the current page view to display the translation button on the current page view.

[0050] The translation function activation command is used to activate the translation function on the electronic device. When the translation function is activated, the user can activate the translation command by clicking the translation button displayed on the display module, thereby translating the current page view through the translation management module.

[0051] The target view is used to display the translation button. The target view is overlaid on the current page view (i.e., the view interface corresponding to the application module). Regardless of what the display module is currently displaying, the translation button can be displayed on the view interface corresponding to the application module through the target view.

[0052] In steps S001 to S003, the translation button is displayed on top of the view interface corresponding to the application module through the target view. Even if the view interface corresponding to the application module displayed by the display module changes, the translation button can continue to be displayed on the view interface corresponding to the application module through the target view. There is no need to add the logic program corresponding to the translation button in each view interface corresponding to the application module, which reduces the development workload of the page view.

[0053] Furthermore, to facilitate user operation, the method also includes the following steps:

[0054] Step S004: In response to the translation function closing command, hide the target view.

[0055] The "Translation Function Off" command disables the page translation function on electronic devices, preventing accidental changes to the displayed page due to user accidental presses of the translation button. When the user no longer needs the translation function, they can hide the target view using the "Translation Function Off" command, thus concealing the translation button.

[0056] In addition, the display of the translation button also has a prompt function to indicate whether the current electronic device has the page translation function enabled. If the current page view has a translation button, the user can directly click the translation button to translate the current page view. If the current page view does not have a translation button, the user needs to enable the translation function first so that the translation button can be displayed on the current page view through the target view before the user can translate the current page view by clicking the translation button.

[0057] After step S100, step S200 is executed: traverse the drawing tree, obtain the text data included in the current page view, and store the text data in a preset data table.

[0058] The drawing tree is the data used by the display module to draw the current page view. It stores only the content displayed in the current page view, typically including text and images. Furthermore, the drawing tree is not part of the application module's business logic; any operation performed on it will not alter the application module's business logic. The electronic device's data retrieval via the drawing tree will not affect the application module's business logic. This avoids unforeseen anomalies caused by modifying the application module's business logic when retrieving text data from the current page view.

[0059] Electronic devices can retrieve all content displayed in the current page view by traversing the rendering tree. However, content not displayed in the current page view (including but not limited to text, images, and interactive logic) stored in the application module will not appear in the rendering tree. For the translation process of the current page view, the rendering tree allows for the quick and accurate retrieval of the text data that needs to be translated.

[0060] Specifically, the acquisition of text data may include the following steps (steps S210 to S220):

[0061] Step S210: Traverse the drawing tree and obtain all leaf nodes in the drawing tree.

[0062] Step S220: Extract text from leaf nodes to obtain the text data included in the current page view.

[0063] The process involves traversing the child nodes layer by layer from the root node of the drawing tree. When a node no longer has any child nodes, it is considered a leaf node of the drawing tree. The content of the leaf node is the content displayed at the top level of the current page view, which is the content that the user can see on the current page view. By extracting the text from the leaf node, the text data included in the current page view can be obtained.

[0064] Steps S210 to S220 can accurately and quickly extract the text data included in the current page view from the drawing tree.

[0065] The preset data table is the storage medium within the translation management module used to store text data and its corresponding translated text data. The data table can be a blank data table created by the translation management module in response to translation instructions, or it can be a data table pre-set within the translation management module. When storing text data in the data table, all text data obtained from the drawing tree can be directly stored in the data table to ensure the integrity of the text data.

[0066] After step S200, step S300 is executed: the translation management module calls the translation tool to translate the text data, obtains the translated text data corresponding to the text data, and stores it in a preset data table.

[0067] The translation tool can be a translation function within the translation management module. For example, when the translation management module is translation software on an electronic device, it can call its own translation function to translate text data. Alternatively, the translation tool can be a translation plugin provided by third-party software, which can be called through a translation interface to translate text data.

[0068] The language of the translated text data can be selected by the user according to their needs. Alternatively, a default language can be preset and set directly when the translation tool is invoked. As an example, the common language of the electronic device's sales location can be set as the default language. If the electronic device is sold in "China," the default language would be set to "Chinese"; if it is sold in "the United Kingdom," the default language would be set to "English," and so on.

[0069] In addition, to ensure that the text data and the translated text data correspond accurately, step S300 may include the following steps (steps S310 to S330):

[0070] Step S310: Mark the text data in the data table, generate the corresponding tag information for the text data, and store it in the data table.

[0071] Step S320: Call the translation tool to translate the text data according to the tag information and generate translated text data corresponding to the tag information.

[0072] Step S330: Store the translated text data in the data table according to the tag information.

[0073] When storing text data in a data table, the translation management module can generate corresponding labels for each piece of text data and encapsulate it in the form of "label: text data". The text data is then input into the translation tool for translation, and the translated content is also encapsulated in the form of "label: translated text data" and returned to the translation management module.

[0074] As an example, suppose a data table stores text data in English, such as "Audi", "Ford", "FAW Audi", and "JEEP". If this text data needs to be translated into Chinese, the data in the table can be encapsulated as "1: Audi; 2: Ford; 3: FAW Audi; 4: JEEP;". The translated text data obtained by the translation management module through the translation tool is then encapsulated as "1: Audi; 2: Ford; 3: FAW Audi; 4: Jeep;". Finally, the translation management module stores the translated text data in the data table according to the labels, so that the text data and the translated text data correspond to each other through the labels.

[0075] Through steps S310 to S330, the text data and translated text data are marked with labels, so that after the translation management module obtains the translated text data, it can accurately store the translated text data and the corresponding text data in the data table, thereby ensuring the accuracy of subsequent translation of the current page view.

[0076] After step S300, step S400 is executed: obtain the drawing information of the current page view sent by the application module to the display module, wherein the drawing information includes text attributes.

[0077] The rendering information is used to cache page content and interaction logic within the application module. The application module sends this rendering information to the display module, which then generates a rendering tree based on the page content in the rendering information and renders the page view based on the rendering tree. This allows the display module to present the corresponding view interface of the application module to the user. Furthermore, the rendering information is sent from the application module to the display module and is not part of the application module's business logic. Modifying the rendering information will not change the application module's business logic. Therefore, modifying the rendering information by the electronic device will not affect the business logic within the application module. This avoids unforeseen anomalies caused by altering the application module's business logic when implementing page translation by modifying the rendering information.

[0078] The drawing information includes text attributes. The content of the text attributes is the text displayed on the view page corresponding to the application module. When the display module generates a drawing tree based on the drawing information, the content of the text attributes in the drawing information is the text data of each node in the drawing tree. In other words, the text data obtained by the translation management module through the drawing tree is the content of the text attributes in the drawing information.

[0079] Step S500: Search the data table according to the content corresponding to the text attributes in the drawing information, obtain the translated text data corresponding to the content of the text attributes in the drawing information, and obtain the target translated text data corresponding to the drawing information.

[0080] The electronic device updates the text attributes in the drawing information by obtaining translated text data from the data table, so that the text data of each node in the drawing tree generated by the display module based on the drawing information is replaced with translated text data, thereby realizing page translation.

[0081] Specifically, the electronic device can retrieve text data one by one from the data table and compare the text data with the content of the text attributes in the drawing information. When the text data matches the content of the text attributes in the drawing information, the translated text data corresponding to that text data is determined as the translated text data corresponding to the content of the text attributes in the drawing information (i.e., the target translated text data). Alternatively, the electronic device can use the content of the text attributes in the drawing information as a search condition for the data table, comparing the content of the text attributes in the drawing information with the text data in the data table one by one. When the content of the text attributes in the drawing information matches the text data in the data table, the translated text data corresponding to that text data is determined as the target translated text data.

[0082] Step S600: Update the text attributes of the drawing information according to the target translated text data to obtain the target drawing information.

[0083] Step S700: Send the target drawing information to the display module so that the display module can redraw and display the translated page view based on the target drawing information.

[0084] Specifically, the content corresponding to the text attributes in the drawing information is replaced with the target translated text data to generate target drawing information. This allows the display module to generate a new drawing tree based on the target drawing information, and the text data in the new drawing tree is the target translated text data. Consequently, the page view finally displayed by the display module is the translated page view, thus completing the translation of the page view.

[0085] In the above embodiments, by acquiring and translating text data, and then updating the rendering information using the corresponding translated text data, the display module redraws and displays the translated page view based on the updated rendering information. This allows the application module to be compatible with multiple languages. Compared to achieving application module compatibility by developing pages for multiple languages, this effectively reduces the workload of page development and lowers the difficulty of subsequent maintenance. Moreover, page updates are achieved by updating rendering information, without requiring modification of the application module's content, effectively avoiding the risk of anomalies due to modifications to the application module's content. Furthermore, the text data is obtained from the rendering tree of the display device. Compared to directly obtaining text data from the rendering information, the characteristic that the rendering tree only contains the content displayed in the current page view can be utilized. By traversing the content (e.g., text, images, etc.) in the rendering tree, all text data displayed in the current page view can be quickly obtained from the rendering tree, effectively accelerating the text data acquisition speed and thus speeding up the page translation.

[0086] Furthermore, to facilitate user operation, in some embodiments, such as Figure 4 As shown, Figure 4 A flowchart of the page translation method provided in the second embodiment of this application is shown. Step S300 may specifically include the following steps:

[0087] Step S321: Obtain the language type used by the electronic device to obtain the target language type.

[0088] Step S322: Call the translation tool to translate the text data according to the target language type to obtain the translated text data corresponding to the original text data.

[0089] When using the translation function, users usually translate unfamiliar languages ​​into familiar ones. Therefore, when selecting the target language type, users usually choose their idiomatic language (idiomatic language refers to the language that a person uses most naturally and familiarly in daily life, work, or specific scenarios). The language used on electronic devices (i.e., the language set by the settings module in the electronic device) is usually the user's idiomatic language.

[0090] Therefore, when users need to translate a webpage, the translation management module can directly use the language of the electronic device as the target language, automatically translating the text data into a language the user is familiar with, without requiring the user to select a target language. Furthermore, compared to using the language commonly used in the electronic device's country of sale as the target language, using the language of the electronic device itself as the target language results in a more user-friendly translation with higher accuracy.

[0091] When a page contains multiple controls, the drawing information corresponding to each control usually also includes multiple controls. For some special pages, there may be controls with the same text content. To speed up translation, when storing text data in a data table, the text data obtained from the drawing tree can be deduplicated before being stored in the data table. This avoids translating the same text data multiple times and improves translation efficiency. Specifically, storing text data in a preset data table may include the following steps (steps S230 to S240):

[0092] Step S230: Search the preset data table based on the text data.

[0093] Step S240: If the text data does not exist in the data table, then store the text data in the data table.

[0094] If identical text data already exists in the data table, it means that the text data is already stored in the data table and does not need to be stored again to prevent duplicate content. If identical text data does not exist in the data table, it means that the text data has not yet been stored in the data table and needs to be stored to ensure that the data table contains all text data in the current page view and ensures data integrity.

[0095] The resulting data table not only stores all the text data corresponding to the current page view, but also avoids translating the same text data multiple times, thus effectively improving translation efficiency.

[0096] Furthermore, to ensure that the translated text data corresponding to the deduplicated text data can also accurately translate all text data on the page, step S500 may include the following steps:

[0097] Iterate through the text data in the data table, and perform the following steps for each piece of text data in the data table:

[0098] Step S510: Compare the text data in the data table with the content corresponding to the text attributes in each drawing information.

[0099] Step S520: If the text data in the data table is the same as the content corresponding to the text attribute in the drawing information, then the translated text data corresponding to the text data in the data table is determined as the target translated text data corresponding to the drawing information.

[0100] The rendering information includes various attributes, such as text, image, and video. Each attribute corresponds to the data displayed on the page of the application module, including the text, images, and videos. The page translation function only needs to translate the text on the page. Therefore, during page translation, the text data is compared with the text attribute content in the rendering information. If the text data and text attribute content are the same, the translated text data corresponding to the text data is determined as the translated text data corresponding to the text attribute content (i.e., the target translated text data), and the text attribute content in the rendering information is replaced with the target translated text data.

[0101] Furthermore, when replacing the content of text attributes in the drawing information, each text data in the data table needs to be compared one by one with the content of text attributes in all the drawing information. Specifically, a text data is first retrieved from the data table, and this text data is compared one by one with the content of text attributes in each drawing information. If the text data is the same as the content of the text attribute in the drawing information, the corresponding translated text data is determined as the target translated text data for the drawing information. The drawing information is then updated based on the translated text data corresponding to this text data. Only after the text data has been compared with the content of text attributes in all the drawing information is a new text data retrieved from the data table again, ensuring that the content of text attributes in each drawing information can be replaced with the corresponding translated text data.

[0102] Furthermore, to improve the practicality of the page translation method, in some embodiments, such as Figure 5 As shown, Figure 5 A flowchart of a page translation method provided in the third embodiment of this application is shown. After step S700, the method includes the following steps:

[0103] Step S810: In response to the restore command, obtain target drawing information from the display module.

[0104] Step S820: Search the data table based on the content of the text attributes in the target drawing information, obtain the text data corresponding to the content of the text attributes in the target drawing information, and obtain the target text data.

[0105] Step S830: Update the target drawing information based on the target text data.

[0106] Step S840: Send the updated target drawing information to the display module so that the display module can redraw and display the restored page view based on the updated target drawing information.

[0107] The data table stores text data and translated text data in a one-to-one correspondence. When searching the data table, not only can the corresponding translated text data be retrieved from the original text data, but the corresponding text data can also be retrieved from the translated text data. Therefore, when the page translation is complete and the user needs to restore the page, they can search the data table based on the content of the text attributes in the target rendering information (i.e., the target translated text data), retrieve the target text data corresponding to the target rendering information from the data table, update the content of the text attributes in the target rendering information to the corresponding target text data, and then the display module can draw the restored page view based on the updated target rendering information.

[0108] Through steps S810 to S840, the user can update the content of the text attributes in the target drawing information using the restore command, thereby restoring the content of the text attributes in the target drawing information to the original text data. This will restore the translated page view displayed by the display module to the page view before translation, effectively improving the practicality of the page translation method.

[0109] Furthermore, to improve the user experience of the page translation function, in some embodiments, after step S300, the method further includes the following steps:

[0110] Step S900: If the translated text data corresponding to the text data is empty, then prompt that there is no translated text data in the current page view.

[0111] If the current page view contains no text content or the text content is an image, it means there is no content to be translated. The translation management module receives empty text data from the display module, and the translation tool also obtains empty translated text data. Regardless of how the user activates the translation command, the current page view displayed by the display module will not change. In this case, the electronic device can notify the user through pop-ups or other means that there is no text data to be translated in the current page view, preventing the user from repeatedly activating the translation command due to the unchanged page view, thus affecting the user experience.

[0112] According to a second aspect of the embodiments of this application, a page translation apparatus is provided, such as... Figure 6 As shown, Figure 6 A schematic diagram of the structure of the page translation device provided in this application embodiment is shown. The page translation device 2 includes an application module 21, a display module 22, and a translation management module 23.

[0113] Application module 21 sends the drawing information of the current page view to display module 22, whereby the drawing information includes text attributes. Display module 22 receives the drawing information sent by application module 21, generates a drawing tree of the current page view based on the drawing information, and draws and displays the current page view based on the drawing tree. Translation management module 23, in response to translation instructions, obtains the drawing tree from display module 22, traverses the drawing tree, obtains the text data included in the current page view, and stores the text data in a preset data table. Translation management module 23 also calls a translation tool to translate the text data, obtains the translated text data corresponding to the text data, and stores it in a preset data table. Translation management module 23 also obtains the drawing information, searches the data table based on the content corresponding to the text attributes in the drawing information, obtains the translated text data corresponding to the content of the text attributes in the drawing information, and obtains the target translated text data corresponding to the drawing information. Translation management module 23 also updates the text attributes of the drawing information based on the target translated text data, obtains the target drawing information, and sends the target drawing information to display module 22. The display module 22 is also used to receive target drawing information sent by the translation management module 23, and redraw and display the translated page view according to the target drawing information.

[0114] In the above embodiments, by acquiring and translating text data, and then updating the rendering information using the corresponding translated text data, the display module redraws and displays the translated page view based on the updated rendering information. This allows the application module to be compatible with multiple languages. Compared to achieving application module compatibility by developing pages for multiple languages, this effectively reduces the workload of page development and lowers the difficulty of subsequent maintenance. Moreover, page updates are achieved by updating rendering information, without requiring modification of the application module's content, effectively avoiding the risk of anomalies due to modifications to the application module's content. Furthermore, the text data is obtained from the rendering tree of the display device. Compared to directly obtaining text data from the rendering information, the characteristic that the rendering tree only contains the content displayed in the current page view can be utilized. By traversing the content (e.g., text, images, etc.) in the rendering tree, all text data displayed in the current page view can be quickly obtained from the rendering tree, effectively accelerating the text data acquisition speed and thus speeding up the page translation.

[0115] This application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the page translation method described above.

[0116] This application provides a computer program that can be executed by a processor to implement the above-described page translation method embodiments.

[0117] This application provides a computer program product, which includes a computer program that, when executed by a processor, implements the page translation method described above.

[0118] In the several embodiments provided in this application, any function, if implemented as a software functional module / unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, part or all of the technical solutions of this application can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or other electronic device) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing computer program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0119] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, the embodiments of this application are not directed to any particular programming language. It should be understood that the content of this application described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of this application.

[0120] It should be noted that the above embodiments are illustrative of this application and not restrictive, and those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. This application can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In claims enumerating several means, several units or modules of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be construed as limiting the order of execution.

[0121] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A page translation method, characterized in that, Applied to an electronic device, the electronic device including an application module, a translation management module, and a display module, the method includes: In response to a translation command, the translation management module obtains the drawing tree of the current page view from the display module; Traverse the drawing tree to obtain the text data included in the current page view, and store the text data in a preset data table; The translation management module calls a translation tool to translate the text data, obtains the translated text data corresponding to the text data, and stores it in the preset data table; Obtain the drawing information of the current page view sent by the application module to the display module, wherein the drawing information includes text attributes; The data table is searched based on the content corresponding to the text attributes in the drawing information to obtain the translated text data corresponding to the content of the text attributes in the drawing information, and the target translated text data corresponding to the drawing information is obtained. The text attributes of the drawing information are updated based on the target translated text data to obtain the target drawing information; The target drawing information is sent to the display module so that the display module can redraw and display the translated page view based on the target drawing information.

2. The page translation method according to claim 1, characterized in that, The translation management module invokes a translation tool to translate the text data, obtaining translated text data corresponding to the original text data, specifically including: Obtain the language type used by the electronic device to obtain the target language type; The translation tool is invoked to translate the text data according to the target language type, thereby obtaining the translated text data corresponding to the text data.

3. The page translation method according to claim 1, characterized in that, The step of storing the text data in a preset data table specifically includes: The preset data table is searched based on the text data; If the text data does not exist in the data table, then the text data will be stored in the data table.

4. The page translation method according to claim 3, characterized in that, The drawing information is multiple; The step of searching the data table based on the content corresponding to the text attributes in the drawing information to obtain the translated text data corresponding to the content of the text attributes in the drawing information, and obtaining the target translated text data corresponding to the drawing information, specifically includes: Iterate through the text data in the data table, and perform the following steps for each piece of text data in the data table: The text data in the data table is compared with the content corresponding to the text attributes in each of the drawing information; If the text data in the data table is the same as the content corresponding to the text attribute in the drawing information, then the translated text data corresponding to the text data in the data table is determined as the target translated text data corresponding to the drawing information.

5. The page translation method according to claim 1, characterized in that, The translation management module invokes a translation tool to translate the text data, obtaining the translated text data corresponding to the original text data, and stores it in a preset data table, specifically including: The text data in the data table is marked to generate tag information corresponding to the text data, and stored in the data table; The translation tool is invoked to translate the text data based on the tag information, generating translated text data corresponding to the tag information; The translated text data is stored in the data table based on the tag information.

6. The page translation method according to claim 1, characterized in that, After sending the target drawing information to the display module, the method further includes: In response to the restore command, the target drawing information is obtained from the display module; The target text data is obtained by searching the data table based on the content of the text attributes in the target drawing information. Update the target drawing information based on the target text data; The updated target drawing information is sent to the display module so that the display module can redraw and display the restored page view based on the updated target drawing information.

7. The page translation method according to claim 1, characterized in that, The method further includes: In response to a translation function activation command, the system acquires the translation button and its location information, wherein the translation button is used to activate the translation command. The display module draws a target view based on the translation button and its position information. The target view is overlaid on the current page view to display the translation button on the current page view.

8. The page translation method according to claim 7, characterized in that, The method further includes: In response to the command to disable the translation function, the target view is hidden.

9. The page translation method according to claim 1, characterized in that, After the translation management module calls the translation tool to translate the text data to obtain the translated text data corresponding to the text data, the method further includes: If the translated text data corresponding to the text data is empty, a message will be displayed indicating that there is no translated text data in the current page view.

10. The page translation method according to claim 1, characterized in that, The step of traversing the drawing tree to obtain the text data included in the current page view specifically includes: Traverse the drawing tree to obtain all leaf nodes in the drawing tree; Text is extracted from the leaf nodes to obtain the text data included in the current page view.

11. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the page translation method according to any one of claims 1 to 10.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the page translation method according to any one of claims 1 to 10.