Field translation method, device and equipment

By parsing configuration files separately on the client and server, the server loads and stores translation data. The client loads and translates fields from the server, solving the code maintainability and scalability problems caused by hard coding, and improving the flexibility and maintainability of the code.

CN119990154APending Publication Date: 2025-05-13CHINA TELECOM CORP LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411864152.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

In the prior art, translated text is closely coupled with database storage instance data in a hard-coded manner, resulting in lower maintainability and scalability of the code.

Method used

By analyzing configuration files on the client and the server, the server loads and stores translated data from the preset database. The client loads and uses this data for field translation from the server, avoiding the tight coupling between the code and the translated text.

Benefits of technology

Improves the maintainability, flexibility and scalability of the code, reduces the coupling of business code, and simplifies the management and update process of translated data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119990154A_ABST
    Figure CN119990154A_ABST
Patent Text Reader

Abstract

The invention discloses a field translation method and device, electronic equipment and a storage medium, and the method comprises the steps: a client side analyzes a first configuration file, and determines a first loading mode; obtaining translation data from a memory of the server based on the first loading mode; obtaining to-be-translated data; the to-be-translated data comprises class names and corresponding attribute values; traversing the translated data, querying a translation field corresponding to the class name of the to-be-translated data, querying a value corresponding to the attribute value of the to-be-translated data in the translation field, and taking the value as a translation result of the to-be-translated data. Therefore, the client can be driven by the first configuration file, the client can load the translation data from the server, and then the client can translate the acquired to-be-translated data by using the translation data, so that the client does not need to be coupled with a service code, and the maintainability, the flexibility and the expandability of the code are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of data processing, and specifically relates to a field translation method, apparatus, device and storage medium. Background Art

[0002] In web applications, it's often necessary to translate database instance data into a dictionary table so that users or operators can intuitively understand the dictionary values. For example, a page might need to display the service code "ADSLD_001," but only some developers understand its actual meaning. Therefore, a dictionary table is needed to translate the service code "ADSLD_001" into the service name "Broadband Subscription" before displaying it.

[0003] Prior art methods can achieve field translation by directly replacing the values ​​of designated fields in the backend of a web application system. However, this translation method hard-codes the translated text and tightly couples it with the database instance data. This results in a large amount of translated text scattered throughout the code. Modifying the database instance data or updating the translated text requires simultaneously modifying the corresponding code, which reduces code maintainability and scalability. Summary of the Invention

[0004] The purpose of the embodiments of the present application is to provide a field translation method, apparatus, device and storage medium that can solve the problem that the current translation text is tightly coupled with the database storage instance data in a hard-coded manner, resulting in low code maintainability and scalability.

[0005] In a first aspect, an embodiment of the present application provides a field translation method, applied to a client, the method comprising:

[0006] Parsing the first configuration file and determining a first loading mode;

[0007] Based on the first loading method, obtaining translation data from the memory of the server;

[0008] Obtaining data to be translated; the data to be translated includes a class name and a corresponding attribute value;

[0009] The translation data is traversed, a translation field corresponding to the class name of the data to be translated is searched, and a value corresponding to the attribute value of the data to be translated is searched in the translation field as a translation result of the data to be translated.

[0010] Optionally, traversing the translation data and querying the translation field corresponding to the class name of the data to be translated includes:

[0011] According to the class name of the data to be translated, a recursive query is performed upwards level by level to determine the base class name of the data to be translated;

[0012] The translation data is traversed to query the translation field corresponding to the base class name of the data to be translated.

[0013] Optionally, querying the translation field for a value corresponding to the attribute value of the data to be translated as a translation result of the data to be translated includes:

[0014] Searching the translation field for a value corresponding to the attribute value of the data to be translated as a candidate value;

[0015] determining whether the translation data includes additional conditional processing rules;

[0016] If included, additional conditional processing is performed on the candidate value to obtain a translation result of the data to be translated;

[0017] If not included, the candidate value is used as the translation result of the data to be translated.

[0018] Optionally, obtaining translation data from the memory of the server based on the first loading method includes:

[0019] The translation data is obtained from the memory of the server through the preset interface indicated by the first loading method.

[0020] In a second aspect, an embodiment of the present application provides a field translation method, which is applied to a server, including:

[0021] Parsing the second configuration file and determining the second loading mode;

[0022] Based on the second loading method, reading translation data from a preset database;

[0023] The translation data is stored in the memory of the server.

[0024] Optionally, the reading of translation data from a preset database based on the second loading mode includes:

[0025] Reading an execution statement corresponding to the second loading mode from the second configuration file;

[0026] Based on the execution statement, translation data is read from a preset database.

[0027] Optionally, storing the translation data in the memory of the server includes:

[0028] Storing the translation data in a remote dictionary service and a memory of the server;

[0029] In response to an update instruction for any translation data, deleting the any translation data from the memory of the server, and re-reading the any translation data from the preset database based on the second loading method, and re-storing the any translation data into the memory of the server;

[0030] In response to the start-up instruction of the server, the translation data is read from the remote dictionary service and stored in the memory of the server.

[0031] Optionally, after storing the translation data in the memory of the server, the method further includes:

[0032] A preset interface is registered on a service registration platform, where the preset interface is used to provide the translation data.

[0033] In a third aspect, an embodiment of the present application provides a field translation device, applied to a client, the device comprising:

[0034] A parsing module, configured to parse the first configuration file and determine a first loading mode;

[0035] a loading module, configured to obtain translation data from the memory of the server based on the first loading method;

[0036] An acquisition module is used to acquire data to be translated; the data to be translated includes a class name and a corresponding attribute value;

[0037] The translation module is used to traverse the translation data, query the translation field corresponding to the class name of the data to be translated, and query the value corresponding to the attribute value of the data to be translated in the translation field as the translation result of the data to be translated.

[0038] In a fourth aspect, an embodiment of the present application provides a field translation device, which is applied to a server, and the device includes:

[0039] A determination module, configured to parse the second configuration file and determine a second loading mode;

[0040] A reading module, configured to read translation data from a preset database based on the second loading method;

[0041] A storage module is used to store the translation data in the memory of the server.

[0042] In a fifth aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.

[0043] In a sixth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0044] In a seventh aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the method described in the first aspect.

[0045] In an eighth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.

[0046] As can be seen from the above, in this solution, the client and server can be driven by the first configuration file and the second configuration file respectively, so that the server can load and store translation data from a preset database, and the client can load translation data from the server. Then, the client can use the translation data to translate the obtained data to be translated. Therefore, neither the client nor the server needs to be coupled with business code, which enhances the maintainability, flexibility and scalability of the code. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 is a flowchart of a field translation method according to an exemplary embodiment;

[0048] Figure 2 is a schematic diagram showing an example of data to be translated according to an exemplary embodiment;

[0049] Figure 3 is a flowchart of a field translation method according to an exemplary embodiment;

[0050] Figure 4 is a schematic diagram of a storage model for translation data according to an exemplary embodiment;

[0051] Figure 5 is a flowchart illustrating a field translation method according to an exemplary embodiment;

[0052] Figure 6 is a block diagram of a field translation device according to an exemplary embodiment;

[0053] Figure 7 is a block diagram of a field translation device according to an exemplary embodiment;

[0054] Figure 8 is a block diagram of an electronic device according to an exemplary embodiment;

[0055] Figure 9 The figure is a schematic diagram showing the hardware structure of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0056] The following will be combined with the accompanying drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field are within the scope of protection of this application.

[0057] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.

[0058] The field translation method provided in the embodiment of the present application is described in detail below through specific embodiments and application scenarios in conjunction with the accompanying drawings.

[0059] Figure 1 The flowchart of a field translation method according to an exemplary embodiment is shown and is applied to a client. The field translation method includes the following steps.

[0060] In step S11, the first configuration file is parsed and a first loading mode is determined.

[0061] In web applications, it's often necessary to translate database instance data into a dictionary table so that users or operators can intuitively understand the dictionary values. For example, a page might need to display the service code "ADSLD_001," but only some developers understand its actual meaning. Therefore, a dictionary table is needed to translate the service code "ADSLD_001" into the service name "Broadband Subscription" before displaying it.

