Request processing method, apparatus and system, electronic device, and storage medium
By using decorators to translate request parameters on the front-end device, the translation failure problem caused by the lack of internationalization capabilities on the server side is solved. This enables translation to be completed on the front-end device, reducing the communication cost between the front-end and back-end and improving the flexibility and security of request processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING BAIDU NETCOM SCI & TECH CO LTD
- Filing Date
- 2022-03-11
- Publication Date
- 2026-07-10
AI Technical Summary
In existing technologies, the lack of internationalization capabilities on the server side leads to translation failures and high communication costs between the front-end and back-end.
When the front-end device generates the initial request, it attaches configuration information through decorators to determine whether to translate the request parameters, generates the target request and sends it to the server, thus avoiding direct translation by the server.
Completing translation on the front end avoids translation failures caused by the server's inability to support internationalization, reduces communication costs between the front end and back end, and improves the flexibility and security of request processing.
Smart Images

Figure CN114595704B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing technology, and more particularly to the field of cloud computing, providing a request processing method, apparatus and system, electronic device and storage medium. Background Technology
[0002] Internationalization technology refers to translating browser page content and presenting different language interfaces based on different language environments. For example, due to the increasing number of international users, the console interfaces of various cloud providers now offer support for multiple languages. Similarly, the documentation for various open-source tools typically provides multilingual versions.
[0003] Currently, a project often aggregates multiple services, and these services may not have a gateway to uniformly control the content of requests and responses. If a third-party service lacks internationalization features, or if the business logic heavily relies on Chinese characters, the service's external interfaces may not provide timely support. Summary of the Invention
[0004] This disclosure provides a request processing method, apparatus and system, electronic device and storage medium.
[0005] According to a first aspect of this disclosure, a request processing method is provided, comprising: obtaining an initial request generated by a front-end device, wherein the initial request is appended with a decorator; determining whether to translate request parameters of the initial request based on configuration information corresponding to the decorator; generating a target request based on the translated first parameter in response to translating the request parameters; and sending the target request to a server.
[0006] According to a second aspect of this disclosure, a request processing apparatus is provided, comprising: an acquisition module for acquiring an initial request generated by a front-end device, wherein the initial request is appended with a decorator; a first determination module for determining, based on configuration information corresponding to the decorator, whether to translate the request parameters of the initial request; a first translation module for generating a target request based on the translated first parameters in response to translating the request parameters; and a request sending module for sending the target request to a server.
[0007] According to a third aspect of this disclosure, a request processing system is provided, comprising: a front-end device for generating an initial request, wherein a decorator is attached to the initial request; a processor connected to the front-end device for determining, based on configuration information corresponding to the decorator, whether to translate request parameters of the initial request; and, in response to translating the request parameters, generating a target request based on the translated first parameter; and a server connected to the processor for receiving the target request.
[0008] According to a fourth aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the methods described above.
[0009] According to a fifth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause a computer to perform the methods described above.
[0010] According to a sixth aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method described above.
[0011] In the embodiments described above, after the front-end device generates an initial request, it can determine whether to translate the request parameters of the initial request based on the configuration information corresponding to the decorator. In response to translating the request parameters, a target request is generated based on the translated first parameter and sent to the server, thereby achieving the purpose of translating the text in the front-end interface. It is noteworthy that because the initial request is appended with a decorator, the translation can be completed on the front-end device without relying on the server. This avoids translation failures due to server inability to support internationalization, and reduces communication costs between the front-end and back-end regarding internationalization issues. This solves the technical problem in related technologies where translation fails due to server inability to support internationalization.
[0012] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0013] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0014] Figure 1 This is a flowchart of a request processing method according to an embodiment of the present disclosure;
[0015] Figure 2 This is a flowchart of an optional request processing method according to an embodiment of the present disclosure;
[0016] Figure 3 This is a structural diagram of a request processing apparatus according to an embodiment of the present disclosure;
[0017] Figure 4 This is a structural diagram of a request processing system according to an embodiment of the present disclosure;
[0018] Figure 5 This is a block diagram of an electronic device used to implement the request processing method of the embodiments of this disclosure. Detailed Implementation
[0019] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0020] Currently, internationalization technology is mainly achieved through the following solutions: The first is direct server-side translation, where the client informs the server of the language environment. For HTTP services, the language environment can be passed through query parameters or request headers. The server then processes the returned text after obtaining the language environment. The second is libraries with built-in template parsing and filter support, such as Vue and San, which can use template filters to process the text.
[0021] However, for the first option, the server-side may not be controllable, the third-party server may not have internationalization capabilities, and the internationalization solution may not be universally applicable. Different services may enable internationalization in different ways, and the front-end needs to adapt to different methods. If a secondary encapsulation is performed through a server with internationalization capabilities, there are certain modification costs. The cost of modifying the server-side is often greater than that of the front-end, and it is somewhat intrusive to the logic.
[0022] The second approach has many limitations: it heavily relies on the library used, cannot process text outside the template, and can only process the returned text, not actively submit the translated text to the server.
[0023] The main focus of this disclosure is on how to handle the text in the front-end interface, which differs from the two solutions mentioned above and focuses on sending and receiving requests.
[0024] According to embodiments of this disclosure, a request processing method is provided. It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowcharts, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0025] Figure 1 This is a flowchart of a request processing method according to an embodiment of the present disclosure, such as... Figure 1 As shown, the method includes:
[0026] Step S102: Obtain the initial request generated by the front-end device, wherein the initial request is decorated with a decorator.
[0027] The front-end device in the above steps can be a smartphone (Android phone and iPhone), tablet computer (Android tablet, iPad), PDA, laptop computer, PC, etc. with a browser installed. This disclosure does not make any specific limitation in this regard.
[0028] The initial request in the above steps can be an access request generated by a user accessing a webpage in their browser. This request can be decorated with a decorator, which depends on ES7 decorators and provides functionality similar to an interceptor.
[0029] In one alternative embodiment, a user can browse a webpage on a front-end device. The front-end device encapsulates a Promise, such as axios, through a requester to generate an initial request and attaches a decorator to the request. This allows the initial request to be intercepted and the decorator's execution logic to be executed before the front-end device sends the initial request.
[0030] Step S104: Based on the configuration information corresponding to the decorator, determine whether to translate the request parameters of the initial request.
[0031] The configuration information in the above steps can be the pre-configured decorator configuration items for implementing the copy in the front-end processing interface. The specific configuration process can include: configuring the copy to be translated and the translated content. The array format is: source: the copy to be translated, in regular expression format; target: the translated content; specifying the language environment; specifying the effective time, such as response or request; specifying the translation method, which is optional and can be regular expression replacement by default.
[0032] In an optional embodiment, since the configuration information specifies the timing of translation activation, it can be determined whether the request parameters of the initial request need to be translated based on the configuration information. If the timing of translation activation is "request", then the request parameters are translated; if the timing of translation activation is "response", then the request parameters are not translated.
[0033] Step S106: In response to translating the request parameters, a target request is generated based on the translated first parameter.
[0034] In one optional embodiment, after determining that the request parameters need to be translated, since the configuration information specifies the locale and the text to be translated, the text to be translated can be determined first based on the configuration information. Then, the text to be translated can be translated based on the translation method specified in the configuration information to obtain the translated first parameter. Furthermore, since the text to be translated is often not all the parameters of the initial request, a target request can be generated based on the translated first parameter and the other untranslated parameters; that is, the text to be translated in the initial request is replaced with the first parameter.
[0035] Step S108: Send the target request to the server.
[0036] The server mentioned in the above steps can be the web server that the user needs to access, and the specific server can be determined based on the user's actual access situation.
[0037] In one optional embodiment, the text in the front-end interface is translated; that is, after generating the first parameter, the newly generated target request can be sent to the server corresponding to the target request. It should be noted that since only the request parameters are translated, and the request parameters are identical, the initial request and the target request are sent to the same server.
[0038] The solution provided by the above embodiments of this disclosure allows for the translation of request parameters of the initial request based on the configuration information corresponding to the decorator after the front-end device generates an initial request. In response to translating the request parameters, a target request is generated based on the translated first parameter and sent to the server, thus achieving the purpose of translating the text in the interface on the front end. It is noteworthy that because the initial request is appended with a decorator, the translation can be completed on the front-end device without server intervention, avoiding translation failures due to server incompatibility with internationalization. This also reduces communication costs between the front-end and back-end regarding internationalization issues, thereby solving the technical problem of translation failures caused by server incompatibility with internationalization in related technologies.
[0039] In the above embodiments of this disclosure, determining whether to translate the request parameters of the initial request based on the configuration information corresponding to the decorator includes: obtaining the effective timing contained in the configuration information; if the effective timing is the request phase, then determining to translate the request parameters; if the effective timing is the response phase, then determining not to translate the request parameters.
[0040] The aforementioned effective timing can be when the text in the interface needs to be translated on the front end, which can be either a request or a response.
[0041] In one optional embodiment, the user-preconfigured activation timing can be read from the configuration information. If the activation timing is "request", it indicates that the request parameters need to be translated; if the activation timing is "response", it indicates that the result parameters need to be translated. Therefore, it is not necessary to translate the request parameters of the initial request.
[0042] By following the steps above and configuring the effective timing in the configuration information, the text in the front-end request processing can be modified, thereby improving the flexibility of request processing.
[0043] In the above embodiments of this disclosure, responding to the translation of request parameters includes: obtaining a translation method contained in configuration information; translating the request parameters using the translation method to generate a first parameter.
[0044] The translation methods described above can be pre-configured by the user according to their translation needs. Users can choose not to specify a translation method and the translation will be performed according to the default regular expression replacement method.
[0045] In one optional embodiment, since a translation method is specified in the configuration information, or no translation method is specified, the request parameters can be translated based on the specified translation method to generate the first parameter, or the request parameters can be translated based on regular expression substitution to generate the first parameter.
[0046] By following the steps above and configuring translation methods in the configuration information, the application scope of the configuration information is expanded, and the flexibility of translating requests in the front end is increased.
[0047] In the above embodiments of this disclosure, before translating the request parameters, the method further includes: performing a validity check on the configuration information; and, in response to the configuration information passing the verification, translating the request parameters based on the translation method to generate a first parameter.
[0048] In one optional embodiment, before translating the request parameters, the configuration information needs to be validated for legality. Specifically, the validation method provided in related technologies can be used for validation, and this disclosure does not make specific limitations on this. If the configuration information validation passes, the request parameters can be translated based on the translation method contained in the configuration information; if the configuration information validation fails, no processing of the request parameters is required.
[0049] By performing the above steps to verify the validity of the configuration information, the security of request processing is improved.
[0050] In the above embodiments of this disclosure, the method further includes: receiving an initial response returned by a server; determining, based on configuration information, whether to translate the result parameters of the initial response; in response to translating the result parameters, generating a target response based on the translated second parameters; and sending the target response to a front-end device.
[0051] The initial response described above can be the result returned by the server in response to the user's browsing needs. Regardless of whether the initial request is translated, the result returned by the server will be the same.
[0052] In one alternative embodiment, if it is determined that the request parameters need to be translated based on the effective timing contained in the configuration information, a target request can be sent to the server; if it is determined that the request parameters do not need to be translated based on the effective timing contained in the configuration information, an original request can be sent. Since the target request and the original request are the same, the server can return the same result, that is, return the initial response.
[0053] Similar to the initial request processing process, it can be determined whether the result parameters of the initial response need to be translated based on the effective timing contained in the configuration information. If the effective timing is "request", then there is no need to translate the initial response, and the initial response can be directly returned to the front-end device for the front-end device to display to the user.
[0054] If the response is the trigger point, the initial response needs to be translated. Since the configuration information specifies the locale and the text to be translated, the text to be translated can be determined first based on the configuration information. Then, the text to be translated can be translated using the translation method specified in the configuration information to obtain the translated second parameter. Furthermore, since the text to be translated is often not all the parameters of the initial request, the target response can be generated based on the translated second parameter and the other untranslated parameters. That is, the text to be translated in the initial response is replaced with the second parameter, and the target response is returned to the front-end device for display to the user.
[0055] By following the steps above and using the decorator configuration information, the text in the interface can be translated on the front end without going through the server. This avoids the server's inability to support internationalization, which could lead to translation failures, and also reduces the communication costs between the front end and the back end regarding internationalization issues.
[0056] In the above embodiments of this disclosure, determining whether to translate the result parameters of the initial response based on the configuration information includes: obtaining the effective timing contained in the configuration information; if the effective timing is in the request phase, then determining not to translate the result parameters; if the effective timing is in the response phase, then determining to translate the result parameters.
[0057] In one optional embodiment, the user-preconfigured activation timing can be read from the configuration information. If the activation timing is "request", it indicates that no translation of the result parameters is required, and therefore, no translation of the result parameters of the initial response is required. If the activation timing is "response", it indicates that the result parameters need to be translated.
[0058] By following the steps above and configuring the effective timing in the configuration information, the text in the response can be processed on the front end, improving the flexibility of request processing.
[0059] In the above embodiments of this disclosure, responding to the translation of the result parameter includes: obtaining the translation method contained in the configuration information; translating the result parameter based on the translation method to generate a second parameter.
[0060] In one optional embodiment, since the translation method is specified in the configuration information, or if no translation method is specified, the result parameter can be translated based on the specified translation method to generate the second parameter, or the response parameter can be translated based on regular expression substitution to generate the second parameter.
[0061] By following the steps above and configuring translation methods in the configuration information, the application scope of the configuration information is expanded, and the flexibility of translating responses in the front end is increased.
[0062] In the above embodiments of this disclosure, before translating the result parameter, the method further includes: performing a validity check on the configuration information; and, in response to the configuration information passing the verification, translating the result parameter based on the translation method to generate a second parameter.
[0063] In one optional embodiment, before translating the result parameters, the configuration information needs to be validated for legality. Specifically, the validation method provided in related technologies can be used for validation, and this disclosure does not make specific limitations on this. If the configuration information validation passes, the result parameters can be translated based on the translation method contained in the configuration information; if the configuration information validation fails, no processing is required on the result parameters.
[0064] By performing the above steps to verify the validity of the configuration information, the security of response processing is improved.
[0065] The following is combined with Figure 2 A preferred embodiment of this disclosure will be described in detail, such as... Figure 2 As shown, the method includes:
[0066] Step S21: Configure the decorator configuration items, that is, configure the decorator configuration information;
[0067] In step S22, the requester needs to wrap a Promise, such as axios, and attach a decorator above the request.
[0068] Step S23: Is the translation timing a request? If yes, proceed to step S24; otherwise, proceed to step S26.
[0069] Step S24: Verify the legality of the translation configuration, that is, verify the legality of the decorator's configuration information. If it is legal, proceed to step S25; otherwise, proceed to step S26.
[0070] Step S25, translate the request parameters;
[0071] Optionally, the request parameters can be translated based on the decorator configuration items, and the target request can be generated based on the translated content.
[0072] Step S26, request successful;
[0073] Optionally, if the request parameters are not translated, the initial request is sent directly to the server; if the request parameters are translated, the target request is sent to the server. Additionally, if the request fails, subsequent processing ends.
[0074] Step S27: Is the translation timing a response? If yes, proceed to step S28. If no, return the initial response to the front-end device, which will then display it to the customer.
[0075] Step S28: Verify the legality of the translation configuration. That is, verify the legality of the decorator's configuration information. If it is legal, proceed to step S29. If it is not legal, return the initial response to the front-end device, which will then display it to the client.
[0076] Step S29, Translation result parameters;
[0077] Optionally, the resulting parameters are translated based on the decorator configuration items, and a target response is generated based on the translated content. The target response is then returned to the front-end device for display to the client.
[0078] The above solution reduces communication costs between the front-end and back-end regarding internationalization issues; it provides a fallback solution when the server is unsure whether it can support internationalization; unlike traditional solutions, this solution offers the fastest fallback support; the decorator allows for easy plug-and-play functionality; and it provides multilingual support.
[0079] According to embodiments of this disclosure, a request processing apparatus is provided for implementing the above embodiments and preferred embodiments, and details already described will not be repeated. As used below, the terms "module" and "unit" can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0080] Figure 3 This is a structural diagram of a request processing apparatus according to an embodiment of the present disclosure, such as... Figure 3 As shown, the device includes:
[0081] The acquisition module 32 is used to acquire the initial request generated by the front-end device, wherein the initial request is attached with a decorator;
[0082] The first determining module 34 is used to determine whether to translate the request parameters of the initial request based on the configuration information corresponding to the decorator.
[0083] The first translation module 36 is used to generate a target request based on the translated first parameter in response to translating the request parameter.
[0084] The request sending module 38 is used to send the target request to the server.
[0085] In the above embodiments of this disclosure, the first determining module includes: a first timing acquisition unit, configured to acquire the effective timing contained in the configuration information; a first determining unit, configured to determine to translate the request parameters in response to the effective timing being a request phase; and a second determining unit, configured to determine not to translate the request parameters in response to the effective timing being a response phase.
[0086] In the above embodiments of this disclosure, the first translation module includes: a first method acquisition unit, used to acquire a translation method contained in configuration information; and a first translation unit, used to translate the request parameters through the translation method to generate a first parameter.
[0087] In the above embodiments of this disclosure, the device further includes: a verification module for verifying the legality of the configuration information; and a first translation unit for translating the request parameters based on a translation method to generate a first parameter in response to the configuration information verification passing.
[0088] In the above embodiments of this disclosure, the device further includes: a receiving module for receiving an initial response returned by a server; a second determining module for determining, based on configuration information, whether to translate the result parameters of the initial response; a second translating module for generating a target response based on the translated second parameters in response to translating the result parameters; and a response sending module for sending the target response to a front-end device.
[0089] In the above embodiments of this disclosure, the second determining module includes: a first timing acquisition unit, used to acquire the effective timing contained in the configuration information; a third determining unit, used to determine that the result parameters are not translated if the effective timing is in the request stage; and a fourth determining unit, used to determine that the result parameters are translated if the effective timing is in the response stage.
[0090] In the above embodiments of this disclosure, the second translation module includes: a second method acquisition unit, used to acquire a translation method contained in the configuration information; and a second translation unit, used to translate the result parameters based on the translation method to generate a second parameter.
[0091] In the above embodiments of this disclosure, the device further includes: a verification module for verifying the legality of the configuration information; and a second translation unit for translating the result parameters based on a translation method to generate a second parameter in response to the configuration information verification passing.
[0092] According to embodiments of this disclosure, a request processing system is provided to implement the above embodiments and preferred embodiments, and details already described will not be repeated.
[0093] Figure 4 This is a structural diagram of a request processing system according to an embodiment of the present disclosure, such as... Figure 5 As shown, the system includes:
[0094] Front-end device 42 is used to generate an initial request, which is decorated with a decorator.
[0095] Processor 44, connected to the front-end device, is used to determine whether to translate the request parameters of the initial request based on the configuration information corresponding to the decorator; in response to translating the request parameters, it generates a target request based on the translated first parameter;
[0096] Server 46, connected to the processor, is used to receive target requests.
[0097] In the above embodiments of this disclosure, the processor is further configured to obtain the effective timing contained in the configuration information; if the effective timing is a request phase, it determines to translate the request parameters; if the effective timing is a response phase, it determines not to translate the request parameters.
[0098] In the above embodiments of this disclosure, the processor is further configured to obtain the translation method contained in the configuration information, and translate the request parameters using the translation method to generate the first parameter.
[0099] In the above embodiments of this disclosure, the processor is further configured to perform legality verification on the configuration information, and in response to the configuration information verification passing, translate the request parameters based on the translation method to generate the first parameter.
[0100] In the above embodiments of this disclosure, the server is further configured to send an initial response to the processor; the processor is further configured to determine, based on configuration information, whether to translate the result parameters of the initial response, and in response to translating the result parameters, generate a target response based on the translated second parameters; the front-end device is further configured to receive the target response.
[0101] In the above embodiments of this disclosure, the processor is further configured to obtain the effective timing contained in the configuration information, and in response to the effective timing being the request stage, determine that the result parameters are not translated; in response to the effective timing being the response stage, determine that the result parameters are translated.
[0102] In the above embodiments of this disclosure, the processor is further configured to obtain the translation method contained in the configuration information, and translate the result parameters based on the translation method to generate a second parameter.
[0103] In the above embodiments of this disclosure, the processor is further configured to perform legality verification on the configuration information, and in response to the configuration information verification passing, translate the result parameters based on the translation method to generate a second parameter.
[0104] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0105] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0106] like Figure 5As shown, device 500 includes a computing unit 501, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 502 or a computer program loaded from storage unit 508 into random access memory (RAM) 503. RAM 503 may also store various programs and data required for the operation of device 500. The computing unit 501, ROM 502, and RAM 503 are interconnected via bus 504. Input / output (I / O) interface 505 is also connected to bus 504.
[0107] Multiple components in device 500 are connected to I / O interface 505, including: input unit 506, such as keyboard, mouse, etc.; output unit 507, such as various types of monitors, speakers, etc.; storage unit 508, such as disk, optical disk, etc.; and communication unit 509, such as network card, modem, wireless transceiver, etc. Communication unit 509 allows device 500 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0108] The computing unit 501 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 501 performs the various methods and processes described above, such as request processing methods. For example, in some embodiments, the request processing method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on device 500 via ROM 502 and / or communication unit 509. When the computer program is loaded into RAM 503 and executed by the computing unit 501, one or more steps of the request processing method described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform request processing methods by any other suitable means (e.g., by means of firmware).
[0109] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0110] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0111] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0112] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0113] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0114] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0115] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0116] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A request processing method, comprising: After a user browses a webpage on a front-end device, the initial request generated by the front-end device is obtained, wherein the initial request is appended with a decorator; Based on the configuration information corresponding to the decorator, determine whether to translate the request parameters of the initial request; In response to translating the request parameters, the text to be translated is determined based on the configuration information; the text to be translated is translated based on the translation method in the configuration information to obtain the translated first parameter; a target request is generated based on the translated first parameter and other untranslated parameters in the initial request. Send the target request to the server; The method further includes configuring the decorator; Configuring the decorator includes: configuring the text to be translated and the translated content, wherein the text to be translated is located in the initial request; specifying the language environment; specifying the effective time; and specifying the translation method; Based on the configuration information corresponding to the decorator, determining whether to translate the request parameters of the initial request includes: obtaining the effective timing contained in the configuration information; in response to the effective timing being the request phase, determining to translate the request parameters; in response to the effective timing being the response phase, determining not to translate the request parameters. Before translating the request parameters, the method further includes: performing a validity check on the configuration information; and, in response to the configuration information passing the verification, translating the request parameters based on the translation method to generate the first parameter. The method further includes: receiving an initial response returned by the server; determining, based on the configuration information, whether to translate the result parameters of the initial response; in response to translating the result parameters, generating a target response based on the translated second parameters, and sending the target response to the front-end device; in response to not translating the result parameters, sending the initial response to the front-end device, and displaying the initial response to the user through the front-end device.
2. The method according to claim 1, wherein, In response to translating the request parameters, the following are included: Obtain the translation method contained in the configuration information; The request parameters are translated using the translation method to generate the first parameter.
3. The method according to claim 1, wherein, Based on the configuration information, determining whether to translate the result parameters of the initial response includes: Obtain the effective timing contained in the configuration information; If the effective timing is a request phase, then it is determined that the result parameters will not be translated; If the effective timing is in the response phase, then it is determined that the result parameters will be translated.
4. The method according to claim 1, wherein, In response to translating the resulting parameters, the following are included: Obtain the translation method contained in the configuration information; The result parameter is translated using the translation method to generate the second parameter.
5. The method of claim 4, further comprising, before translating the resulting parameter: The configuration information is validated for legality. In response to the configuration information verification passing, the result parameter is translated based on the translation method to generate the second parameter.
6. A request processing apparatus, comprising: The acquisition module is used to acquire the initial request generated by the front-end device after the user browses the webpage on the front-end device, wherein the initial request is attached with a decorator; The first determining module is used to determine whether to translate the request parameters of the initial request based on the configuration information corresponding to the decorator. The first translation module is configured to respond to the translation of the request parameters by determining the text to be translated based on the configuration information; translating the text to be translated based on the translation method in the configuration information to obtain the translated first parameter; and generating a target request based on the translated first parameter and other untranslated parameters in the initial request. Request sending module, used to send the target request to the server; The first determining module is also used to configure the decorator; The first determining module is further configured to configure the data format of the text to be translated, configure the data format of the translated content, wherein the text to be translated is located in the initial request; specify the language environment; specify the effective time; and specify the translation method; The first determining module is further configured to obtain the effective timing contained in the configuration information; in response to the effective timing being a request phase, determine to translate the request parameters; in response to the effective timing being a response phase, determine not to translate the request parameters. The first translation module is further configured to perform a validity check on the configuration information; in response to the configuration information passing the verification, the module translates the request parameters based on the translation method to generate the first parameter; The device further includes: a receiving module for receiving an initial response returned by the server; a second determining module for determining, based on the configuration information, whether to translate the result parameters of the initial response; a second translating module for generating a target response based on the translated second parameters in response to translating the result parameters; a response sending module for sending the target response to the front-end device; the response sending module is also configured to send the initial response to the front-end device in response to not translating the result parameters, and to display the initial response to the user through the front-end device.
7. A request processing system, comprising: A front-end device is used to generate an initial request after a user browses a webpage, wherein the initial request is appended with a decorator; A processor, connected to the front-end device, is configured to determine whether to translate the request parameters of the initial request based on the configuration information corresponding to the decorator; in response to translating the request parameters, determine the text to be translated based on the configuration information; translate the text to be translated based on the translation method in the configuration information to obtain the translated first parameter; and generate a target request based on the translated first parameter and other untranslated parameters in the initial request. A server, connected to the processor, is used to receive the target request; The front-end device is also used to configure the decorator; The front-end device is also used to configure the text to be translated and the translated content, wherein the text to be translated is located in the initial request; specify the language environment; specify the effective time; and specify the translation method; The processor is further configured to obtain the effective timing contained in the configuration information; in response to the effective timing being a request phase, determine to translate the request parameters; in response to the effective timing being a response phase, determine not to translate the request parameters. The processor is further configured to perform a validity check on the configuration information; in response to the configuration information passing the verification, to translate the request parameters based on the translation method to generate the first parameter; The processor is also configured to receive an initial response returned by the server; based on the configuration information, determine whether to translate the result parameters of the initial response; in response to translating the result parameters, generate a target response based on the translated second parameters; The front-end device is also used to receive the target response; The processor is also configured to send the initial response to the front-end device in response to not translating the result parameters; The front-end device is also used to display the initial response to the user.
8. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-5.
9. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-5.
10. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-5.