Multi-language adaptation method, device, equipment and storage medium
By using HOOK to identify and adapt multilingual text on the graphical user interface, the problem of cumbersome and time-consuming multilingual text completion operation in the prior art is solved, and fast and efficient multilingual adaptation is achieved.
Patent Information
- Application Number
- CN202111217953.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-19
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2041-10-19
AI Technical Summary
In the prior art, multilingual text completion operations are cumbersome, time-consuming and inefficient. Especially when multiple languages are needed to support the application, the existing solutions require manual translation and update of the installation package, resulting in poor dynamics.
By using the exchange HOOK method on the graphical user interface to exchange the initial process into a preset process, identify the text of the first language type, and perform adaptation operations, obtain the text of the second language type, including translation, parsing and calling built-in tools or server-side translation, which is displayed directly on the interface.
It enables rapid adaptation of multilingual text without updating the installation package, improves translation efficiency, simplifies operational processes, and reduces development costs.
Smart Images

Figure CN113918261B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a multi-language adaptation method, apparatus, device, and storage medium. Background Art
[0002] With the rapid development of mobile terminal technology, more and more applications are installed on mobile terminals, and the scope of application use is becoming increasingly broad. To meet the needs of users in different regions, application interfaces often need to support multiple languages. This means that the application interface display can be modified according to the local language used in different regions. This is called multilingual adaptation or string internationalization.
[0003] In the existing technology, an integrated multi-language directory is built into the res (specific) directory of the application installation package, that is, string files with different names are created in this directory (each string file with a name represents a language pack). When a new language needs to be added, the developer counts the strings in the string resource file, and after manual translation by the translator, copies them one by one to the corresponding language file, and then displays them on the terminal interface.
[0004] During the process of implementing the present invention, the inventors discovered that there are at least the following problems in the prior art: the implementation method of completing language text is cumbersome, time-consuming and inefficient. Summary of the Invention
[0005] The embodiments of the present application provide a multilingual adaptation method, apparatus, device, and storage medium to address the problem in the prior art that the implementation of language text completion for applications is cumbersome, time-consuming, and inefficient.
[0006] In a first aspect, an embodiment of the present application provides a multi-language adaptation method, comprising:
[0007] Before displaying the copy according to the initial flow of the copy in the application program on the graphical user interface, the initial flow is exchanged with a preset flow using an exchange hook method, and the preset flow is an adaptation flow of the copy;
[0008] identifying text in a first language displayed on the graphical user interface;
[0009] Performing an adaptation operation on the text in the first language type to obtain a text in a second language type;
[0010] The text in the second language type is displayed on the graphical user interface.
[0011] In one possible design of the first aspect, adapting the text in the first language type to obtain the text in the second language type includes:
[0012] Translating the text in the first language type to obtain the translated text, wherein the translated text includes a first portion of the text in the first language type that has not been translated and a second portion of the text that has been translated into the second language type;
[0013] The untranslated first portion of text is supplementarily translated according to the second language type to obtain a translated first portion of text, and the text of the second language type includes the translated first portion of text and the second portion of text.
[0014] In another possible design of the first aspect, adapting the text in the first language type to obtain the text in the second language type includes:
[0015] Parsing a multilingual file corresponding to the text of the first language type to obtain first text content corresponding to the first language type;
[0016] According to the first text content, obtaining, from a server, second text content corresponding to the second language type corresponding to the first text content;
[0017] Determining, in the second text content, text of the second language type corresponding to the text of the first language type;
[0018] The second text content is stored in the corresponding relationship with the first text content to obtain an updated multilingual file.
[0019] In another possible design of the first aspect, performing a supplementary translation on the untranslated first portion of text according to the second language type to obtain the translated first portion of text includes:
[0020] calling a built-in translation toolkit to translate the first part of the text to obtain a translated first part of the text in a second language type;
[0021] or,
[0022] An application program interface is called to send the first portion of text to a preset configuration platform for translation, thereby obtaining the translated first portion of text in a second language type.
[0023] Optionally, the application has been adapted for multi-language completion in multi-language scenarios, and the graphical user interface includes: a native page;
[0024] Accordingly, the identifying of the text in the first language type displayed on the graphical user interface includes:
[0025] The native page is HOOKed to obtain text in the first language type.
[0026] Optionally, the application has been adapted for multi-language completion in multi-language scenarios, and the graphical user interface includes: a web page;
[0027] Accordingly, the identifying of the text in the first language type displayed on the graphical user interface includes:
[0028] Taking a screenshot of the web page to obtain a screenshot page;
[0029] Optical character recognition (OCR) processing is performed on the screenshot page to remove image elements in the screenshot page to obtain text in the first language type.
[0030] Optionally, if the application is not adapted for multilingual completion in a multilingual scenario, the method further includes:
[0031] The language type set by the user or the language type configured by the server corresponding to the application is used as the second language type.
[0032] In a second aspect, an embodiment of the present application provides a multi-language adaptation device, comprising: a processing module, a display module;
[0033] The processing module is configured to, before displaying the copy on the graphical user interface according to the initial copy flow in the application, exchange the initial flow with a preset flow using an exchange hook, wherein the preset flow is an adaptation flow for the copy, identify the text in the first language type displayed on the graphical user interface, and then perform an adaptation operation on the text in the first language type to obtain text in the second language type;
[0034] The display module is configured to display text in the second language on the graphical user interface.
[0035] In one possible design of the second aspect, the processing module performs an adaptation operation on the text in the first language type to obtain the text in the second language type, specifically for:
[0036] Translating the text in the first language type to obtain the translated text, wherein the translated text includes a first portion of the text in the first language type that has not been translated and a second portion of the text that has been translated into the second language type;
[0037] The untranslated first portion of text is supplementarily translated according to the second language type to obtain a translated first portion of text, and the text of the second language type includes the translated first portion of text and the second portion of text.
[0038] In another possible design of the second aspect, the processing module performs an adaptation operation on the text of the first language type to obtain the text of the second language type, specifically for:
[0039] Parsing a multilingual file corresponding to the text of the first language type to obtain first text content corresponding to the first language type;
[0040] According to the first text content, obtaining, from a server, second text content corresponding to the second language type corresponding to the first text content;
[0041] Determining, in the second text content, text of the second language type corresponding to the text of the first language type;
[0042] The second text content is stored in the corresponding relationship with the first text content to obtain an updated multilingual file.
[0043] In another possible design of the second aspect, the processing module performs a supplementary translation on the untranslated first portion of text according to the second language type to obtain a translated first portion of text, specifically for:
[0044] calling a built-in translation toolkit to translate the first part of the text to obtain a translated first part of the text in a second language type;
[0045] or,
[0046] An application program interface is called to send the first portion of text to a preset configuration platform for translation, thereby obtaining the translated first portion of text in a second language type.
[0047] Optionally, the application has been adapted for multi-language completion in multi-language scenarios, and the graphical user interface includes: a native page;
[0048] Accordingly, the processing module identifies the text in the first language displayed on the graphical user interface, specifically for:
[0049] The native page is HOOKed to obtain text in the first language type.
[0050] Optionally, the application has been adapted for multi-language completion in multi-language scenarios, and the graphical user interface includes: a web page;
[0051] Accordingly, the processing module identifies the text in the first language displayed on the graphical user interface, specifically for:
[0052] Taking a screenshot of the web page to obtain a screenshot page;
[0053] Optical character recognition (OCR) processing is performed on the screenshot page to remove image elements in the screenshot page to obtain text in the first language type.
[0054] Optionally, if the application is not adapted for multilingual completion in a multilingual scenario, the processing module is further configured to:
[0055] The language type set by the user or the language type configured by the server corresponding to the application is used as the second language type.
[0056] In a third aspect, an embodiment of the present application provides a terminal device, including: a processor and a memory;
[0057] The memory stores computer-executable instructions;
[0058] The processor executes the computer-executable instructions, so that the terminal device performs the multi-language adaptation method as described in the first aspect and various possible designs.
[0059] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the multilingual adaptation method as described in the first aspect and various possible designs above.
[0060] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the multi-language adaptation method as described in the first aspect and various possible designs.
[0061] The embodiments of the present application provide a multi-language adaptation method, apparatus, device, and storage medium. This method uses an exchange HOOK method to exchange the initial process with a preset process before displaying the copy on the graphical user interface according to the initial process of the copy in the application. The preset process is the adaptation process of the copy, identifies the text of the first language type displayed on the graphical user interface, and performs an adaptation operation on the text of the first language type to obtain the text of the second language type, and then displays the text of the second language type on the graphical user interface. In this technical solution, by replacing the copy process in the application and adapting the copy in multiple languages, the problem of cumbersome, time-consuming, and inefficient implementation of operations such as language text completion in the prior art is solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0063] Figure 1A schematic diagram of an application scenario of the multi-language adaptation method provided in an embodiment of the present application;
[0064] Figure 2 A flowchart of a first embodiment of the multi-language adaptation method provided in an embodiment of the present application;
[0065] Figure 3 A flowchart of a second embodiment of the multi-language adaptation method provided in an embodiment of the present application;
[0066] Figure 4 A flowchart of a third embodiment of the multi-language adaptation method provided in an embodiment of the present application;
[0067] Figure 5 A schematic diagram of the overall flow of the multi-language adaptation method provided in an embodiment of the present application;
[0068] Figure 6 A schematic diagram of the structure of a multi-language adaptation device provided in an embodiment of the present application;
[0069] Figure 7 A schematic diagram of the structure of the terminal device provided in an embodiment of the present application.
[0070] The above drawings illustrate specific embodiments of the present disclosure, which will be described in more detail below. These drawings and textual descriptions are not intended to limit the scope of the present disclosure in any way, but rather to illustrate the concepts of the present disclosure to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0071] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all possible embodiments consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
[0072] Before introducing the embodiments of the present application, the background technology of the present application is first explained:
[0073] With the rapid development of mobile terminal technology, more and more applications are installed on mobile terminals, and the scope of application use is becoming increasingly wider. In order to meet the needs of users in different regions, the application interface usually needs to support multiple languages, thereby changing the application interface display according to the language used in different regions. This is the so-called multilingual adaptation or string internationalization. The existing technology is to integrate a multilingual directory in the res (specific) directory of the application installation package, that is, to create string files (multilingual packages) with different names in this directory.
[0074] However, the prior art integrates the multi-language package into the application installation package, which increases the size of the application installation package and requires upgrading the installation package when refreshing the multi-language package of the application.
[0075] Furthermore, during the development process, developers were required to compile a list of strings in the string resource files and hand them off to the translation team for manual translation. Once the translation was complete, the translated strings were manually copied one by one and placed in the corresponding language folder. This entire process was cumbersome and labor-intensive, resulting in a lengthy development process and low efficiency.
[0076] In addition, the existing solution cannot effectively cover the scenarios of adding and modifying multilingual copywriting, and can only be solved by updating and upgrading the multilingual package or installation package, which has poor dynamics.
[0077] Based on the above problems in the prior art, Figure 1 The following is a schematic diagram of an application scenario of the multi-language adaptation method provided in the embodiment of the present application, which is used to solve the above technical problems. Figure 1 As shown, the application scenario diagram includes: a terminal device 11 and a server 12.
[0078] The terminal device 11 may be a device with display function, such as a mobile phone, a computer, a tablet, or a TV, and the server may be a server-side device corresponding to an application running on the terminal device 11, such as a configuration platform.
[0079] In one possible implementation, the display interface of the terminal device 11 is opening an application whose default language is English. At this time, the English on the display interface needs to be displayed in Chinese. According to the multi-language package in the application (the multi-language package contains some English corresponding to Chinese, but lacks some English corresponding to Chinese), at this time, the terminal device 11 will send the English text that cannot be translated into Chinese and the identifier of the translation type corresponding to the English text to the server 12. In the server 12, this part of the English text is translated, and the result is returned to the terminal device 11, and then displayed on the display interface of the terminal device 11.
[0080] It should be understood that the above processing process and hardware equipment are only examples of possible implementation methods. In the following embodiments, the contents provided by the embodiments of this application will be described in detail.
[0081] In response to the above-mentioned technical problems, the inventor's technical conception process of this application is as follows: The inventor found that when translating a certain text in the existing technology, if the multi-language package under the application does not have the corresponding translation text for the text, the multi-language package needs to be updated, that is, the technical staff will re-change the code of the application and send the installation package to the user to re-download and install the installation package. The inventor believes that when there is no corresponding translation text for the text, this part of the text and the type to be translated can be sent to a third-party device, directly obtained after translation, and then loaded on the user's device; or it can be translated by calling other translation software or toolkits on the user's device, and the results can be returned to the application and displayed, which can solve the problem of complicated steps caused by the need to update the application, and also improve the translation efficiency.
[0082] Below Figure 1 The framework structure diagram shown in FIG2 is used to describe the technical solution of the present application in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0083] Figure 2 This is a flow chart of the first embodiment of the multi-language adaptation method provided in the present application. Figure 2 As shown, the multi-language adaptation method may include the following steps:
[0084] Step 21: Before displaying the copy according to the initial flow of the copy in the application on the graphical user interface, use the exchange HOOK method to exchange the initial flow with the preset flow.
[0085] Among them, the preset process is the adaptation process of the copywriting.
[0086] In this step, the specific method for copywriting settings in the client corresponding to the application, that is, the initial process of the copywriting, is intercepted and exchanged for the preset process using the HOOK method, that is, the adaptation operation of the multilingual copywriting is performed according to specific rules, which is detailed in the following embodiment.
[0087] Optionally, the process may be triggered when the user opens the application and slides up or down the page on the graphical user interface before the text is displayed, or may be triggered when the server detects that a multilingual file in the application needs to be updated.
[0088] Step 22: Identify the text in the first language displayed on the graphical user interface.
[0089] In this step, in order to adapt the text on the graphical user interface, the text needs to be recognized first. The embodiment of the present application divides the application into two possible implementations and processes them separately. One possible implementation is that the application has adapted to multilingual completion in multilingual scenarios, and the other possible implementation is that the application has not adapted to multilingual completion in multilingual scenarios.
[0090] In a possible implementation, for multi-language completion of an application that has adapted to multi-language scenarios, the graphical user interface includes: a native page and a network page.
[0091] A native page is a page that can be displayed by an application without an internet connection; a network page is an embedded web page that requires an internet connection to load and display, such as an HTML5 page. Furthermore, the two different types of pages are processed differently to obtain text in the first language.
[0092] The first type, graphical user interface includes: native page.
[0093] Hook the native page to obtain the text in the first language type.
[0094] Specifically, since the embodiment of the present application needs to intercept the text setting method in the existing technology and replace it with the processing process of this solution, the multi-language adaptation of the text type can be processed in a HOOK manner to obtain the text of the first language type and the language type to be translated, that is, the second language type.
[0095] The following is the program code corresponding to the setting method of a certain field in the Input Output System (IOS) as an example:
[0096]
[0097]
[0098] The second type, graphical user interface, includes: web pages.
[0099] First, a screenshot of the web page is processed to obtain a screenshot page. Then, an optical character recognition (OCR) process is performed on the screenshot page to remove image elements in the screenshot page to obtain text in the first language type.
[0100] Specifically, for embedded web pages, the text setting method cannot be directly hooked in the application to convert it into an XML format file. At this time, it is necessary to take a screenshot of the page to obtain a screenshot page. There will be some irrelevant text in the screenshot page. For example, the illustrations of the screenshot page contain some text, which does not need to be translated. These irrelevant texts are removed. This process can be achieved through OCR to obtain the text of the first language type and the language type to which it is translated.
[0101] In another possible implementation, for multilingual completion in an application that is not adapted to a multilingual scenario, the language type set by the user or the language type configured by the server corresponding to the application needs to be used as the second language type.
[0102] The default language type of the application may be used as the first language type. When the first language type and the second language type are different, the text corresponding to the first language type is directly translated using the following steps.
[0103] Step 23: Perform adaptation operation on the text in the first language type to obtain text in the second language type.
[0104] In this step, in the graphical user interface, an adaptation operation is performed on the text of the first language type, which may be completing the translation text corresponding to the text of the first language type, or modifying (updating) the translation text corresponding to the text of the first language type.
[0105] Optionally, this step may have the following possible scenarios: one is to translate the untranslated part of the text of the first language type; the second is to update the multilingual file (in the application) corresponding to the text of the first language type; or it can be to update the text of the second language type corresponding to the text of the first language type, which are detailed in the following two embodiments respectively.
[0106] Step 24: Display the text in the second language on the graphical user interface.
[0107] In this step, after the text in the second language type is obtained, the adapted text is displayed in a graphical user interface so that the user can browse the interface provided by the application or operate the application.
[0108] In a possible implementation, the text in the second language may be displayed through a Label, a Button, or other controls that can set text or attributedText.
[0109] The multilingual adaptation method provided in an embodiment of the present application utilizes a hook method to replace the initial flow of the application's text with a preset flow before displaying it on a graphical user interface. The preset flow serves as the text adaptation flow. The method then identifies text in a first language displayed on the graphical user interface, performs adaptation operations on the text in the first language, and obtains text in a second language. This method then displays the text in the second language on the graphical user interface. This technical solution, by replacing the text flow in the application and adapting the text to multiple languages, addresses the cumbersome, time-consuming, and inefficient implementation of language text completion and other operations in the prior art.
[0110] Based on the above embodiments, Figure 3 This is a flow chart of the second embodiment of the multi-language adaptation method provided in the present application. Figure 3 As shown, the above step 23 can be implemented by the following steps:
[0111] Step 31: Translate the text in the first language type to obtain a translated text.
[0112] The translated text includes a first portion of text in the first language type that has not been translated and a second portion of text that has been translated into the second language type.
[0113] In this solution, when an application runs on a terminal device, the application's screens are displayed on the terminal's graphical user interface. The language of the text displayed on these screens can be adjusted based on user needs. For example, if the application supports Chinese text by default, the Chinese text can be translated into English and displayed on the interface.
[0114] In this step, the graphical user interface provided by the application displays text in the first language type, and the text in the first language type needs to be translated.
[0115] Among them, the first language type can be determined by determining whether a multi-language mode is set in the application and searching for multi-language files. If no multi-language files are detected, the default application language type is used as the first language type. Alternatively, the language type set by the user according to needs or sent by the server can be used as the first language type.
[0116] In one possible design, in response to a user clicking a translation button on a graphical user interface, the application can call a local multilingual file to translate the text in the first language type according to the language type into which the text in the first language type is converted as needed.
[0117] It should be understood that when the first language type and the language type to be converted (hereinafter referred to as the second language type) are consistent, the following processing is unnecessary.
[0118] The translated text includes a first portion of text in the first language type that has not been translated and a second portion of text that has been translated into the second language type.
[0119] That is, since the multilingual file does not contain the second part of the text of the second language type corresponding to all the texts of the first language type, during the translation process, there appear parts that have been successfully translated or parts that have not been successfully translated, that is, the first part of the text and the second part of the text.
[0120] Alternatively, some applications do not have a multi-language completion function adapted to multi-language scenarios, and thus cannot translate the text in the first language type, that is, only the first part of the text exists.
[0121] Step 32: Perform supplementary translation on the untranslated first part of the text according to the second language type to obtain a translated first part of the text.
[0122] The second language text includes the translated first part of the text and the translated second part of the text.
[0123] In this step, there is untranslated text in the graphical user interface, which is called the first part of text. At this time, this part of text needs to be translated. The embodiment of the present application provides the following two ways to implement it as examples:
[0124] First, a built-in translation toolkit is called to translate the first part of the text to obtain the translated first part of the text in the second language type.
[0125] Among them, the translation toolkit can be some software development tools (Software Development Kit, SDK), which can be in the terminal device. Taking IOS as an example, the tool can be Google Translate software, that is, after the first part of the text is translated by Google Translate software, the translated first part of the text is obtained.
[0126] The second method is to call an application program interface and send the first part of the text to a preset configuration platform for translation, thereby obtaining the translated first part of the text in the second language type.
[0127] Among them, the configuration platform allows technicians to customize and store the texts corresponding to the first language type and the second language type after translation. The translated first part of the text can be directly obtained from the configuration platform by calling the Application Programming Interface (API).
[0128] The multilingual adaptation method provided by the embodiments of this application translates the text of the first language type to obtain the translated text, and supplements and translates the untranslated first part of the text according to the second language type to obtain the translated first part of the text. In this technical solution, starting from the untranslated text, the application programming interface or the built-in translation toolkit is called for translation, realizing the operation of adapting the text without updating the application package, and the process is convenient.
[0129] Based on the above embodiments Figure 4 is a schematic flowchart of the third embodiment of the multilingual adaptation method provided by the embodiments of this application. As Figure 4 shown, the above step 23 can be implemented through the following steps
[0130] Step 41: Parse the multilingual file corresponding to the text of the first language type to obtain the first text content corresponding to the first language type.
[0131] In this solution, when it is necessary to update the multilingual file in the application, that is, when updating the string files with different names in the res (specific) directory of the application installation package (taking IOS as an example), for example, correcting, expanding, and adding multilingual types to the English translation of a certain Chinese word, the following operations are performed.
[0132] From the perspective of the prior art, even if updating the English translation of a single Chinese word, it is necessary to download all resources, that is, update the entire installation package, while the embodiments of this application only update the resources that need to be updated (for example, updating the translation of a certain word in a certain language).
[0133] In this step, first obtain the built-in multilingual file in the application, that is, by obtaining the string file and reading all the texts contained in the file, and parsing them in a certain format.
[0134] In a possible implementation, the format can be the correspondence between the keyword key and the value value, such as "hello - hello" in Chinese - English. Obtain "hello" in Chinese and store it in a certain path or specific location.
[0135] Step 42: Obtain the second text content corresponding to the second language type of the first text content from the server.
[0136] In this step, the server can be the service side of the corresponding manufacturer of the application, or the service side for text translation. The second text content corresponding to the second language type of the first text content is configured in the server, which can be the text content added or updated by technicians in real time.
[0137] In a possible implementation, continuing with the above example of "Hello - hello" (Chinese - English), in the server, it may be added or updated that "Hello" (the first text content) corresponds to "hi" (English), or corresponds to "здравствуйте" (other language). Obtain "hi" or "здравствуйте" corresponding to "Hello" from the server. Here, "hi" or "здравствуйте" is the second text content corresponding to the second language type.
[0138] Step 43: Determine the text of the second language type corresponding to the text of the first language type in the second text content.
[0139] In this step, the text of the second language type corresponding to the text of the first language type is in the second text content, and the text of the second language type displayed in the graphical user interface is also the updated text to be supplemented.
[0140] Optionally, the process of this embodiment can be the overall update of the text content of multiple language types in a multi - language file, or the update of the text of the second language type displayed in the graphical user interface.
[0141] Step 44: Store the second text content into the corresponding relationship of the first text content to obtain an updated multi - language file.
[0142] In this step, store the modified key - value corresponding relationship into the corresponding string file and write it through the key, that is, store the updated text content into the multi - language file.
[0143] Furthermore, the updated application contains the second text content corresponding to the first text content, which can be displayed on the corresponding graphical user interface during the subsequent operation of the application.
[0144] The multilingual adaptation method provided in an embodiment of the present application parses a multilingual file corresponding to a text of a first language type to obtain first text content corresponding to the first language type. Based on the first text content, the method obtains second text content corresponding to a second language type corresponding to the first text content from a server. The method then determines within the second text content which text of the first language type corresponds to the text of the second language type. Finally, the method stores the second text content in the corresponding relationship of the first text content to obtain an updated multilingual file. This technical solution obtains the required text content from the server, avoiding the cumbersome process of re-downloading the application when updating multiple languages, as is the case with existing technologies. This method provides a basis for the application to subsequently display different text translation results in a graphical user interface.
[0145] Based on the above embodiments, Figure 5 This is a schematic diagram of the overall flow of the multi-language adaptation method provided in the embodiment of this application. Figure 5 As shown, the schematic diagram includes the following steps:
[0146] Step 1. Start;
[0147] Step 2: Start the application.
[0148] After the application is started, there may be two execution processes, namely, completion and update of the multi-voice type of the text. Specifically, the update starts from step 3; the text completion starts from step 7.
[0149] Step 3: Parse multilingual files;
[0150] Step 4: Obtain all first text content (first language type) - second text content (second language type) in the multilingual file;
[0151] Step 5: Pull the first text content (first language type) - the second text content (second language type) that needs to be updated and update it;
[0152] Step 6: Encapsulate the updated first text content (first language type) - second text content (second language type) into a multilingual file, and execute step 19;
[0153] Step 7: Determine whether the application has been adapted to multilingual completion in a multilingual scenario. If so, proceed to step 8; if not, proceed to step 11.
[0154] Step 8. Set the application's default language as the first language type;
[0155] Step 9: Use the language type set by the user in the application or sent by the server as the first language type;
[0156] Step 10: Call the API or SDK to obtain the translated text and proceed to step 18.
[0157] Step 11: Determine whether the graphical user interface of the application is a native page when it is running. If so, execute step 12; if not, execute step 14;
[0158] Step 12: Determine the first language type;
[0159] Step 13: Obtain the text in the first language type by exchanging, and execute step 17;
[0160] Step 14: Determine the first language type;
[0161] Step 15: Take a screenshot of the web page to obtain a screenshot page;
[0162] Step 16: Perform OCR on the screenshot page to determine the text in the first language type;
[0163] Step 17: Determine the text to be completed and the corresponding language type, and execute step 10;
[0164] Step 18: Display in the graphical user interface;
[0165] Step 19. End.
[0166] The multilingual adaptation method provided in the embodiment of the present application determines the default language type and the language type that needs to be changed for the application, and performs corresponding processing on two scenarios: multilingual completion for the application that has adapted to the multilingual scenario and multilingual completion for the application that has not adapted to the multilingual scenario. It determines the text that needs to be completed or supplemented, and realizes efficient translation of the text and display in the graphical user interface. In addition, it also parses the multilingual package that needs to be updated and obtains the language that needs to be updated from the application server, thereby reducing the cumbersome steps in the update process of the existing technology and avoiding the inconvenience caused by the long development cycle.
[0167] Based on the above method embodiment, Figure 6 This is a schematic diagram of the structure of the multi-language adaptation device provided in the embodiment of the present application. Figure 6 As shown, the multi-language adaptation device includes: a processing module 61, a display module 62;
[0168] Processing module 61 is configured to, before displaying the copy on the graphical user interface according to the initial copy flow in the application, exchange the initial flow with a preset flow using a swap hook, where the preset flow is an adaptation flow for the copy, identify the text in the first language displayed on the graphical user interface, and then perform an adaptation operation on the text in the first language to obtain text in the second language;
[0169] The display module 62 is configured to display the text in the second language on the graphical user interface.
[0170] In one possible design of the embodiment of the present application, the processing module 61 performs an adaptation operation on the text of the first language type to obtain the text of the second language type, specifically for:
[0171] Translating the text in the first language to obtain a translated text, wherein the translated text includes a first portion of the text in the first language that has not been translated and a second portion of the text that has been translated into the second language;
[0172] According to the second language type, the untranslated first part of the text is supplementarily translated to obtain the translated first part of the text, and the text of the second language type includes the translated first part of the text and the second part of the text.
[0173] In another possible design of the embodiment of the present application, the processing module 61 performs an adaptation operation on the text of the first language type to obtain the text of the second language type, specifically for:
[0174] Parsing a multilingual file corresponding to a text of a first language type to obtain first text content corresponding to the first language type;
[0175] According to the first text content, obtaining from the server a second text content corresponding to a second language type corresponding to the first text content;
[0176] Determining, in the second text content, a text of a second language type corresponding to the text of the first language type;
[0177] The second text content is stored in the corresponding relationship with the first text content to obtain an updated multilingual file.
[0178] In another possible design of the embodiment of the present application, the processing module 61 performs a supplementary translation on the untranslated first portion of text according to the second language type to obtain a translated first portion of text, specifically for:
[0179] Calling a built-in translation toolkit to translate the first part of the text to obtain the translated first part of the text in the second language type;
[0180] or,
[0181] An application program interface is called to send the first portion of text to a preset configuration platform for translation, thereby obtaining the translated first portion of text in a second language type.
[0182] Optionally, the application has been adapted to multi-language completion for multi-language scenarios, and the graphical user interface includes: native pages;
[0183] Accordingly, the processing module 61 identifies the text in the first language displayed on the graphical user interface, specifically for:
[0184] Hook the native page to obtain the text in the first language type.
[0185] Optionally, the application has been adapted for multi-language completion in multi-language scenarios, and the graphical user interface includes: web pages;
[0186] Accordingly, the processing module 61 identifies the text in the first language displayed on the graphical user interface, specifically for:
[0187] Taking a screenshot of the web page to obtain a screenshot page;
[0188] Optical character recognition (OCR) is performed on the screenshot page to remove image elements from the screenshot page and obtain text in the first language type.
[0189] Optionally, if the application is not adapted to multilingual completion in a multilingual scenario, the processing module 61 is further configured to:
[0190] The language type set by the user or the language type configured by the server corresponding to the application is used as the second language type.
[0191] The multilingual adaptation device provided in the embodiment of the present application can be used to implement the technical solution corresponding to the multilingual adaptation method in the above embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0192] It should be noted that it should be understood that the division of the various modules of the above multi-language adapter is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also all be implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by the hardware integrated logic circuit in the processor element or instructions in the form of software.
[0193] Figure 7 This is a schematic diagram of the structure of the terminal device provided in the embodiment of the present application. Figure 7As shown, the terminal device may include: a processor 70, a memory 71, and computer program instructions stored in the memory 71 and executable on the processor 70.
[0194] Optionally, the terminal device may further include: a display 72.
[0195] The processor 70 executes the computer-executable instructions stored in the memory 71, so that the processor 70 implements the solution in the above embodiment. The processor 70 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0196] The memory 71 and the display 72 are connected to the processor 70 via a system bus and communicate with each other. The memory 71 is used to store computer program instructions.
[0197] The display 72 is used to display the graphical user interface. In hardware implementation, the above Figure 6 The display module 62 in the illustrated embodiment corresponds to the display 72 in this embodiment, wherein the display 72 is used to display the processing results of the processor 70 and interact with humans.
[0198] The system bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. System buses can be categorized as address buses, data buses, and control buses. For ease of illustration, the diagram uses a single thick line, but this does not imply a single bus or type of bus.
[0199] The terminal device provided in the embodiment of the present application can be used to execute the technical solution corresponding to the multi-language adaptation method in the above embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0200] An embodiment of the present application further provides a chip for executing instructions, which is used to execute the technical solution of the multi-language adaptation method in the above embodiment.
[0201] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed on a terminal device, the terminal device executes the technical solution of the multi-language adaptation method in the above embodiment.
[0202] An embodiment of the present application further provides a computer program product, including a computer program, which, when executed by a processor, is used to perform the technical solution of the multi-language adaptation method in the above embodiment.
[0203] The computer-readable storage medium may be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The computer-readable storage medium may be any available medium that can be accessed by a general-purpose or dedicated terminal device.
[0204] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A multi-language adaptation method, characterized in that: include: Before displaying the copy according to the initial flow of the copy in the application program on the graphical user interface, the initial flow is exchanged with a preset flow using an exchange hook method, and the preset flow is an adaptation flow of the copy; identifying text in a first language displayed on the graphical user interface; Performing an adaptation operation on the text in the first language type to obtain a text in a second language type; displaying text in the second language type on the graphical user interface; Adapting the text in the first language type to obtain the text in the second language type includes: translating the text in the first language type to obtain the translated text, wherein the translated text includes a first portion of the text in the first language type that has not been translated and a second portion of the text that has been translated into the second language type; calling a built-in translation toolkit to translate the first portion of text to obtain a translated first portion of text in a second language type; or calling an application program interface to send the first portion of text to a preset configuration platform for translation to obtain a translated first portion of text in the second language type, wherein the text in the second language type includes the translated first portion of text and the second portion of text; The application has been adapted for multilingual completion in a multilingual scenario, and the graphical user interface includes: a native page; accordingly, identifying text of the first language type displayed on the graphical user interface includes: hooking the native page to obtain text of the first language type; The graphical user interface includes a web page; accordingly, identifying text in a first language displayed on the graphical user interface includes: taking a screenshot of the web page to obtain a screenshot page; performing optical character recognition (OCR) on the screenshot page to remove image elements from the screenshot page to obtain text in the first language; The application is not adapted to multi-language completion in a multi-language scenario, and the method further includes: using a language type set by a user or a language type configured by a server corresponding to the application as the second language type.
2. The method according to claim 1, characterized in that The adapting operation on the text of the first language type to obtain the text of the second language type includes: Parsing a multilingual file corresponding to the text of the first language type to obtain first text content corresponding to the first language type; According to the first text content, obtaining, from a server, second text content corresponding to the second language type corresponding to the first text content; Determining, in the second text content, text of the second language type corresponding to the text of the first language type; The second text content is stored in the corresponding relationship with the first text content to obtain an updated multilingual file.
3. A multi-language adaptation device, characterized in that: include: Processing module, display module; The processing module is configured to, before displaying the copy on the graphical user interface according to the initial copy flow in the application, exchange the initial flow with a preset flow using an exchange hook, wherein the preset flow is an adaptation flow for the copy, identify the text in the first language type displayed on the graphical user interface, and then perform an adaptation operation on the text in the first language type to obtain text in the second language type; The display module is configured to display text in the second language on the graphical user interface; The processing module is specifically configured to: translate the text in the first language type to obtain the translated text, wherein the translated text includes a first portion of the text in the first language type that has not been translated and a second portion of the text that has been translated into the second language type; calling a built-in translation toolkit to translate the first portion of text to obtain a translated first portion of text in a second language type; or calling an application program interface to send the first portion of text to a preset configuration platform for translation to obtain a translated first portion of text in the second language type, wherein the text in the second language type includes the translated first portion of text and the second portion of text; The application has been adapted for multilingual completion in multilingual scenarios. The graphical user interface includes: a native page; accordingly, the processing module identifies text of the first language type displayed on the graphical user interface, and is specifically used to: perform HOOK processing on the native page to obtain text of the first language type; the graphical user interface includes: a web page; accordingly, the processing module identifies text of the first language type displayed on the graphical user interface, and is specifically used to: perform screenshot processing on the web page to obtain a screenshot page; perform optical character recognition (OCR) processing on the screenshot page to remove image elements in the screenshot page to obtain text of the first language type; The application is not adapted to multi-language completion in a multi-language scenario, and the processing module is further configured to: The language type set by the user or the language type configured by the server corresponding to the application is used as the second language type.
4. The device according to claim 3, characterized in that The processing module performs an adaptation operation on the text of the first language type to obtain the text of the second language type, specifically for: Parsing a multilingual file corresponding to the text of the first language type to obtain first text content corresponding to the first language type; According to the first text content, obtaining, from a server, second text content corresponding to the second language type corresponding to the first text content; Determining, in the second text content, text of the second language type corresponding to the text of the first language type; The second text content is stored in the corresponding relationship with the first text content to obtain an updated multilingual file.
5. A terminal device comprising: A processor, a memory, and computer program instructions stored in the memory and executable on the processor, wherein the processor implements the multi-language adaptation method according to claim 1 or 2 when executing the computer program instructions.
6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the multi-language adaptation method according to claim 1 or 2.
7. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, it is used to implement the multi-language adaptation method according to claim 1 or 2.
Citation Information
Patent Citations
Text translation method and system, computer equipment and storage medium
CN108280219A
Multi-language adaptation method, device and system, computer equipment and storage medium
CN111427641A