[0062] In related technologies, field translation can be achieved by replacing the values ​​of designated fields in the backend of a web application system. However, this translation method hard-codes the translated text and tightly couples it with the database instance data. This results in a large amount of translated text being scattered throughout the code. Modifying the database instance data or updating the translated text requires modifying the corresponding code as well, which reduces the maintainability and scalability of the code.

[0063] Based on this, this application proposes a field translation method to solve the above problems.

[0064] In this step, the client first reads and parses the first configuration file, which defines the method for loading translation data and other necessary configuration information. For example, the first configuration file can be represented as trans_cache.xml. The client can parse the load_type field in the first configuration file to determine the first method for loading translation data.

[0065] In step S12, based on the first loading method, the translation data is obtained from the memory of the server.

[0066] In this step, the first loading method is used by the client to obtain translation data from the server. The client needs to send a data acquisition request to the server according to a certain configuration or protocol indicated in the first configuration file. The server then processes and returns the translation data based on the data acquisition request.

[0067] For example, the client can traverse the module_code nodes in the first configuration file. Each module_code node represents a translation data module to be loaded, and each translation data module includes multiple translation data. The client can then construct corresponding request parameters for each module_code node and generate a data acquisition request. The request parameters include the module_code value and the number of translation data items to be acquired each time. The number of translation data items can be specified in the first configuration file or a default value can be selected.

[0068] On the server side, data caching technology is usually used to store translation data in memory. When the client sends a data acquisition request, the server can directly read the translation data from the memory and return it to the client, thereby improving data access speed and system performance.

[0069] Furthermore, the client can store the obtained translation data in TransModule.keyValuesMap according to the field names configured in the key_code node and value_code node, and at the same time assign the current module_code value to the corresponding TransModule.moduleCode field for subsequent use.

[0070] For example, the client can store the obtained translation data in the form of a translation configuration table to facilitate the subsequent translation process. For example, the fields in the translation configuration table may include but are not limited to:

[0071] TRANS_TABLE is the name of the table where the translation data is located or the identifier of the translation data module;

[0072] CLASS_NAME is the entity class name that needs to be translated in the translation data;

[0073] PROP_NAME is the name of the field that needs to be translated in the entity class;

[0074] PROP_VALUE_NAME is the entity field where the translation needs to be stored.

[0075] TRANS_EXTR_COND is an additional conditional processing rule, which may involve further screening, adjustment, or conversion of the translation results to ensure the accuracy and applicability of the translation results.

[0076] In one implementation, based on the first loading method, obtaining translation data from the memory of the server includes:

[0077] The translation data is obtained from the memory of the server through the preset interface indicated by the first loading method.

[0078] That is to say, in this embodiment, the client does not directly connect to the database to query the translation data, but loads the translation data by calling a preset interface. After the client sends a data acquisition request to the server from the preset interface, the server directly obtains the translation data from the memory and returns it to the client.

[0079] In step S13, data to be translated is obtained; the data to be translated includes class names and corresponding attribute values.

[0080] In this step, the client can obtain the data to be translated, which is the data that needs to be translated, including the class name and the corresponding attribute value. For example, in the above example, the service code is the class name of the data to be translated, and "ADSLD_001" is the corresponding attribute value.

[0081] The data to be translated can be one or more, for example Figure 2 As shown, the data to be translated may be a list containing multiple ViewDto objects, each ViewDto object represents a view data object to be translated, and ViewDto, ViewDto2 and ViewDto3 correspond to the same base class BaseDto.

[0082] In step S14, the translation data is traversed to search for the translation field corresponding to the class name of the data to be translated, and the value corresponding to the attribute value of the data to be translated is searched in the translation field as the translation result of the data to be translated.

[0083] In this step, traversing the translation data involves checking each item in the translation data one by one in a certain order. During this traversal, the client first extracts the class name of the data to be translated; then, it searches the translation data for the translation field corresponding to that class name. This may require the use of algorithms such as hash tables, binary searches, and tree structure traversals to accelerate the search process.

