Information display method and server

By defining enumeration classes and data instances in the target application, conversion of multi-language environments is achieved, which solves the problem of high maintenance costs of international code in software international development, simplifies the international development process, and reduces maintenance costs.

CN118626191APending Publication Date: 2024-09-10XFUSION DIGITAL TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410788943.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-18
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

In the process of software internationalization development, each additional internationalization code needs to write corresponding information to each internationalization configuration file, resulting in increased workload and high maintenance costs.

Method used

By defining an enumeration class in the executable file of the target application, using data instances to achieve conversion to multiple language environments, directly returning feedback content in the front-end language environment, avoiding additional configuration of internationalization exception status codes and configuration files, and simplifying internationalization development work.

Benefits of technology

It simplifies international development, reduces international file maintenance costs, improves development efficiency, and avoids the maintenance burden of multiple international files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626191A
    Figure CN118626191A
Patent Text Reader

Abstract

The information display method comprises the following steps: receiving a first request sent by a front end for a target application program; acquiring a language environment of a front end; in response to the first request, first display information is sent to the front end, the first display information comprises first feedback content, and the language of the first feedback content is matched with the language environment of the front end; wherein the file associated with the target application program comprises a first data instance, the first data instance indicates the feedback content corresponding to the first feedback information in the multi-language environment, and the first feedback content is one of the feedback content in the multi-language environment. The data organization is carried out through the data instances of the feedback content of the feedback information in different languages, and an internationalized abnormal state code and a configuration file do not need to be additionally configured, so that the internationalized development work is simplified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of servers, and in particular to an information display method and a server. Background Art

[0002] With the development of computers and networks, newly developed software applications need to be applied to different countries, that is, software internationalization. Software internationalization is the process of software design and document development, which enables the software's functions and code design to handle multiple languages. When creating different language versions, there is no need to redesign the source code and software engineering methods.

[0003] In the existing software internationalization development process, each time an internationalized code is added, the corresponding information of the added internationalized code needs to be written into each internationalization configuration file. For a large number of codes that need to be internationalized, the workload will increase and the maintenance and configuration costs of the corresponding software will increase. Summary of the invention

[0004] The embodiment of the present application provides a method and server for displaying information. The solution of the present application simplifies the development of internationalized software.

[0005] In a first aspect, an embodiment of the present application provides a method for displaying information, the method comprising: receiving a first request for a target application sent by a front end, and obtaining a language environment of the front end; in response to the first request, sending first display information to the front end, the first display information including first feedback content, and the language of the first feedback content being adapted to the language environment of the front end; wherein, in a file associated with the target application, a first data instance is included, the first data instance indicating that the first feedback information corresponds to feedback content in multiple language environments, and the first feedback content is one of the feedback contents in the multiple language environments.

[0006] In this solution, when the target application responds to the first request, when the target application needs to return feedback information, the feedback content of the feedback information in the front-end language environment can be directly returned. That is, when the target application generates feedback information, it can achieve the conversion of the front-end language environment through the data instance, and there is no need to configure the internationalization abnormal status code and configuration file, which simplifies the internationalization development work.

[0007] In a possible implementation, the file includes multiple data instances of a data structure, the data structure is used to organize data according to feedback information corresponding to feedback content in multiple languages, and the first data instance is one of the multiple data instances.

[0008] In a possible implementation, the file includes an enumeration class, and the enumeration class has multiple data instances of a data structure, the data structure is an enumeration constant and the meaning of the enumeration constant, the enumeration constant is feedback information, and the meaning is feedback content in multiple language environments. It should be noted that each data instance is a member of the enumeration class, and the member records data according to the data structure. In addition, the name of the enumeration class can be any type of multiple types of feedback information.

[0009] That is to say, by pre-defining the enumeration class in the executable file corresponding to the target application, the target application can use the enumeration class to implement the conversion of the front-end language environment when generating feedback information, which simplifies the internationalization development work and maintains the internationalization processing in one enumeration class. It is no longer necessary to configure the internationalization file, thus avoiding the high maintenance cost of multiple internationalization files.

[0010] In a possible implementation, the file is a file that records the code of the target application, for example, it may be an executable file.

[0011] In a possible implementation, the method further includes: acquiring language version information of a front end that sends the first request from the first request; and determining a language environment of the front end according to the language version information of the front end. Exemplarily, the front end may be a browser.

[0012] That is, when generating feedback information, the target application can obtain the language environment in which the current target application is running by requesting.

[0013] In a possible implementation manner, the method further includes: acquiring filling information of a placeholder in the first feedback content; and replacing the placeholder in the first feedback content with the filling information to obtain first display information.

[0014] That is to say, if the target application needs to dynamically fill in the placeholder when generating feedback information, the problem of dynamic information display in the process of realizing the target application generating feedback information through the data structure is solved.

[0015] In a possible implementation, the first request also includes: user information, which is information input to the front end; obtaining fill information of the placeholder in the first feedback content, including: determining the fill information based on abnormal information in the user information.

