Text translation method and device
By integrating text translation functions in the gateway device, centrally translating the response messages returned by the server, the problems of high resource occupation and low translation efficiency in the existing technology are solved, and resource conservation and efficiency improvement are achieved.
Patent Information
- Application Number
- CN202411594036.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-02-28
AI Technical Summary
In the prior art, the server needs to deploy and manage multiple translation functions, resulting in high resource occupation and low overall translation efficiency.
Integrate text translation functions in the gateway device, and centrally translate the text in the response packet returned by the server through the gateway device, reducing the number of translation services that the server needs to deploy.
It effectively saves server resources, improves resource utilization, and improves translation efficiency.
Smart Images

Figure CN119538946A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data communication, and in particular to a text translation method and device. Background Art
[0002] The application system is usually composed of a client and a server, which work together to provide users with specific functions. Among them, the server usually contains various types of background services for the client to access. In some scenarios, the client may need to display text content in different languages to the user, such as displaying the text on the page in simplified Chinese, English, Japanese, etc.
[0003] In the related art, each backend service on the server side will integrate its own translation function, so that when receiving the access request from the client, it will use its own integrated translation function to translate the text content to be returned into the text content in the language required by the client. However, this method requires the deployment and management of a large number of translation functions, and each translation function is repeated, which occupies a lot of resources and has a low overall translation efficiency, which needs to be improved urgently. Summary of the invention
[0004] In view of this, the present invention provides a text translation method and device to solve the deficiencies in the related art.
[0005] Specifically, the present invention is achieved through the following technical solutions:
[0006] According to a first aspect of the present invention, a text translation method is provided, which is applied to a gateway device, and the method comprises:
[0007] Forwarding a request message sent by a client to a corresponding server, and receiving a first response message returned by the server, wherein the first response message includes a first text in a first language;
[0008] In the case where it is determined that the first text needs to be translated, the first text is translated into a second text in a second language, and a second response message including the second text is sent to the client.
[0009] According to a second aspect of the present invention, there is provided a text translation device, which is applied to a gateway device, and the device comprises:
[0010] a message forwarding unit, configured to forward a request message sent by a client to a corresponding server, and receive a first response message returned by the server, wherein the first response message includes a first text in a first language;
[0011] A text translation unit is used to translate the first text into a second text in a second language when it is determined that the first text needs to be translated, and send a second response message containing the second text to the client.
[0012] According to a third aspect of the present invention, there is provided an electronic device, comprising:
[0013] A processor; a memory for storing processor-executable instructions; wherein the processor implements the steps of the method as described in the first aspect by running the executable instructions.
[0014] According to a fourth aspect of the present invention, there is provided a computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method described in the first aspect.
[0015] The technical solution provided by the embodiments of the present invention may have the following beneficial effects:
[0016] In addition to forwarding request messages and response messages normally, the gateway device of the present invention is also used to translate the text in the response message, that is, to translate the first text in the first language in the first response message into the second text in the second language. It can be seen that the scheme of the present invention is based on the gateway device connected between the client and the server, and integrates the text translation function in the gateway device, so that the device can centrally translate the first text in the first response message returned by the server based on the function. It can be understood that no matter whether the gateway device is connected to various background services in the same server or connected to multiple servers at the same time, it can realize centralized translation of related texts, which greatly reduces the number of translation services that need to be deployed on the server, effectively saves server resources and improves its resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 is a schematic diagram of the architecture of a text translation system shown in an embodiment of the present invention;
[0019] Figure 2 is a flow chart of a text translation method shown in an embodiment of the present invention;
[0020] Figure 3 is a schematic diagram of a text translation method shown in an embodiment of the present invention;
[0021] Figure 4 is an interactive flow chart of a text translation method shown in an embodiment of the present invention;
[0022] Figure 5 is a schematic structural diagram of an electronic device shown in an embodiment of the present invention;
[0023] Figure 6 It is a block diagram of a text translation device shown in an embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to solve the above problems existing in the related art, the present invention proposes a text translation solution, in which a translation function is integrated in a gateway device between a client and a server, and the gateway device provides a unified translation service for the message content between the two based on the translation function. An embodiment of the solution is described in detail below in conjunction with the accompanying drawings.
[0025] Figure 1 FIG. 1 is a schematic diagram of the architecture of a text translation system provided by an exemplary embodiment. Figure 1 As shown, the system may include a gateway device 10, several servers, such as server 11 and server 12, several electronic devices, such as mobile phone 13, mobile phone 14 and mobile phone 15, etc.
[0026] Any server connected to the gateway device 10 can be a physical server containing an independent host, or it can also be a virtual server, cloud server, etc. hosted by a host cluster. The back-end program code of the application can be run in the server to serve as the server of the application. The server can include one or more background services to provide specific services to the client. Exemplarily, the server can be built using a microservice architecture, under which the server can be composed of one or more microservice components at a logical level. At this time, the client can access each microservice component on demand (of course, some service components can only be accessed if they have access rights), which will not be repeated here.
[0027] The front-end program code of the application can be run in any mobile phone connected to the gateway device 10 to serve as the client of the application. Exemplarily, the installation package of the application (such as .apk or .deb format) can be pre-installed in the mobile phone 13 so that the client can be started and run in the mobile phone 13 (the client and the server adopt the C / S architecture at this time). Alternatively, when an online "client" such as HTML5 technology is adopted, the client can be obtained and run without installing the corresponding application on the electronic device, such as the mobile phone 14 can access the server through a browser (the client and the server adopt the B / S architecture at this time), which will not be repeated. Of course, the mobile phone is only one type of electronic device that the user can use. In fact, the user can also use electronic devices such as the following types: personal computers (Personal Computer), workstations (Work Station), PDAs (Personal Digital Assistants), wearable devices (such as smart glasses, smart watches, etc.), VR (Virtual Reality) devices, AR (Augmented Reality, Augmented Reality) devices, etc., and the embodiments of the present invention do not limit this.
[0028] in addition, Figure 1 The lightning-shaped arrow used to connect the server (or mobile phone) and the gateway device 10 indicates that the server can be connected to the gateway device 10 through a network. Specifically, the network may include various types of wired or wireless networks, which are not limited in the embodiment of the present invention. Figure 1 As shown, the gateway device can be connected to at least one server and at least one electronic device. The "server" described in the following embodiments of the present invention can be any server running in any server connected to the gateway device 10, and the "client" can be any client running in any electronic device (such as any mobile phone) connected to the gateway device 10. This is hereby explained.
[0029] Figure 2 is a flowchart of a text translation method shown in an embodiment of the present invention, the method is applied to a gateway device, such as Figure 1 The gateway device 10 shown in FIG.
[0030] Step 202: forward the request message sent by the client to the corresponding server, and receive a first response message returned by the server, wherein the first response message includes a first text in a first language.
[0031] First of all, it should be noted that the gateway device described in the present invention can be obtained by performing software and / or hardware modifications to a conventional gateway device in the relevant technology, so that the device has a text translation function while having a message forwarding function, and thus the text translation solution described in the present invention can be implemented relying on the text translation function.
[0032] After receiving the request message sent by the client to the server, the gateway device can forward the request message to the corresponding server. Figure 1 As shown, it is assumed that the servers 11 and 12 are respectively running the server of the application APP1 and APP2, the mobile phone 13 is running the client of APP1, and the mobile phones 14 and 15 are running the client of APP2. The gateway device 10 can maintain the correspondence between the client identifier of the above-mentioned client and the server identifier of the corresponding server, or it can also maintain the correspondence between each server and its access interface. Based on this, if the gateway device 10 receives a request message sent by the mobile phone 13, it can forward the message to the server running in the server 11 based on the above correspondence; if it receives a request message sent by the mobile phone 14 or the mobile phone 15, it can forward the message to the server running in the server 12 based on the above correspondence, which will not be repeated. Among them, the gateway device 10 can also forward the request message sent by the client to the corresponding background service in the server, which will not be repeated.
[0033] After receiving the request message forwarded by the gateway device, the server can process the message accordingly and return a targeted response message (hereinafter referred to as the first response message). The specific processing process can be referred to the records in the relevant technology, which will not be repeated here. Among them, the message content of the first response message includes a text in a certain language (i.e., a first text in a first language), such as a Chinese text (including multiple Chinese characters) or an English text (including multiple words).
[0034] At this time, the gateway device can determine whether it is necessary to translate the first text in the first response message, that is, whether it is necessary to translate the first text in the first language into the second text in the second language. The first language and the second language in the present invention are different natural languages, such as simplified Chinese and English, simplified Chinese and traditional Chinese, English and Japanese, etc.
[0035] In one embodiment, when it is determined that no translation is required, the gateway device may directly forward the received first response message (as the second response message) to the aforementioned client as a response to the request message. Figure 3As shown, assuming that the gateway device receives the request message 3 sent by the client, it can forward the message to the corresponding background service and receive the first response message returned by the latter; assuming that it is determined that the first text does not need to be translated, the message forwarding component can directly forward the first response message to the client as a response to the request message 3. At this time, the first response message received by the client contains the untranslated first text in the first language.
[0036] Step 204: if it is determined that the first text needs to be translated, the first text is translated into a second text in a second language, and a second response message including the second text is sent to the client.
[0037] As mentioned above, the gateway device has a text translation function, so when it is determined that the first text needs to be translated, it can translate the first text in the first language into the second text in the second language based on the function, and then generate a second response message containing the second text and send the message to the client. It is understandable that the client can parse the second response message to obtain the second text and display the text to the user for viewing / reading.
[0038] It can be seen that the scheme of the present invention is based on the gateway device connected between the client and the server, and integrates the text translation function in the gateway device, so that the device can centrally translate the first text in the first response message returned by the server based on the function. It can be understood that whether the gateway device is connected to various background services in the same server or connected to multiple servers at the same time, it can achieve centralized translation of related texts, greatly reducing the number of translation services that need to be deployed on the server, effectively saving server resources and thus improving its resource utilization.
[0039] In one embodiment, the gateway device can determine whether the first text needs to be translated in a variety of ways. For example, when there is a translation requirement (i.e., the text content in the second language needs to be obtained), the client can add a language identifier of the second language to the header of the request message when generating the request message; accordingly, the gateway device can parse the received request message to determine whether the language identifier of the second language is recorded in its header: if the language identifier is recorded, it can be determined that the first text needs to be translated from the first language to the second language; conversely, if the language identifier is not recorded, it can be determined that the first text does not need to be translated. Of course, this method requires the message structure of the request message to be modified (such as adding a language type field to the message header), and ensure that the gateway device can identify such messages generated and sent by the client. It can be understood that when any language identifier is parsed from the message header, the language represented by the language identifier can be determined as the aforementioned second language. In this way, the client can specify the second language required by itself to the gateway device, so that the gateway device can translate the aforementioned first text as needed, thereby better meeting the language requirements of the client.
[0040] For another example, given that different users corresponding to different clients accessing the server may be in different regions (such as different areas, different countries, etc.), and the languages used by users in different regions are often different, the region where the user is located can be predicted based on the network address of the client, and whether the first text needs to be translated can be determined accordingly. Specifically, if the network address of the client is in the preset region corresponding to the second language, it can be determined that the first text needs to be translated from the first language to the second language. Exemplarily, if most people in countries A and B speak Chinese and English respectively, use (such as reading and writing) Chinese and English, and the text in the page content displayed by the client is in Chinese by default. In this scenario, if user U uses the client to initiate a request message to the server in country B, the gateway device can determine that the client is located in country B based on the network address recorded in the header of its message, indicating that user U is located in an English-speaking country; further, after parsing the page content from the first response message returned from the server, if the page content contains a Chinese article, the gateway device can determine that the Chinese article needs to be translated into an English article. In this way, the gateway device can automatically identify whether the first text needs to be translated and the language into which it should be translated (i.e., determine the specific language of the second language) according to the region where the client is located, without the client actively requesting translation. This solution does not require the message structure of the request message to be modified, and is easy to promote and apply for messages that are compatible with existing structures.
[0041] As mentioned above, when it is determined that the first text needs to be translated, the gateway device needs to translate the text into a second text in a second language. There are many ways to achieve the translation.
[0042] In one embodiment, a translation service component may be deployed in the gateway device, and the component is used to implement the aforementioned text translation function; based on this, the gateway device may call the translation service component to translate the first text into the second text in the second language. Correspondingly, a forwarding service component may also be deployed in the gateway device to implement the aforementioned message forwarding function. In this way, the text translation function of the gateway device is integrated into a translation service component, so that the text translation function and the message forwarding function simultaneously possessed by the device are mutually independent (similar to the concept of "function unloading"), and are respectively completed by different functional components, avoiding the mutual influence and possible interference between different functions, realizing the modular operation of the gateway device, and helping to improve its operating efficiency. It is understandable that, when a translation service component is deployed, the translation process described in the following embodiments of the present invention can be implemented by the component, and this is hereby explained.
[0043] In one embodiment, the gateway device may pre-associate translation lexicons corresponding to a plurality of languages, such as a Chinese lexicon corresponding to Chinese, an English lexicon corresponding to English, a Japanese lexicon corresponding to Japanese, and the like. Among them, the translation lexicon corresponding to any language may record the commonly used vocabulary of that language and translation rules with other languages, and the like. Based on this, the gateway device may search for a target translation lexicon corresponding to the second language from the above-mentioned multiple translation lexicons, and call the found target translation lexicon to translate the first text into a second text in the second language. For the specific translation process, please refer to the records in the relevant technology, which will not be repeated here. It can be understood that this method utilizes a preset translation lexicon (such as one that can be cached locally in the gateway device) to translate the first text, which can achieve rapid translation of the text, reduce the waiting time of the client, and help improve the user experience. Figure 3 As shown, assuming that the gateway device receives a request message 1 sent by the client, it can forward the message to the corresponding background service and receive the first response message returned by the latter; assuming that it is determined that the first text needs to be translated and the second language is English, the translation service component can search for an English translation word library from translation word libraries 1 to n, and further call the word library to translate the first text into a second text in English. The request message 1 and the interactive steps involved in its translation process can be found in Figure 3 Solid arrow shown.
[0044] In another embodiment, since the text translation technology itself is relatively mature, the gateway device can connect to at least one preset service interface provided by a third-party translation platform, so that the online translation service provided by the third-party translation platform can be called through the preset service interface to translate the first text into a second text in a second language. In this way, the gateway device does not need to maintain complex translation rules locally, but only needs to manage the preset service interface, so that the first text can be accurately translated based on the powerful translation capabilities of the third-party service platform. Figure 3 As shown, assuming that the gateway device receives the request message 2 sent by the client, it can forward the message to the corresponding background service and receive the first response message returned by the latter; assuming that it is determined that the first text needs to be translated and the second language is Japanese, the translation service component can call a third-party translation platform to translate the first text, that is, the first text can be sent to the third-party service platform for translation through the aforementioned preset service interface, and the translation result returned by the platform, that is, the translated second text in Japanese form, can be received. The request message 2 and the interactive steps involved in its translation process can be found in Figure 3 Shown by the dashed arrow.
[0045] As mentioned above, the gateway device can call the translation word library to translate the first text, or call a third-party translation platform to translate the first text. In this regard, the gateway device can set priorities for the above two methods.
[0046] In one embodiment, the gateway device may preferentially call a translation word library to translate the first text. If it is determined that the first text needs to be translated, an attempt may be made to find a target translation word library corresponding to the second language from translation words corresponding to a plurality of languages. Based on the consideration of saving local storage space of the gateway device, the gateway device may not maintain a target translation word library corresponding to the second language, that is, the target translation word library corresponding to the second language may not be found in the associated multiple translation word libraries. In this regard, if the target translation word library is found, the target translation word library may be called to translate the first text into a second text in a second language; and if the target translation word library is not found, the online translation service provided by a third-party translation platform may be further called through a preset service interface to re-translate the first text into a second text in a second language.
[0047] Alternatively, after finding the target translation word library and calling the word library to translate the first text into the second text, the gateway device can send a second response message containing the second text to the client, so that the client can display it to the user for viewing, and determine the user's adoption rate of the text based on the user's feedback operation. It is understandable that the lower the quality of the text translation (such as the more words with translation errors and the less fluent the sentences), the lower the possibility of the user adopting (or approving) the text (that is, the lower the adoption rate). The client can determine the results of user feedback through pop-up reminders, questionnaires, or user operations based on page embedding points, and calculate the user's adoption rate for the text accordingly. Furthermore, when the adoption rate is lower than the threshold (indicating that the second text quality obtained by calling the target translation word library is low), the online translation service provided by the third-party translation platform can be further called through the preset service interface to re-translate the first text into the second text of the second language.
[0048] Of course, for the second text obtained by re-translating by calling a third-party translation platform, the gateway device can send a second response message containing the second text to the client so that the client can display the text for the user to view / read. In this regard, the adoption rate of the client to the second text can be determined in the aforementioned manner. And in the case where the adoption rate is higher than a threshold value (indicating that the second text obtained by re-translating by calling a third-party translation platform has a higher quality), the target translation vocabulary corresponding to the second language can be updated according to the second text. In this way, when the translation quality of the target translation vocabulary cached locally is low and the translation quality of the third-party translation platform is high, the target translation vocabulary can be updated based on the translation result of the first text by the third-party translation platform to improve the translation quality of the vocabulary for subsequent texts.
[0049] In one embodiment, whether the second text is obtained by calling the target translation vocabulary or calling a third-party translation platform for translation, whether the second text is obtained by the first translation or the re-translation, its adoption rate can be determined in the above-mentioned manner. When the adoption rate of the second text (regardless of the second text translated by any of the above-mentioned methods) by the client is lower than the threshold value (indicating that the translation quality of the text is low), the gateway device can send a text correction reminder message to the client's management party (such as the operator or developer of the application program, etc.) to remind the management party to correct the second text. In this way, when the translation quality is low, the management party can be notified to intervene and actively correct the second text of low quality, such as correcting part of the text with translation errors, modifying typos, etc., to improve the quality of the displayed second text.
[0050] In one embodiment, the gateway device can use a variety of methods to send the second response message containing the second text to the client. For example, the first text in the first response message can be replaced with the second text (the message after replacement is the second response message), and the replaced second response message is sent to the client. At this time, the second response message only contains the second text obtained by translation, and does not contain the first text before translation. For another example, the second text can also be added to the first response message (the message after addition is the second response message), and the added second response message is sent to the client. At this time, the second response message contains both the second text and the first text, which is convenient for the client to display the text of the corresponding language on demand, such as realizing language switching. Among them, the above-mentioned "replacement" and "addition" can be performed on the message body of the first response message. The specific process can be referred to the records in the relevant technology, which will not be repeated here.
[0051] In one embodiment, the number of the second languages may be one or more. For example, when the number of the second languages is one, the gateway device may translate the first text into the second text of the language; and when the number of the second languages is multiple, the gateway device may translate the first text into the second text corresponding to each second language, that is, obtain multiple second texts. It is understandable that when the number of the second languages is multiple, the gateway device may include each second text in the second response message and send it to the client, so that the client can display the second text corresponding to any language on demand. For example, after receiving the second texts in English, Chinese and Japanese at the same time, the corresponding second text may be displayed according to the display language selected by the user (that is, the language to which the text the user wants to view belongs, such as selecting "Simplified Chinese" or "English" in the upper right corner of the page). It is understandable that, because the client has parsed the second languages from the second response message, even if the user switches the display language between the above-mentioned second languages, the client can immediately display the second text corresponding to the switched language without temporarily requesting the gateway device to translate, so that the page presents the effect of switching the display language instantly, further improving the user experience.
[0052] In one embodiment, in view of the fact that the aforementioned text translation requires the consumption of certain resources, the relevant parties may be charged for the aforementioned text translation service. For example, the gateway device may count the number of characters of the first text being translated, and send a charge reminder message for the number of characters to the pre-associated fee-related parties. Exemplarily, the charge reminder message may include an amount to be receivable, which is positively correlated with the number of characters, that is, the more characters translated, the higher the charge. The above-mentioned fee-related party may be the client, so that the user pays the corresponding translation fee according to the message; the above-mentioned fee-related party may also be the aforementioned third-party translation platform, so that the platform charges the operator of the application or the user of the client the corresponding translation fee, etc., which will not be repeated.
[0053] Figure 4 FIG. 1 is an interactive flow chart of a text translation method according to an embodiment of the present invention. Figure 4 As shown, the method includes the following steps 401-409.
[0054] Step 401: The client sends a request message to a gateway device.
[0055] Assume that the first language and the second language in the embodiment are Chinese and English respectively, which indicates that the client needs to display text in English. Based on this, when generating the request message, the client can add a language identifier such as "001" or "English" in the language type field of the message header to indicate to the gateway device that the second language is English.
[0056] Of course, if the client does not have a translation requirement, the value of the aforementioned language type field can be set to be empty or a preset value to indicate that the gateway device does not need to translate the first text in the first response message.
[0057] Step 402: The gateway device forwards the request message to the server.
[0058] Step 403: The server returns a response message to the gateway device.
[0059] Step 404: The gateway device parses the message header of the request message.
[0060] On the one hand, the gateway device needs to forward the request message to the server and receive the first response message returned by the server; on the other hand, it needs to parse the message header of the request message to determine whether the first text in the first response message needs to be translated based on the value of the aforementioned language type field.
[0061] It should be noted that there is no necessary order between step 402 and step 404, that is, the gateway device can parse the message header first and then forward the request message; it can also forward the request message first and then parse the message header (of course, the parsed message is a copy of the forwarded message), or even parse the message header after step 403 (that is, after receiving the first response message); step 402 and step 404 can also be executed separately by two different threads (or different processes), and the embodiments of the present invention are not limited to this.
[0062] Based on the value of the aforementioned language type field obtained by parsing the message header, the gateway device can determine whether the first text in the first response message needs to be translated. If the field value is the aforementioned "001" or "English", it indicates that the first text needs to be translated into the second text in English, and then the process goes to step 405; if the aforementioned field value is empty or a preset value, it indicates that the first text does not need to be translated, and then the process goes to step 409.
[0063] Step 405: The gateway device parses the first response message to obtain a first text to be translated.
[0064] Step 406: The gateway device translates the first text to obtain a second text in a second language.
[0065] Step 407: The gateway device reassembles the second response message including the second text.
[0066] Step 408: The gateway device sends a second response message to the client.
[0067] After parsing the first response message to obtain the first text, the gateway device can call the target translation dictionary or a third-party translation platform to translate the text into a second text (i.e., English). Furthermore, a second response message containing the second text can be obtained by replacing the first text in the first response message with the second text or adding the second text to the first response message, and the second response message is further sent to the client as a response to the request message in step 401. The specific process of translating the first text and reorganizing the second response message can be found in the records of the previous embodiment, which will not be repeated here.
[0068] Step 409: The gateway device forwards the first response message to the client.
[0069] In the case where the first text does not need to be translated, the gateway device does not need to parse the first response message and can directly forward the message to the client as a response to the request message in step 401.
[0070] Figure 5is a schematic structural diagram of an electronic device shown in an embodiment of the present invention. Figure 5 At the hardware level, the device includes a processor 501, a network interface 502, a memory 503, a non-volatile memory 504, and an internal bus 505, and may also include hardware required for other services. The embodiment of the present invention can be implemented based on software, such as the processor 501 reading the corresponding computer program from the non-volatile memory 504 to the memory 503 and then running it. Of course, in addition to the software implementation, the embodiment of the present invention does not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0071] Figure 6 A block diagram of a text translation device shown in an embodiment of the present invention. Figure 6 , the device can be applied to Figure 5 In the device shown, in order to implement the technical solution described in the present invention, the device is applied to a gateway device, and the device includes:
[0072] The message forwarding unit 601 is used to forward the request message sent by the client to the corresponding server, and receive a first response message returned by the server, wherein the first response message includes a first text in a first language;
[0073] The text translation unit 602 is configured to translate the first text into a second text in a second language when it is determined that the first text needs to be translated, and send a second response message containing the second text to the client.
[0074] Optionally, the text translation unit 602 is specifically used for:
[0075] If the message header of the request message records the language identifier of the second language, it is determined that the first text needs to be translated from the first language to the second language; or,
[0076] If the network address of the client is within the preset region corresponding to the second language, it is determined that the first text needs to be translated from the first language to the second language.
[0077] Optionally, the text translation unit 602 is specifically used for:
[0078] searching for a target translation word library corresponding to the second language from translation word libraries corresponding to multiple languages, and calling the found target translation word library to translate the first text into a second text in a second language; or,
[0079] An online translation service provided by a third-party translation platform is called through a preset service interface to translate the first text into a second text in a second language.
[0080] Optionally, the text translation unit 602 is specifically used for:
[0081] Trying to find a target translation word library corresponding to the second language from translation word libraries corresponding to multiple languages, and if the target translation word library is found, calling the target translation word library to translate the first text into a second text in the second language;
[0082] When the target translation vocabulary is not found or the second text translated by calling the target translation vocabulary is not adopted by the client, an online translation service provided by a third-party translation platform is called through a preset service interface to re-translate the first text into a second text in a second language.
[0083] Optionally, also include:
[0084] The word library updating unit 603 is used to update the target translation word library corresponding to the second language according to the second text when the adoption rate of the second text re-translated by calling the online translation service at the client is higher than a threshold.
[0085] Optionally, also include:
[0086] The correction reminder unit 604 is used to send a text correction reminder message to the manager of the client to remind the manager to correct the second text when the adoption rate of the second text by the client is lower than a threshold.
[0087] Optionally, the text translation unit 602 is specifically used for:
[0088] replacing the first text in the first response message with the second text, and sending the replaced second response message to the client; or,
[0089] The second text is added to the first response message, and the added second response message is sent to the client.
[0090] Optionally, also include:
[0091] The response message forwarding unit 605 is used to forward the first response message to the client when it is determined that the first text does not need to be translated.
[0092] Optionally, also include:
[0093] The charging reminder unit 606 is used to count the number of characters of the first text translated, and send a charging reminder message for the number of characters to the pre-associated fee-related party.
[0094] Optionally, a translation service component is deployed in the gateway device, and the text translation unit 602 is specifically used for:
[0095] The translation service component is called to translate the first text into a second text in a second language.
[0096] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0097] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. Ordinary technicians in this field can understand and implement it without paying creative work.
[0098] The present specification also provides a computer-readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the steps of the method described in any of the aforementioned embodiments provided by the present invention are implemented.
[0099] Specifically, computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media and memory devices, including, for example, semiconductor memory devices (such as EPROM, EEPROM and flash memory devices), magnetic disks (such as internal hard disks or removable disks), magneto-optical disks, and CD ROM and DVD-ROM disks.
[0100] The present specification also provides a computer program product, including a computer program and / or instructions, which implement the steps of the method described in any of the aforementioned embodiments when executed by a processor.
Claims
1. A text translation method, characterized in that: Applied to a gateway device, the method comprises: Forwarding a request message sent by a client to a corresponding server, and receiving a first response message returned by the server, wherein the first response message includes a first text in a first language; In the case where it is determined that the first text needs to be translated, the first text is translated into a second text in a second language, and a second response message including the second text is sent to the client.
2. The method according to claim 1, characterized in that The determining that the first text needs to be translated includes: If the message header of the request message records the language identifier of the second language, it is determined that the first text needs to be translated from the first language to the second language; or, If the network address of the client is within the preset region corresponding to the second language, it is determined that the first text needs to be translated from the first language to the second language.
3. The method according to claim 1, characterized in that The translating the first text into a second text in a second language comprises: Searching for a target translation word library corresponding to the second language from translation word libraries corresponding to multiple languages, and calling the found target translation word library to translate the first text into a second text in a second language; or An online translation service provided by a third-party translation platform is called through a preset service interface to translate the first text into a second text in a second language.
4. The method according to claim 1, characterized in that: The translating the first text into a second text in a second language comprises: Trying to find a target translation word library corresponding to the second language from translation word libraries corresponding to multiple languages, and if the target translation word library is found, calling the target translation word library to translate the first text into a second text in the second language; When the target translation vocabulary is not found or the second text translated by calling the target translation vocabulary is not adopted by the client, an online translation service provided by a third-party translation platform is called through a preset service interface to re-translate the first text into a second text in a second language.
5. The method according to claim 4, characterized in that Also includes: When the adoption rate of the second text re-translated by calling the online translation service at the client is higher than a threshold, the target translation word library corresponding to the second language is updated according to the second text.
6. The method according to claim 1, characterized in that Also includes: When the adoption rate of the second text by the client is lower than a threshold, a text correction reminder message is sent to the manager of the client to remind the manager to correct the second text.
7. The method according to claim 1, characterized in that The sending the second response message including the second text to the client includes: replacing the first text in the first response message with the second text, and sending the replaced second response message to the client; or, The second text is added to the first response message, and the added second response message is sent to the client.
8. The method according to claim 1, characterized in that Also includes: When it is determined that the first text does not need to be translated, the first response message is forwarded to the client.
9. The method according to claim 1, characterized in that: Also includes: The number of characters of the first text translated is counted, and a charging reminder message for the number of characters is sent to a pre-associated fee-related party.
10. The method according to any one of claims 1 to 9, characterized in that The gateway device is provided with a translation service component, and the translating the first text into a second text in a second language includes: The translation service component is called to translate the first text into a second text in a second language.
11. A text translation device, characterized in that: Applied to a gateway device, the device comprises: a message forwarding unit, configured to forward a request message sent by a client to a corresponding server, and receive a first response message returned by the server, wherein the first response message includes a first text in a first language; A text translation unit is used to translate the first text into a second text in a second language when it is determined that the first text needs to be translated, and send a second response message containing the second text to the client.
12. An electronic device comprising: processor; A memory for storing processor-executable instructions; wherein the processor implements the method according to any one of claims 1 to 10 by executing the executable instructions.
13. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 10.