[0084] Once a translation field is found, the client can further search within it for a value that corresponds to the attribute value of the data to be translated. This may require the use of techniques such as string matching and regular expression matching to ensure accuracy. The client can then record the translation result and potentially associate it with the data to be translated for subsequent use.

[0085] For example, a client can obtain the TransModule translation data stored in the Translator.transModuleCache property based on the TRANS_TABLE field in the translation configuration table. Translator.transModuleCache is a cache that stores multiple TransModules, each of which contains the translation data of a specific translation data module.

[0086] Then, based on the name specified in the PROP_NAME field, the property value corresponding to the name is obtained from the ViewDto object. This property value is recorded as attrCode and represents the original text to be translated. Then, using attrCode as the key (key), the corresponding translation result (value) is retrieved from TransModule.keyValuesMap.

[0087] In one implementation, traversing the translation data and searching for the translation field corresponding to the class name of the data to be translated includes:

[0088] According to the class name of the data to be translated, a recursive query is performed upwards level by level to determine the base class name of the data to be translated;

[0089] Traverse the translation data and query the translation field corresponding to the base class name of the data to be translated.

[0090] That is, for each data item to be translated, the client can recursively query its base class name, one level at a time, based on its class name, until a termination condition is reached, such as reaching the root class or no more parent classes can be found. The recursively obtained class name can then be used as a query condition to query the translation configuration table, specifically the CLASS_NAME field, to obtain the corresponding translation field.

[0091] The purpose of recursive queries is to handle inheritance relationships. In object-oriented programming, subclasses can inherit the properties and methods of their parent classes. Therefore, recursive queries can ensure that all possible translation data can be found.

[0092] In one implementation, searching a translation field for a value corresponding to an attribute value of the data to be translated as a translation result of the data to be translated includes:

[0093] Querying the translation field for a value corresponding to the attribute value of the data to be translated as a candidate value;

[0094] Determine whether the translation data includes additional conditional processing rules;

[0095] If included, additional conditional processing is performed on the candidate value to obtain the translation result of the data to be translated;

[0096] If not included, the candidate value is used as the translation result of the data to be translated.

[0097] First, the client can query the translation field for the value corresponding to the attribute value of the data to be translated. This process typically involves string matching, regular expression matching, or more complex semantic matching algorithms. Based on the attribute value of the data to be translated, the client can search the translation field for matching or most similar translation options and select these options as candidate values.

[0098] Next, the client can determine whether the translation data includes additional conditional processing rules. These rules may involve further screening, adjustment, or transformation of candidate values ​​to ensure the accuracy and applicability of the translation results. For example, some rules may require candidate values ​​to be modified based on context or specific conditions, or adjusted to the grammar and idioms of the target language.

[0099] If the translation data includes additional conditional processing rules, the client can perform additional conditional processing on the candidate value. If the translation data does not include additional conditional processing rules, or additional conditional processing has been completed, the client can output the candidate value as the translation result of the data to be translated.

[0100] Among them, additional conditional processing rules may include but are not limited to:

[0101] Specific configuration table conversion (field@configuration table name): This means that there are multiple translation configuration tables, which store the translation rules or mapping relationships of specific fields. When a field needs to be translated, the current translation configuration table is first searched to obtain the translated value. Then, this translated value is used as a parameter to query the value of the corresponding field in the specified configuration table (specified by the configuration table name followed by the @ symbol) as the final translation result;

[0102] Special suffix processing (after_suffix): add the specified suffix after the current translation configuration table is translated;

[0103] Special prefix processing (before_prefix): add the specified prefix after the current translation configuration table is translated;

[0104] Special additional data (sql_additional data sql): the value queried by the SQL (Structured Query Language) statement after the translation of the current translation configuration table is completed and the splicing configuration is completed;

[0105] Default value (default): takes the value configured in the TRANS_VALUE_DEFAULT field;

[0106] OTHER_VALUE: The value to be taken when no candidate value is matched.

[0107] Correspondingly, Figure 3 The present invention is a flowchart of a field translation method according to an exemplary embodiment, which is applied to a server. The field translation method includes the following steps.