[0016] In the specific implementation, the target application can save the parameters to be filled in the local variable ThreadLocal of the corresponding thread in advance. When the target application generates feedback information, the corresponding parameters can be obtained from ThreadLocal and filled into the feedback content to solve the problem that the target application needs to dynamically fill parameters with strings when generating feedback information.

[0017] In one possible implementation, the target application is divided into: presentation layer, business logic layer, data access layer;

[0018] Responding to the first request includes: executing the program logic of the first request in the presentation layer, the business logic layer and the data access layer.

[0019] That is to say, the backend of the target application can be divided into a three-layer architecture, and each layer of the architecture may need to generate feedback information during the execution process.

[0020] In a possible implementation, the first request is a hypertext transfer protocol (http) request.

[0021] That is to say, the request input by the user may be an http request, and the request header of the http request may carry language information that can be received by the browser.

[0022] In a possible implementation, the feedback content is abnormal prompt information.

[0023] In a second aspect, an embodiment of the present application provides an electronic device, including:

[0024] at least one memory for storing a program;

[0025] At least one processor is used to execute the program stored in the memory. When the program stored in the memory is executed, the processor is used to execute the method described in the first aspect or any possible implementation manner of the first aspect.

[0026] In a third aspect, an embodiment of the present application provides a computer storage medium, in which instructions are stored. When the instructions are executed on a computer, the computer executes the method described in the first aspect or any possible implementation of the first aspect.

[0027] In a fourth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method described in the first aspect or any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0029] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application;

[0030] Figure 2 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

[0031] Figure 3 A display implementation process of information provided in an embodiment of the present application;

[0032] Figure 4 A flowchart of a method for displaying information provided by an embodiment of the present application;

[0033] Figure 5 A schematic diagram of an application front-end user interaction interface provided in an embodiment of the present application;

[0034] Figure 6 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0036] In the description of the embodiments of the present application, any embodiment or design scheme of "exemplary", "for example" or "for example" should not be understood as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "for example" or "for example" is intended to present related concepts in a specific way.

[0037] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "include", "comprises", "has" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.

[0038] Before introducing the embodiments of the present application, the technical terms involved in the embodiments of the present application are first introduced.

[0039] Internationalization refers to the process of decoupling software from specific languages ​​and regions during the software design process. When the software is ported to different languages ​​and regions, the software itself does not need to be changed or modified. For example, the exception error information generated by the background program processing is returned to the front end. In the Chinese language environment, the returned exception information should be in Chinese, and in the English language environment, the returned exception information should be in the corresponding English.

[0040] Java is an object-oriented programming language with the characteristics of simplicity, object-oriented, distributed, robust, secure, platform-independent and portable, multi-threaded, dynamic, etc. It can be used to write desktop applications, Web applications, distributed systems and embedded system applications, etc. In the process of using Java for software development, in order to improve the maintainability and scalability of the code and the development efficiency, the three-layer architecture of the control layer (Controller), business logic layer (Service), and data access layer (Dao) can be used for software development.

[0041] The controller layer is located at the front end of the architecture, directly facing users or external requests. It is responsible for receiving user input, forwarding the request to the corresponding service layer for processing, and finally returning the processing result to the user. The main task of the controller layer is request processing and data forwarding. It does not contain business logic, ensuring the lightweight of the user interface.

[0042] The business logic layer (Service) is the center of the three-tier architecture and is responsible for processing the core business logic of the application. This layer interprets user requests, performs necessary business calculations, calls the data access layer for data persistence operations, and returns the execution results.

[0043] The data access layer (DAO) is the layer that interacts directly with the database or other persistent storage methods. The DAO layer is responsible for performing specific database operations, such as CRUD, and returning the results of the operations. By abstracting data access, the DAO layer decouples the business logic layer from the data storage details, improving the adaptability and stability of the system.

[0044] Spring is an open source Java enterprise application framework and a lightweight container for managing the life cycle of Java classes. Spring provides functions such as inversion of control (IOC), aspect oriented programming (AOP) and Web MVC (model view controller, MVC).

[0045] Spring Boot is a rapid development scaffold based on the Spring framework. It simplifies the initialization and construction process of Spring applications and provides many convenient functions and features, such as automatic configuration and embedded Tomcat, allowing developers to focus more on the implementation of business logic.

[0046] Instantiation: It is the process of converting an abstract concept class into a concrete object of that class. The instantiation process is generally composed of class name object name = new class name (parameter 1, parameter 2... parameter n).

[0047] Inheritance: quickly add new functions based on the original class; does not affect the original class, nor change the code of the original class, which is convenient for the expansion of functions; inheritance is a way to create a new class, and the newly created class can inherit one or more classes; inheritance describes the relationship between classes.

[0048] The embodiment of the present application provides a method for displaying information, wherein the backend of the application receives a first request sent by the front end for a target application; obtains the language environment of the front end; in response to the first request, sends first display information to the front end, the first display information includes first feedback content, and the language of the first feedback content is adapted to the language environment of the front end; wherein, in a file associated with the target application, a first data instance is included, the first data instance indicates that the first feedback information corresponds to feedback content in multiple language environments, and the first feedback content is one of the feedback contents in multiple language environments. In this solution, in the process of the target application responding to the first request, when the target application needs to return feedback information, the feedback content of the feedback information in the language environment of the front end can be directly returned. That is, when the target application generates feedback information, the conversion of the language environment of the front end can be realized through the data instance, and there is no need to configure internationalization abnormal status codes and configuration files, which simplifies internationalization development work.