[0108] In step S21, the second configuration file is parsed to determine the second loading mode.

[0109] In other words, the server also needs to first obtain the corresponding configuration file, namely the second configuration file. The second configuration file can also be represented as trans_cache.xml. The second configuration file and the first configuration file can be the same file, or they can be corresponding but different configuration files, without limitation. By parsing the trans_cache.xml file, the server can understand which modules' translation data needs to be loaded and how this data is loaded.

[0110] Specifically, when the server starts, it first reads and parses the second configuration file to obtain all module_code nodes and their related configuration information, including the load_type, key_code, and value_code fields. The key_code field represents the identifier of a specific translation item or term, and the value_code field is used to store the translation result corresponding to the key_code.

[0111] In step S22, based on the second loading method, the translation data is read from the preset database.

[0112] In this step, the server can construct a data loading thread for each module_code node. These threads will be responsible for loading the translation data of the corresponding module_code node from a preset database. The preset database can be any currently popular relational database, including but not limited to MySQL (My Structured Query Language), PostgreSQL, SQLite, Oracle, and so on.

[0113] Specifically, first, the server can read the load_type field to determine the second loading method corresponding to the current module_code node. For example, if the second loading method is to load translation data through SQL statements, then each module_code can define an SQL statement in the corresponding load_sql node. After the server reads the corresponding SQL statement, it can read the translation data corresponding to the current module_code node from the preset database according to the paging mode.

[0114] Among them, the translation data obtained by the server may need to be further parsed to obtain the required part. Specifically, the server can parse the actual dictionary key value in each translation data according to the key_code and value_code field names (read from the second configuration file). After the parsing is completed, the server can store these key-value pairs in a TransModule object and assign the module_code value to the TransModule.moduleCode field.

[0115] In one implementation, based on the second loading method, reading translation data from a preset database includes:

[0116] Reading an execution statement corresponding to the second loading mode from the second configuration file;

[0117] Based on the executed statement, the translation data is read from the preset database.

[0118] In other words, the second loading method typically uses SQL. This means that the server will directly read the translation data from the preset database. Specifically, each module_code can define a specific SQL statement under the load_sql node. When the server needs to load translation data, it can read the second configuration file, find the corresponding module_code and the SQL statement defined in the load_sql node, and then execute this SQL statement to retrieve the translation data from the preset database.

[0119] In step S23, the translation data is stored in the memory of the server.

[0120] In this step, the server can store the obtained translation data in memory. Specifically, the server can create a Map<moduleCode,TransModule> A data structure is used to store all loaded translation data. For each loaded TransModule object, it is stored along with the corresponding moduleCode in the aforementioned Map. Next, a utility class, Translator, can be defined to provide translation-related services. Within the Translator class, a property, transModuleCache, is defined to store the aforementioned Map data structure.

[0121] That is, in the server's memory, the translation data is in the form of Map<moduleCode,TransModule> . ModuleCode is a unique identifier that corresponds to the value configured in the module_code node in trans_cache.xml. The TransModule object contains a keyValuesMap that stores translation data in the form of key-value pairs.

[0122] In one implementation, storing the translation data in the server's memory includes:

[0123] Store the translation data in the remote dictionary service and in the server's memory;

[0124] In response to an update instruction for any translation data, deleting the any translation data from the memory of the server, and re-reading the any translation data from the preset database based on the second loading method, and re-storing the any translation data into the memory of the server;

[0125] In response to the start-up instruction of the server, the translation data is read from the remote dictionary service and stored in the memory of the server.

[0126] That is to say, if Figure 4 As shown in the figure, the translation data obtained by the server from the preset database will be cached in Redis (Remote Dictionary Server) and a copy will also be stored in the memory. When the server is shut down, the memory will be cleared. When the server is started, the translation data will be directly obtained from Redis and stored in the memory again.

[0127] Among them, Redis is a high-performance key-value storage system that supports multiple types of data structures, such as strings, hashes, lists, sets, etc. Using Redis as a cache layer can significantly improve data access speed.