[0049] In some possible implementations, the file associated with the target application may be a file recording the code of the target application, and may be an executable file, for example.

[0050] In some possible implementations, the file associated with the target application includes multiple data instances of a data structure, the data structure is used to organize data according to feedback information corresponding to feedback content in multiple languages, and the first data instance is one of the multiple data instances.

[0051] Exemplarily, the instantiation of a data structure can be achieved through an enumeration class. The instantiation of a data structure is to construct a data instance under the data structure. For example, the enumeration class includes multiple data instances under the data structure. The data structure is an enumeration constant and the meaning of the enumeration constant. The enumeration constant is feedback information, and the meaning is feedback content in multiple language environments. The meaning of the enumeration constant is used to express the enumeration constant in other forms. Each data instance can also be called an enumeration instance. The enumeration instance is an instantiated enumeration constant and an instance of the enumeration constant. The enumeration instance can be identified by the instantiated enumeration constant.

[0052] Then in an embodiment of the present application, an enumeration class is defined in advance in the executable file of the target application, and each enumeration instance (representing the feedback content corresponding to the feedback information in different language environments) is defined in the enumeration class. During the operation of the target application, an enumeration instance that needs to be prompted (that is, the first data instance) can be thrown out, and based on the pre-defined enumeration instance that needs to be prompted (that is, the first data instance), the first feedback content in the language environment of the front end in the enumeration instance that needs to be prompted (that is, the first data instance) can be output. The internationalization processing process of the response information of the target application is simplified. At the same time, the internationalization processing of the feedback information is uniformly maintained in an enumeration class, and there is no need to configure the internationalization exception status code and configuration file additionally, which simplifies the workload of internationalization development and avoids the problem of high maintenance costs of multiple internationalization files.

[0053] In some possible implementations, the feedback information is used for prompting, and may be abnormal prompting information or successful prompting information.

[0054] For example, Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present application is shown. Figure 1 The figure includes a terminal device 100 and a server 200. The terminal device 100 can be used to interact with a user, receive information input by the user to generate a first request, and the server 200 can be used to store data and provide support for applications running on the terminal device 100.

[0055] For example, a browser may be deployed on the terminal device 100, and the user may input corresponding information through the browser. An application may also be run on the terminal device 100, and the front-end page of the application may be displayed on the browser and interact with the user. In response to the information input by the user, the browser generates a first request and triggers the execution of the corresponding application.

[0056] A database may be deployed on the server 200, and the database may store data information required or generated during the execution of the application on the terminal device 100. During the execution of the application on the terminal device 100, it may interact with the server 200 to obtain the data information stored in the server 200. In some cases, the front end of the application may be deployed on the terminal device 100, and the back end of the application may be deployed on the server 200. The server 200 runs the back end of the application, is responsible for processing the request sent by the front end of the application and performing logic processing, interacting with the database, and finally returning data to the front end.

[0057] It is understandable that the server 200 is an optional device. In some cases, the application can be deployed only on the terminal device 100, and all data and information generated during the operation of the application on the terminal device 100 can be stored in the terminal device 100.

[0058] For example, Figure 2 FIG. 1 shows a schematic diagram of the structure of a terminal device provided in an embodiment of the present application. Figure 1 As shown, the terminal device 100 may include: a processor 110 , a storage device 120 , a memory 130 , and a display screen 140 .

[0059] Among them, the memory device 120 refers to an external memory which may be a disk, a tape, an optical disk, etc. The memory device 120 may store application code. In the embodiment of the present application, the application code stored in the memory device 120 (which may be stored in the form of an executable file) defines an internationalization interface class, an internationalization enumeration class, etc. in the corresponding exception response internationalization code. In one example, the internationalization interface class may include multiple language interfaces, each language structure is used to obtain feedback content in the corresponding language; illustratively, the internationalization interface class may include a default language interface and other language interfaces, wherein the default language interface is internationalized and unified; the internationalization enumeration class may inherit the internationalization interface class and define internationalization information, such as multiple data instances under the data structure, the data structure indicates that the feedback content corresponds to the feedback content in multiple language environments, and illustratively, the data structure may be feedback information {feedback content of language 1, feedback content of language 2, ...}. In some possible implementations, there may be multiple internationalization enumeration classes, and one internationalization enumeration class is identified by a label, and the label may be a feedback type, such as a certain type of exception, and the feedback information in the data instance under the data structure in the internationalization enumeration class belongs to the feedback type, so as to facilitate the maintenance and management of the data structure.

[0060] In a possible example, the application corresponding to the application code stored in the memory device 120 can be implemented in a three-layer architecture of a control layer (Controller), a business logic layer (Service), and a data access layer (Dao) during development.