[0128] In addition to the Redis cache, the server also stores a copy of the translation data in memory. This ensures that when accessing translation data, it can be retrieved directly from memory without having to query Redis each time. This further improves data access efficiency and response speed.

[0129] Furthermore, in this embodiment, the translation data refresh mechanism allows for dynamic refreshing of translation data based on module_code via the interface. Specifically, when refreshing the translation data for a moduleCode, the server first removes the translation data for that moduleCode from memory and simultaneously clears the translation data for that moduleCode from Redis. It then finds the load_sql node corresponding to that moduleCode in the trans_cache.xml file and executes the corresponding second loading method, loading the translation data for that moduleCode from the pre-set database. The loaded translation data is then stored in Redis and memory.

[0130] This step ensures that the translation data in memory is up to date, or at least the state before the refresh operation begins. This ensures that when the server needs to access the translation data, it can quickly retrieve the latest data from memory.

[0131] In one implementation, after storing the translation data in the server's memory, the process further includes:

[0132] Register the preset interface on the service registration platform. The preset interface is used to provide translation data.

[0133] That is to say, the server can select an appropriate registration method according to the settings in the second configuration file or startup parameters, register its own service information (such as service name, IP address, port number, etc.) to the corresponding service registration platform, or directly provide services through the built-in HTTP (Hypertext Transfer Protocol) interface.

[0134] The service registration platform can be a service registration center such as Nacos or Zookeeper. The server registers its service information with the registration center through a communication protocol with the service registration platform. The service registration platform records this information and provides service discovery and management functions so that other services can find and call the plug-in service.

[0135] In addition to registering with the service registry, the server also has a built-in HTTP interface, allowing clients to directly call services through HTTP requests. This approach eliminates the need for intervention from the service registry platform, improving service flexibility and scalability.

[0136] like Figure 5 As shown, the solution in this application is explained below with a specific embodiment.

[0137] Assume that ViewDto has an attribute actionCode (business code), which needs to be translated into a Chinese name and stored in the attribute actionName.

[0138] So, first you need to add a configuration to the translation configuration table. That is, in the Translator.transModuleCache property of the tool class, there is a record with the key TABLE_ACTION_INFO and the value of this record is TransModule. The keyValuesMap property of this TransModule saves all the action_code and action_name values ​​declared in the tb_acion_info table. Suppose the tb_acion_info table has a record with action_code = "ADSLD_001" and action_name = "Broadband Subscription".

[0139] The translation process is as follows:

[0140] Iterating over a List <viewdto>, according to the class name of the translation input parameter ViewDto, recursively upward to its base class name, and uses the class name as the input parameter to query the translation configuration table (CLASS_NAME field) to obtain the corresponding configuration;

[0141] Traverse the translation configuration and obtain the translation data TransModule whose Translator.transModuleCache.moduleCode is TABLE_ACTION_INFO through the TRANS_TABLE field value of the translation configuration table;

[0142] Get the property value of ViewDto.actionCode based on the PROP_NAME field in the translation configuration. Assume it is "ADSLD_001". Get the translation result "Broadband Subscription" through TransModule.keyValuesMap.get("ADSLD_001");

[0143] Determine whether there are additional conditional processing in the translation configuration. If so, perform special processing on the translation results, for example:

[0144] If the TRANS_EXTR_COND field is configured with "after_valid", the translation result will be suffixed with "Broadband subscription - valid";

[0145] If "sql_select now()" is configured, the translation result will be specially processed into "Broadband subscription 2023-11-16 16:00:00";

[0146] If "action_ext_name@table_action_name" is configured, "Broadband Subscription" is used as the parameter, and the action_ext_name field value in the table_action_name table is searched for as the translation result.

[0147] If "default" is configured, the value of the TRANS_VALUE_DEFAULT field will be used as the translation result;

[0148] According to the PROP_VALUE_NAME configuration, the final translation result "Broadband Subscription" is stored in the ViewDto.actionName field to complete the translation.