[0061] The memory 130 can be used to store the operation data in the processor 110, as well as the data exchanged between the processor 110 and the storage device 120. For example, a process can be stored in the memory 130. In addition to the executable program code, the process also includes the memory heap space, stack space, and data structure used by the process during operation for the operating system management. In one possible example, the memory 130 can be a random access memory (RAM) or a read-only memory (ROM). The memory 130 and the processor 110 can be set separately. Optionally, the memory 130 can also be integrated in the processor 110.

[0062] The processor 110 is the computing core and control core of the terminal device 100. The processor 110 may include one or more processing units. For example, the processor 110 may include one or more of an application processor (AP), a modem, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). Among them, different processing units can be independent devices or integrated in one or more processors. In some embodiments, the processor 110 can execute the corresponding application after obtaining the request information input by the user. Specifically, the operating system on the terminal device will load the executable code of the corresponding application from the storage device 120 into the memory 130, and after generating the corresponding data structure and memory space, it can read the instructions from the starting position of the executable code and hand them over to the processor 110 for sequential execution. In some possible scenarios, the feedback information may be an exception prompt information. During the running of the application, if there is an exception, the processor 110 may generate an identifier of the first data instance, such as the first feedback information in the first data instance. Then, the processor 110 determines the first feedback content to be returned based on the identifier of the first data instance and the language environment information of the front end. The returned first feedback content matches the current language environment of the front end.

[0063] The display screen 140 serves as an input and output device of the terminal device 100. The user can input information through the display screen 140, and during the execution of the application program, the display screen 140 can output corresponding first display information, and the first display information includes first feedback content.

[0064] It is understandable that the terminal device 100 in the embodiment of the present application can be an electronic device such as a mobile phone, a tablet computer, a desktop computer, a server, etc.

[0065] The above is an introduction to the terminal device provided in the embodiment of the present application. Based on the above content, the following introduces a display implementation process of information provided in the embodiment of the present application.

[0066] like Figure 3 As shown, the application can be deployed on Figure 2 The application can be divided into a front end and a back end. Among them, the front end can be the part of the application responsible for user interaction and interface display, for example, the front end can be responsible for displaying data, processing user input, sending network requests and other functions. The interface for interacting with the user contained in the front end of the application can be displayed through the display screen 140 on the terminal device 100. The back end refers to the part of the application responsible for data processing and business logic, for example, the back end can be responsible for processing data, business logic, security and other issues. Under the architecture of separation of the front end and the back end, the front end and the back end are independent, communicate through the API interface, the front end sends a request to the back end, the back end returns data, and the front end is displayed according to the returned data. Among them, in the process of developing the back end of the application, the back end can be divided into three levels of implementation, including: including: control layer (controller), business logic layer (service) and data access layer (dao). During the operation of the application, the back end of the application can be executed by the processor 110 on the terminal device 100.

[0067] Next, continue to refer to Figure 3 The architecture of the application shown in the figure, the embodiment of the present application takes the feedback information as an exception type, the feedback content as an exception prompt content, and the first data instance as an exception instance as an example to introduce the internationalization processing process of the feedback information during the operation of the application. It should be noted that the meaning of the exception prompt content and the exception type are the same, and the exception prompt content is the expression of the exception type in a certain language.

[0068] (1) The front-end browser receives user input information.

[0069] During the running of the application, the application can receive information input by the user through the user interaction interface deployed by the front-end browser. The information input by the user may be a user name, password, etc.

[0070] (2) The front-end browser sends the request to the back-end controller layer, service layer, and dao layer for processing.

[0071] After receiving the information input by the user, the front-end browser can generate a request based on the information input by the user. The request is sent to the controller layer, service layer, and dao layer of the back end for processing. Specifically, the browser can send the request to the controller layer, and the controller layer can call the method of the service layer to process the received request. In the process of processing the received request, the service layer can call the dao layer to process the data. During the operation of the application, when the controller layer, service layer, and dao layer have an exception in the process of processing the request, the controller layer, service layer, and dao layer can throw an exception instance. For example, the exceptions thrown by the controller layer may include: http method not supported exception, parameter verification exception, parameter binding exception, etc.; the exceptions thrown by the service layer may include: custom business exception, I / O exception, etc.; the exceptions thrown by the dao layer may include: database exception, etc.

[0072] In a possible example, for the exception instances that may be thrown by the back-end controller layer, service layer, and dao layer, the exception instances are data instances under the data structure, and an internationalized enumeration class can be defined in advance in the project file of the application. The internationalized enumeration class includes multiple enumeration instances (that is, data instances under the data structure described above), each of which describes the exception type and the exception prompt content corresponding to the exception type in different language environments. The enumeration instance can be identified by the exception type.

[0073] (3) Capture exception instances thrown by the controller layer, service layer, and dao layer.

[0074] After the controller layer, service layer, and dao layer throw exception instances, the SpringBoot global interceptor can intercept the exception instances thrown by the controller layer, service layer, and dao layer. It can be understood that in SpringBoot, a global exception handling class can be created through the @ControllerAdvice annotation, and then the @ExceptionHandler annotation can be used to handle specific exceptions.

[0075] (4) Obtain corresponding first exception prompt content according to the exception instance and the front-end language environment information carried in the request.

[0076] After obtaining the exception instance thrown by the controller layer, service layer, and dao layer, the application can obtain the first exception prompt content corresponding to the exception instance based on the obtained exception instance and the language environment information carried in the request sent by the front end. Among them, the language type of the obtained first exception prompt content matches the language environment information carried in the request.

[0077] (5) Output and display the first abnormal prompt content through the front-end browser.

[0078] After the application generates the first abnormal prompt content, it is also necessary to send the generated first abnormal prompt content to the front end and display it on the front end page to achieve the purpose of reminding the user.

[0079] In the embodiment of the present application, data organization is performed through data instances of feedback content in different languages ​​of feedback information, and there is no need to additionally configure internationalization abnormal status codes and configuration files, thereby simplifying the workload of internationalization development.

[0080] For example, Figure 4 A flowchart of a method for displaying information provided by an embodiment of the present application is shown. The method can be performed by Figure 1 The terminal device 100 shown in the figure executes, or is Figure 1 The server 200 shown in the figure is executed, and the embodiment of the present application is described by taking the terminal device 100 as an example. Figure 4 As shown, it includes: step 401-step 404.

[0081] Step 401: Receive a first request for a target application sent by a front end.

[0082] In some cases, the first request carries locale information, and the locale information is used to indicate the locale of the front end.

[0083] In an embodiment of the present application, the target application running on the terminal device 100 can receive information input by the user through the browser on the terminal device 100, that is, the user input information in the above embodiment, and the browser generates a first request. Among them, the type of the first request can be a hypertext transfer protocol (HTTP) request. The request header of the http request can carry language information that the browser can receive. For example, the language information that the current browser can receive can be obtained through the "accept-language" information carried in the http request header.

[0084] It is understandable that when HTTP sends a request or a response, it will carry a request header (requestheaders), which stores some necessary information. For example: accept, accept-encoding, accept-language and other information. Among them, accept is used to identify the data format that the browser can accept; accept-encoding is used to identify the compression algorithm that the browser can accept; accept-language is used to identify the language that the browser can receive (such as zh-CN).

[0085] Step 402: Obtain the language environment of the front end.

[0086] In some possible embodiments of the present application, the terminal device 100 can parse the language environment of the front end from the first request, specifically in the following manner: obtaining the language version information of the front end that sends the first request from the first request; and determining the language environment of the front end based on the language version information of the front end.

[0087] In some other possible embodiments of the present application, the terminal device 100 may obtain the language environment of the front end determined previously. Step 403: In response to the first request, send first display information to the front end, the first display information includes first feedback content, and the language of the first feedback content is adapted to the language environment of the front end; wherein, in the file associated with the target application, a first data instance is included, the first data instance indicates that the first feedback information corresponds to feedback content in multiple language environments, and the first feedback content is one of the feedback content in multiple language environments.

[0088] In a specific implementation, the terminal device 100 responds to the first request, triggers the execution of the target application deployed on the terminal device 100, and determines prompt information, where the prompt information is at least used to indicate the first data instance; then, the terminal device 100 determines the first feedback content based on the prompt information and the language environment of the front end; finally, the first display information is determined based on the first feedback content.

[0089] In an embodiment of the present application, the prompt information may include an identifier of the first data instance. For example, the data instance under the data structure is feedback information {feedback content of language 1, feedback content of language 2, ...}, and the identifier of the first data instance is the first feedback information in the first data instance. Exemplarily, the first feedback information may be the exception type described above.

[0090] In some possible scenarios of the embodiments of the present application, after receiving the first request generated by the browser, the terminal device 100 may respond to the first request, trigger the execution of the target application deployed on the terminal device 100, and obtain the prompt information generated during the execution of the target application. Exemplarily, the prompt information may be abnormal information generated during the execution of the target application.

[0091] Among them, the first data instance indicated by the prompt information can be an enumeration instance in an enumeration class, and the enumeration class has been defined in the executable file corresponding to the target application. It should be noted that the executable file is the application code for the programmer to develop the target application. It can be understood that the data structure can be instantiated through the enumeration class, and the data instance under the data structure can be called an enumeration instance; the enumeration class is a special data type used to define a fixed named constant. In java, the enumeration class is defined by using the enum keyword. The enumeration class can contain one or more enumeration constants, each of which is an instance of the enumeration class and can also be an enumeration instance. The enumeration constants are pre-defined in the enumeration class, and they are unique and named objects. In the embodiment of the present application, the meaning of the enumeration constant also needs to be constructed in the enumeration instance, and the meaning of the enumeration constant is the feedback information of the enumeration constant in multiple language environments. In a possible embodiment, the prompt information may include the identifier of the enumeration class to which the first data instance belongs, and the enumeration class has multiple data instances under the data structure. In specific implementation, multiple enumeration classes may be set. For each enumeration class, the identifier of the enumeration class may be the feedback type of the feedback information, and the enumeration class has multiple enumeration instances.