[0149] As can be seen from the above, the technical solution provided by the embodiment of the present application is that the client and the server can be driven by the first configuration file and the second configuration file respectively, so that the server loads and stores translation data from a preset database, and the client loads translation data from the server. Then, the client can use the translation data to translate the obtained data to be translated. Therefore, neither the client nor the server needs to be coupled with the business code, thereby enhancing the maintainability, flexibility and scalability of the code.

[0150] The field translation method provided in the embodiment of the present application can be executed by a field translation device. In the embodiment of the present application, the method of executing terminal access by the field translation device is taken as an example to illustrate the device of the field translation method provided in the embodiment of the present application.

[0151] Figure 6 This is a block diagram of a field translation device according to an exemplary embodiment, which is applied to a client and includes:

[0152] The parsing module 301 is used to parse the first configuration file and determine the first loading mode;

[0153] A loading module 302, configured to obtain translation data from the memory of the server based on the first loading method;

[0154] The acquisition module 303 is used to acquire data to be translated; the data to be translated includes a class name and a corresponding attribute value;

[0155] The translation module 304 is configured to traverse the translation data, query the translation field corresponding to the class name of the data to be translated, and query the value corresponding to the attribute value of the data to be translated in the translation field as the translation result of the data to be translated.

[0156] Figure 7 This is a block diagram of a field translation device according to an exemplary embodiment, which is applied to a server and includes:

[0157] Determining module 401, configured to parse the second configuration file and determine a second loading mode;

[0158] A reading module 402 is configured to read translation data from a preset database based on the second loading method;

[0159] The storage module 403 is used to store the translation data in the memory of the server.

[0160] As can be seen from the above, the technical solution provided by the embodiment of the present application is that the client and the server can be driven by the first configuration file and the second configuration file respectively, so that the server loads and stores translation data from a preset database, and the client loads translation data from the server. Then, the client can use the translation data to translate the obtained data to be translated. Therefore, neither the client nor the server needs to be coupled with the business code, thereby enhancing the maintainability, flexibility and scalability of the code.

[0161] The field translation method provided in the embodiment of the present application can be executed by a terminal access terminal. In the embodiment of the present application, a method for performing terminal access by a terminal access terminal is taken as an example to illustrate the apparatus of the field translation method provided in the embodiment of the present application.

[0162] The field translation device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than the terminal. Exemplary, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a palmtop computer, a car-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) equipment, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.

[0163] The field translation device provided in the embodiment of the present application can achieve Figures 1 to 5 To avoid repetition, the various processes implemented in the method embodiment are not described here.

[0164] Alternatively, as Figure 8 As shown, an embodiment of the present application also provides an electronic device 500, including a processor 501 and a memory 502, wherein the memory 502 stores a program or instruction that can be run on the processor 501. When the program or instruction is executed by the processor 501, the various steps of the above-mentioned field translation method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0165] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0166] Figure 9 A schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application.

[0167] The electronic device 1000 includes but is not limited to components such as a radio frequency unit 1001 , a network module 1002 , an audio output unit 1003 , an input unit 1004 , a sensor 1005 , a display unit 1006 , a user input unit 1007 , an interface unit 1008 , a memory 1009 , and a processor 1010 .

[0168] Those skilled in the art will understand that the electronic device 1000 may also include a power source (such as a battery) to power each component, and the power source may be logically connected to the processor 1010 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system. Figure 9 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be repeated here.

[0169] As can be seen from the above, the technical solution provided by the embodiment of the present application is that the client and the server can be driven by the first configuration file and the second configuration file respectively, so that the server loads and stores translation data from a preset database, and the client loads translation data from the server. Then, the client can use the translation data to translate the obtained data to be translated. Therefore, neither the client nor the server needs to be coupled with the business code, thereby enhancing the maintainability, flexibility and scalability of the code.

[0170] It should be understood that in an embodiment of the present application, the input unit 1004 may include a graphics processing unit (GPU) 10041 and a microphone 10042, and the graphics processor 10041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 1006 may include a display panel 10061, and the display panel 10061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1007 includes a touch panel 10071 and at least one of other input devices 10072. The touch panel 10071 is also called a touch screen. The touch panel 10071 may include two parts: a touch detection device and a touch controller. Other input devices 10072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and an operating stick, which will not be repeated here.