[0092] In one possible example, the target application may be an application written in Java. In the process of writing the target application, the format of the prompt information generated during the execution of the target application may be defined in the executable file corresponding to the target application. For example, an internationalized interface class including a default language interface and other language interfaces is defined, as well as an internationalized enumeration class. Among them, the defined internationalized enumeration class inherits the internationalized interface, and the internationalized interface class serves as the parent class of the internationalized enumeration class. The internationalized interface class may provide a default implementation of the interface method, and the internationalized enumeration class may override the default implementation in the internationalized interface class. Based on the defined internationalized interface class and internationalized enumeration class, the target application may generate prompt information containing the identifier of the enumeration instance during operation.

[0093] In a possible example, the code file corresponding to the internationalization interface class defined in the executable file corresponding to the target application may be as follows:

[0094]

[0095]

[0096] After defining the internationalization interface class, you also need to define an internationalization enumeration class. The newly defined internationalization enumeration class can be used to implement the internationalization interface class. Specifically, take the enumeration constant as an exception type as an example for description, you can refer to the following code:

[0097]

[0098] In the executable file corresponding to the target application, after defining the internationalization interface and the internationalization enumeration class, the enumeration instance (that is, the first data instance mentioned above) that throws an exception when the application is abnormal can be implemented based on the defined internationalization interface class and the internationalization enumeration class. The specific implementation can refer to the following code snippet:

[0099]

[0100]

[0101] In the above code, it is defined that during the execution of the target application, a corresponding prompt message may be thrown out due to an I / O problem of a certain operation. The prompt message may carry the identifier of the corresponding enumeration instance (the first data instance described above), such as the first exception type.

[0102] Next, the terminal device 100 determines the first feedback content based on the prompt information and the language environment of the front end.

[0103] In the embodiment of the present application, during the execution of the target application, the Spring Boot global exception interceptor can be used to obtain the prompt information generated by the target application during the execution. After obtaining the prompt information, the target application determines the first feedback information according to the identifier of the first data instance in the prompt information and the language environment of the front end parsed from the first request.

[0104] In one possible example, based on the code described above with enumeration constants as exception types, the target application throws the identifier "NET_ERROR" of the abnormal enumeration instance (that is, the first data instance) by executing the code "Throw new BusinessException(ErrorEnum.NET_ERROR)". Then, the target application can obtain the feedback content corresponding to the language environment information of the application as the first feedback content through the defined getMsg method. Among them, the language information of the application can be the language environment of the front end parsed from the first request. For example, the target application obtains the current language environment through LocaleContextHolder.getLocale() in the getMsg method. If Locale.US is returned, it is an English environment, and the getEnMsg method of "NET_ERROR" is called to obtain the first feedback content corresponding to "NET_ERROR" from the pre-defined international enumeration class "ErrorEnum", which is "Network abnormality".

[0105] Finally, first display information is determined based on the first feedback content.

[0106] In some possible scenarios of the embodiments of the present application, the first feedback content does not have a placeholder, and the terminal device 100 uses the first feedback information as the first display information.

[0107] In some other possible scenarios of the embodiments of the present application, the first feedback content has a placeholder, and the terminal device 100 obtains the filling information of the placeholder in the first feedback content; replaces the placeholder in the first feedback content with the filling information to obtain the first display information. Exemplarily, the prompt information carries a first data instance, such as an identifier of an enumeration instance, and the filling information replaces the placeholder in the first feedback content in the language environment of the front end in the first data instance, such as the enumeration instance, so as to dynamically generate complete and specific internationalized prompt information.

[0108] In a possible application, when the target application is running and responding, it also involves internationalization parameter transmission when generating the first feedback content of the response. Internationalization parameter transmission can be understood as adding information determined based on the information sent by the front end to the first feedback content.

[0109] Exemplarily, the filling information is abnormal user information.

[0110] In some possible situations, the terminal device 100 may actively record abnormal user information. For example, the terminal device 100 may obtain the user's login status in a certain browser and record the number of failed logins in the certain browser.

[0111] In some other possible situations, the first request may also include: user information, the user information is the information input to the front end, the prompt information includes abnormal information in the user information (that is, abnormal user information), and the terminal device 100 determines the fill-in information based on the abnormal information in the user information. For example, the terminal device 100 uses the abnormal information in the user information as fill-in information. Exemplarily, the user information may be an account number and a password, and the abnormal information is an account number, then the fill-in information may be an account number. Exemplarily, the user information may be field values ​​of multiple fields, and the abnormal information is an erroneous field value, then the fill-in information may be the erroneous field value and the field to which the erroneous field value belongs. Specifically, in step 401, the first request may also include user information. The target application responds to the first request. During the execution process, if it is determined that there is abnormal information in the user information, the abnormal information is used as fill-in information, and the target application may replace the placeholder in the first feedback content in the language environment of the front end in the first data instance with the fill-in information.

[0112] Step 404: display first display information.

[0113] In the embodiment of the present application, after the target application generates the first display information, the target application may also output the generated first display information to the front end and display it, so as to achieve the purpose of reminding the user.

[0114] In this solution, when the target application responds to the first request, when the target application needs to return feedback information, the feedback content of the feedback information in the front-end language environment can be directly returned. That is, when the target application generates feedback information, it can achieve the conversion of the front-end language environment through the data instance, and there is no need to configure the internationalization abnormal status code and configuration file, which simplifies the internationalization development work.

[0115] It should be noted that Figure 4 A method for displaying information provided by an embodiment of the present application is shown. Figure 1 The terminal device 100 shown is only an example and does not constitute a specific limitation. In other possible implementations, Figure 1 The server 200 shown is executed. At this time, the front end can be replaced by the terminal device 100, and step 404 can be replaced by the terminal device 100 displaying the first display information.

[0116] Based on the information display method provided above, specific application scenarios of the information display method are described.

[0117] In a possible application scenario, users can Figure 5 Enter user information in the browser interface shown in a, and the browser generates a first request. Figure 5 The interface shown in a can be the login interface of the application. The first request is used to request to log in to the target application. The first request can carry information such as user name, registered mobile phone number, verification code, etc. After the target application receives the first request, it first judges the user information such as "user name, registered mobile phone number, verification code" carried in the first request. When there is an abnormality in the user information carried in the first request, a corresponding prompt message is output. Among them, the output prompt information includes the abnormal user information and the identifier of the enumeration instance (such as the first feedback information in the abnormal enumeration instance). For example, the target application detects that the "registered mobile phone number" entered by the user is incorrect, and the prompt information may include the "registered mobile phone number"; subsequently, the target application can output the first display information expressed in Chinese when it determines that the current running language environment is Chinese. The first display information includes the abnormal user information and the Chinese feedback content in the enumeration instance. Figure 5 As shown in b in the figure, the target application can be Figure 5 In the browser interface shown in b, the first display information is output and displayed to prompt the user that the "registered mobile phone number" currently entered is incorrect.

[0118] It should be noted that after receiving the first request sent by the browser, the target application responds to the first request input by the user. During the execution of the target application, if an exception occurs, the target application will throw out the identifier of the corresponding exception enumeration instance (that is, the first data instance described above). The exception enumeration instance is used to illustrate the feedback content (such as the exception prompt content) of the first feedback information (such as the exception type) in different languages. Since the enumeration instances are pre-defined in the enumeration class, they are unique and named objects and cannot be changed during the operation of the target application. Therefore, after the target application can output the first display information based on the identifier of the thrown exception enumeration instance in combination with the user information of the exception (that is, it is necessary to pass parameters and format international information), the target application passes parameters through the thread local variable ThreadLocal, and uniformly formats it in the interface class, so as to combine the enumeration instance and the user information of the exception to output the first display information.

[0119] It is understandable that ThreadLocal is called a thread variable. The variable filled in ThreadLocal belongs to the current thread, and the variable is isolated from other threads. ThreadLocal creates a copy of the variable in each thread, and each thread can access its own internal copy variable.

[0120] In one possible example, after receiving the first request, the target application verifies the user information carried in the first request in response to the received first request. When the application determines that there is abnormal user information in the first request, the target application can store the abnormal user information (for example, the registered mobile phone number) in the thread local variable ThreadLocal. Then, when the target application outputs the first feedback content (for example, the abnormal prompt content) of the currently running language environment in the abnormal enumeration instance, it can read the abnormal user information from ThreadLocal and fill the abnormal user information in the placeholder of the first feedback content to obtain the first display information.

[0121] In a possible example, in the process of realizing the internationalization of exception response information, the specific code implementation of internationalization parameter transmission through the thread local variable ThreadLocal of the target application can be as follows.

[0122] First, when defining an internationalized interface class, the internationalized interface class needs to support internationalization and parameterization. For details, please refer to the following code:

[0123]

[0124] After defining the internationalization interface class, you also need to define an internationalization enumeration class. The newly defined internationalization enumeration class can be used to implement the internationalization interface class. In the defined internationalization enumeration class, for the enumeration instance that needs to pass parameters, you can use "s%" to occupy the placeholder when defining the enumeration instance. Specifically, you can refer to the following code:

[0125]

[0126] In the executable file corresponding to the target application, after defining the internationalization interface and internationalization enumeration class, you can implement the enumeration instance that throws an exception when the application is abnormal based on the defined internationalization interface class and internationalization enumeration class. The specific implementation can refer to the following code snippet:

[0127]

[0128] In the above code, when creating a BusinessException object, the context parameters of the current thread are recorded, and the error code is associated with the exception enumeration instance. In this way, the parameters of the error message and the identifier of the exception enumeration instance (such as the first feedback information in the exception enumeration instance) can be obtained where the exception enumeration instance is thrown and processed, thereby achieving the purpose of internationalizing parameter transmission in the process of internationalizing the exception response information.