[0171] The memory 1009 can be used to store software programs and various data. The memory 1009 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, applications or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 1009 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM), and a direct memory bus random access memory (DRRAM). The memory 109 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0172] Processor 1010 may include one or more processing units. Optionally, processor 1010 integrates an application processor and a modem processor. The application processor primarily handles operations related to the operating system, user interface, and application programs, while the modem processor primarily processes wireless communication signals, such as a baseband processor. It is understood that the modem processor may not be integrated into processor 1010.

[0173] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned field translation method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0174] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0175] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned field translation method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0176] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0177] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned field translation method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0178] It should be noted that, in this document, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, but may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0179] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0180] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.< / viewdto>

Claims

1. A field translation method, characterized in that: Applied to a client, the method comprises: Parsing the first configuration file and determining a first loading mode; Based on the first loading method, obtaining translation data from the memory of the server; Acquire data to be translated; the data to be translated includes a class name and a corresponding attribute value; The translation data is traversed, a translation field corresponding to the class name of the data to be translated is searched, and a value corresponding to the attribute value of the data to be translated is searched in the translation field as a translation result of the data to be translated.

2. The field translation method according to claim 1, characterized in that: The traversing the translation data and querying the translation field corresponding to the class name of the data to be translated includes: According to the class name of the data to be translated, a recursive query is performed upwards level by level to determine the base class name of the data to be translated; The translation data is traversed to query the translation field corresponding to the base class name of the data to be translated.

3. The field translation method according to claim 1, characterized in that: The step of searching the translation field for a value corresponding to the attribute value of the data to be translated as a translation result of the data to be translated includes: searching the translation field for a value corresponding to the attribute value of the data to be translated as a candidate value; determining whether the translation data includes additional conditional processing rules; If included, additional condition processing is performed on the candidate value to obtain the translation result of the data to be translated; If not included, the candidate value is used as the translation result of the data to be translated.

4. The field translation method according to claim 1, characterized in that: The acquiring translation data from the memory of the server based on the first loading mode includes: The translation data is obtained from the memory of the server through the preset interface indicated by the first loading method.

5. A field translation method, characterized in that: Applied to the server, including: Parsing the second configuration file and determining the second loading mode; Based on the second loading method, reading translation data from a preset database; The translation data is stored in the memory of the server.

6. The field translation method according to claim 5, characterized in that: The reading of translation data from a preset database based on the second loading mode includes: Reading an execution statement corresponding to the second loading mode from the second configuration file; Based on the execution statement, translation data is read from a preset database.

7. The field translation method according to claim 5, characterized in that: The storing the translation data in the memory of the server includes: Storing the translation data in a remote dictionary service and a memory of the server; In response to an update instruction for any translation data, deleting the any translation data from the memory of the server, and re-reading the any translation data from the preset database based on the second loading mode, and re-storing the any translation data in the memory of the server; In response to the start-up instruction of the server, the translation data is read from the remote dictionary service and the translation data is stored in the memory of the server.

8. The field translation method according to claim 5, characterized in that: After storing the translation data in the memory of the server, the method further includes: The preset interface is registered on the service registration platform, and the preset interface is used to provide the translation data.

9. A field translation device, characterized in that: Applied to a client, the device comprises: A parsing module, used for parsing the first configuration file and determining a first loading mode; A loading module, used for acquiring translation data from the memory of the server based on the first loading mode; An acquisition module, used to acquire data to be translated; the data to be translated includes a class name and a corresponding attribute value; The translation module is used to traverse the translation data, query the translation field corresponding to the class name of the data to be translated, and query the value corresponding to the attribute value of the data to be translated in the translation field as the translation result of the data to be translated.

10. A field translation device, characterized in that: Applied to the server, the device comprises: A determination module, used for parsing the second configuration file and determining the second loading mode; A reading module, used for reading translation data from a preset database based on the second loading mode; The storage module is used to store the translation data in the memory of the server.

11. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the field translation method according to any one of claims 1 to 8.

12. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the field translation method according to any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Entry translation method and device, equipment and storage medium

    CN120633681A