[0129] In an embodiment of the present application, if the target application needs to perform internationalized parameter passing when generating feedback information of an exception response, the local variable ThreadLocal of the currently running thread of the target application can be used for internationalized parameter passing, which solves the problem of the target application needing to dynamically fill in string parameters when generating feedback information of an exception response.

[0130] It is understandable that the size of the sequence number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. In addition, in some possible implementations, each step in the above embodiment can be selectively executed according to actual conditions, and can be partially executed or fully executed, which is not limited here. In addition, all or part of any feature in the above embodiment can be freely and arbitrarily combined without contradiction. The combined technical solution is also within the scope of the present application.

[0131] Based on the method in the above embodiment, the embodiment of the present application provides an electronic device, including: at least one memory for storing programs; at least one processor for executing the programs stored in the memory, and when the programs stored in the memory are executed, the processor is used to execute the method in the above embodiment. Exemplarily, the electronic device can be, but is not limited to, a mobile phone, a computer, a server, and other electronic devices.

[0132] Based on the method in the above embodiment, the present application embodiment also provides a terminal device. Figure 6 , Figure 6 This is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application. Figure 6 As shown, the terminal device includes one or more processors 601 and an interface circuit 602. Optionally, the terminal device may also include a bus 603. Among them:

[0133] Processor 601 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in processor 601 or an instruction in software form. The above processor 601 can be a general-purpose processor, a digital communicator (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods and steps in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.

[0134] The interface circuit 602 can be used to send or receive data, instructions or information. The processor 601 can use the data, instructions or other information received by the interface circuit 602 to process, and can send the processing completion information through the interface circuit 602.

[0135] Optionally, the terminal device further includes a memory, which may include a read-only memory and a random access memory, and provides operation instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory (NVRAM).

[0136] Optionally, the memory stores executable software modules or data structures, and the processor can perform corresponding operations by calling operation instructions stored in the memory (the operation instructions can be stored in the operating system).

[0137] Optionally, the interface circuit 602 may be used to output the execution result of the processor 601 .

[0138] It should be noted that the functions corresponding to the processor 601 and the interface circuit 602 can be implemented through hardware design, software design, or a combination of hardware and software, which is not limited here.

[0139] Based on the method in the above embodiment, the present application embodiment also provides a server. The structure of the server can be found in Figure 6 . Figure 6 This is only an example and does not constitute a specific limitation. For example, Figure 6 More devices.

[0140] It should be understood that each step of the above method embodiment can be completed by a hardware-based logic circuit or a software-based instruction in a processor.

[0141] Based on the method in the above embodiment, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a processor, the processor executes the method in the above embodiment.

[0142] Based on the method in the above embodiment, an embodiment of the present application provides a computer program product, characterized in that when the computer program product runs on a processor, the processor executes the method in the above embodiment.

[0143] The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.

[0144] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.

[0145] It should be understood that the various numerical numbers involved in the embodiments of the present application are only used for the convenience of description and are not used to limit the scope of the embodiments of the present application.

Claims

1. A method for displaying information, characterized in that: The method comprises: receiving a first request for a target application sent by a front end; Get the front-end language environment; In response to the first request, first display information is sent to the front end, the first display information includes first feedback content, and the language of the first feedback content is adapted to the language environment of the front end; wherein, in a file associated with the target application, a first data instance is included, the first data instance indicates that the first feedback information corresponds to feedback content in multiple language environments, and the first feedback content is one of the feedback contents in the multiple language environments.

2. The method according to claim 1, characterized in that The file includes multiple data instances of a data structure, and the data structure is used to organize data according to feedback information corresponding to feedback content in multiple language environments. The first data instance is one of the multiple data instances.

3. The method according to claim 2, characterized in that The file includes an enumeration class, under which there are multiple data instances of the data structure, the data structure is an enumeration constant and the meaning of the enumeration constant, the enumeration constant is feedback information, and the meaning is the feedback content in the multiple language environments.

4. The method according to any one of claims 1 to 3, characterized in that: The file is a file that records the code of the target application.

5. The method according to any one of claims 1 to 4, characterized in that: The obtaining of the language environment of the front end includes: Acquire language version information of a front end sending the first request from the first request; The language environment of the front end is determined according to the language version information of the front end.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Obtaining filling information of the placeholder in the first feedback content; The placeholder in the first feedback content is replaced with the filling information to obtain first display information.

7. The method according to claim 6, characterized in that The first request also includes: user information, which is information input to the front end; The obtaining filling information of the placeholder in the first feedback content includes: The filling information is determined based on abnormal information in the user information.

8. The method according to any one of claims 1 to 7, characterized in that: The target application is divided into: presentation layer, business logic layer, data access layer; The responding to the first request includes: In the presentation layer, the business logic layer and the data access layer, the program logic of the first request is executed.

9. The method according to any one of claims 1 to 8, characterized in that: The feedback content is abnormal prompt information.

10. A server, characterized in that: include at least one memory for storing a program; At least one processor is used to execute the program stored in the memory, and when the program stored in the memory is executed, the processor is used to execute the method described in any one of claims 1-9.

Citation Information

Cited By

  • Universal multi-language rendering method for internationalized users

    CN120278170A