A backend language switching method, device, equipment and storage medium

By intercepting interface data on the back end and using a dictionary table for field replacement, the problems of slow response and security risks in traditional internationalization processing are solved, efficient and secure language switching is achieved, maintenance costs are reduced, and system adaptability is improved.

CN119645554BActive Publication Date: 2025-10-10SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411776771.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-10-10
Estimated Expiration
2044-12-05

AI Technical Summary

Technical Problem

Traditional internationalization processing methods rely on front-end technology, resulting in slow response speed, high maintenance costs, and security risks of directly exposing back-end data to the front-end.

Method used

By intercepting the response data of the target interface at the back end, obtaining the path information and matching it with the preset interface field table, determining the switchable fields, and using the preset dictionary table to replace the fields, real-time translation and dynamic switching of languages ​​can be achieved.

Benefits of technology

It significantly improves language switching efficiency, reduces the time for front-end loading language packs, increases user interface rendering speed, reduces maintenance costs, and enhances system security and flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645554B_ABST
    Figure CN119645554B_ABST
Patent Text Reader

Abstract

The application discloses a backend language switching method and device, equipment and storage medium, and relates to the technical field of computers, and comprises the following steps: if response data of a backend target interface is intercepted, then the path information of the interface is matched with a preset interface field table; based on the switchable field determined by matching, a to-be-converted field in the response data is matched with a preset dictionary table based on the to-be-converted language; if the matching is complete, then the to-be-converted field is replaced by a first target conversion field in the preset dictionary table; if the matching is not complete, then a first to-be-converted field corresponding to the current language and a second to-be-converted field representing a symbol in the to-be-converted field are determined, and the first to-be-converted field is replaced by a second target conversion field corresponding to the first to-be-converted field in the preset dictionary table, and the second to-be-converted field is replaced by a preset placeholder in the preset dictionary table. Therefore, the efficiency of language switching can be improved without modifying the original business code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a back-end language switching method, apparatus, device and storage medium. Background Art

[0002] With the rapid development of globalization and internet technology, multilingual support has become an essential feature of modern software applications. This is particularly true for multinational enterprises, cross-border e-commerce platforms, and web and mobile applications targeting a global audience. Providing multilingual interfaces and content has become a key factor in attracting and retaining users. However, traditional internationalization approaches often rely on front-end technology, dynamically loading language packages on the client based on the user's language selection. While this approach meets multilingual requirements to a certain extent, it also presents issues such as slow response times, high maintenance costs, and potential security risks associated with directly exposing back-end data to the front-end. Summary of the Invention

[0003] In view of this, the purpose of the present invention is to provide a backend language switching method, apparatus, device and storage medium, which can significantly improve the efficiency of language switching without modifying the original business code. The specific solution is as follows:

[0004] In a first aspect, the present application discloses a backend language switching method, comprising:

[0005] If the response data of the target interface of the backend is intercepted, the path information corresponding to the target interface is obtained, and the path information is matched with the preset interface field table to determine the switchable fields;

[0006] Determining a plurality of to-be-converted fields in the response data based on the switchable fields, and determining a current language and a to-be-converted language corresponding to the response data, so as to match the plurality of to-be-converted fields with a preset dictionary table based on the to-be-converted language;

[0007] If there is a complete match, replacing the plurality of to-be-converted fields based on a plurality of first target conversion fields corresponding to the plurality of to-be-converted fields in the preset dictionary table;

[0008] If there is no complete match, several first fields to be converted corresponding to the current language and several second fields to be converted representing symbols among the several fields to be converted are determined, and the several first fields to be converted are replaced by several second target conversion fields corresponding to the several first fields to be converted in the preset dictionary table, and the several second fields to be converted are replaced by preset placeholders in the preset dictionary table.

[0009] Optionally, if the response data of the target interface of the backend is intercepted, obtaining the path information corresponding to the target interface and matching the path information with the preset interface field table to determine the switchable field includes:

[0010] Determine whether there is a target interface for data feedback among the multiple data interfaces of the backend; if the target interface exists, intercept data from the target interface to obtain response data fed back by the target interface;

[0011] Path information corresponding to the target interface is obtained, and the path information is matched with a preset interface field table to determine a switchable field type corresponding to the target interface, and a switchable field is determined according to the switchable field type.

[0012] Optionally, determining a number of to-be-converted fields in the response data based on the switchable field, and determining a current language and a to-be-converted language corresponding to the response data, so as to match the number of to-be-converted fields with a preset dictionary table based on the to-be-converted language, includes:

[0013] Extracting a plurality of fields to be converted corresponding to the switchable fields in the response data;

[0014] Determining a current language corresponding to the response data, and determining a language to be converted corresponding to the response data according to the received language conversion instruction;

[0015] The plurality of to-be-converted fields are matched with fields corresponding to the to-be-converted language in a preset dictionary table.

[0016] Optionally, if there is a complete match, replacing the multiple fields to be converted based on multiple first target conversion fields corresponding to the multiple fields to be converted in the preset dictionary table includes:

[0017] If the plurality of to-be-converted fields completely match the fields corresponding to the language to-be-converted in the preset dictionary table, extracting a plurality of first target conversion fields corresponding to the plurality of to-be-converted fields from the preset dictionary table; the plurality of first target conversion fields being fields corresponding to the language to-be-converted;

[0018] The plurality of to-be-converted fields are replaced based on the plurality of first target conversion fields.

[0019] Optionally, if a complete match cannot be made, determining several first fields to be converted corresponding to the current language and several second fields to be converted representing symbols among the several fields to be converted, and replacing the several first fields to be converted with several second target conversion fields corresponding to the several first fields to be converted in the preset dictionary table, and replacing the several second fields to be converted with preset placeholders in the preset dictionary table, includes:

[0020] If the plurality of to-be-converted fields do not completely match the fields corresponding to the to-be-converted language in the preset dictionary table, extracting a plurality of first to-be-converted fields corresponding to the current language from the plurality of to-be-converted fields, and using the fields that do not match the current language from the plurality of to-be-converted fields as a plurality of second to-be-converted fields representing symbols;

[0021] Matching the first to-be-converted fields with the preset dictionary table to determine a number of second target conversion fields corresponding to the first to-be-converted fields, and replacing the first to-be-converted fields with the second target conversion fields;

[0022] Extracting placeholders from the preset dictionary table, and replacing the plurality of second fields to be converted with the placeholders.

[0023] Optionally, the backend language switching method further includes:

[0024] If the plurality of to-be-converted fields do not completely match the fields corresponding to the to-be-converted language in the preset dictionary table, and the plurality of first to-be-converted fields do not completely match the preset dictionary table, then the backend language switching is exited.

[0025] Optionally, the backend language switching method further includes:

[0026] If a new language request is received, determining a target new language corresponding to the new language request, and obtaining a target new language package corresponding to the target new language;

[0027] The preset dictionary table is updated based on the target new language package, so as to provide a language switching service corresponding to the target new language based on the obtained updated dictionary table.

[0028] In a second aspect, the present application discloses a backend language switching device, comprising:

[0029] An information matching module is used to obtain path information corresponding to the target interface if the response data of the target interface of the backend is intercepted, and match the path information with the preset interface field table to determine the switchable field;

[0030] a field matching module, which determines a plurality of to-be-converted fields in the response data based on the switchable fields, and determines a current language and a to-be-converted language corresponding to the response data, so as to match the plurality of to-be-converted fields with a preset dictionary table based on the to-be-converted language;

[0031] a first field conversion module, configured to replace the plurality of to-be-converted fields based on a plurality of first target conversion fields corresponding to the plurality of to-be-converted fields in the preset dictionary table if there is a complete match;

[0032] The second field conversion module is used to determine, if a complete match cannot be made, several first fields to be converted corresponding to the current language and several second fields to be converted representing symbols among the several fields to be converted, and replace the several first fields to be converted with several second target conversion fields corresponding to the several first fields to be converted in the preset dictionary table, and replace the several second fields to be converted with preset placeholders in the preset dictionary table.

[0033] In a third aspect, the present application discloses an electronic device, comprising:

[0034] Memory, used to store computer programs;

[0035] The processor is configured to execute the computer program to implement the aforementioned back-end language switching method.

[0036] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program, wherein the computer program implements the aforementioned backend language switching method when executed by a processor.

[0037] In the present application, after intercepting the response data of the target interface of the back-end, the path information corresponding to the target interface can be obtained, and the path information can be matched with the preset interface field table to determine the switchable fields; then, based on the switchable fields, several fields to be converted in the response data are determined, and the current language and the language to be converted corresponding to the response data are determined, so as to match the several fields to be converted with the preset dictionary table based on the language to be converted; if there is a complete match, the several fields to be converted are replaced based on several first target conversion fields corresponding to the several fields to be converted in the preset dictionary table; if there is not a complete match, several first fields to be converted corresponding to the current language and several second fields to be converted representing symbols in the several fields to be converted are determined, and the several first fields to be converted are replaced by the several second target conversion fields corresponding to the several first fields to be converted in the preset dictionary table, and the several second fields to be converted are replaced by the preset placeholders in the preset dictionary table. It can be seen that, through the method of the present application, after intercepting the response data of the target interface of the back-end, the path information corresponding to the target interface is matched with the preset interface field table to determine the switchable field, and then the field to be converted in the response data is determined based on the switchable field, and then the field to be converted is matched with the preset dictionary table. If it can be fully matched, the field to be converted is replaced according to the target conversion field in the dictionary table. If it cannot be fully matched, it is necessary to determine several first fields to be converted corresponding to the current language and several second fields to be converted representing symbols in the field to be converted, and replace the first field to be converted with the field in the preset dictionary table, and replace the second field to be converted with the preset placeholder. In this way, by setting the language dictionary table, interface and field table and interceptor logic, real-time translation and dynamic language switching of the interface response data can be achieved. And by calling the back-end interface to switch the language, the efficiency of language switching can be significantly improved without modifying the original business code, effectively improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0039] Figure 1 This is a flow chart of a back-end language switching method disclosed in this application;

[0040] Figure 2 This is an interface field representation disclosed in this application;

[0041] Figure 3 A dictionary representation is disclosed in this application;

[0042] Figure 4 This is a schematic diagram of a back-end language switching system disclosed in this application;

[0043] Figure 5 This is a schematic diagram of the processing logic of a back-end language switching system disclosed in this application;

[0044] Figure 6 This is a schematic structural diagram of a back-end language switching device disclosed in this application;

[0045] Figure 7 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0046] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0047] Traditional internationalization methods often rely on front-end technology, dynamically loading language packages based on the user's language selection on the client side. While this approach meets multilingual requirements to a certain extent, it also presents issues such as slow response times, high maintenance costs, and potential security risks associated with directly exposing back-end data to the front-end.

[0048] In order to overcome the above technical problems, the present application discloses a back-end language switching method, apparatus, device and storage medium, which can significantly improve the efficiency of language switching without modifying the original business code.

[0049] See also Figure 1 As shown, an embodiment of the present invention discloses a backend language switching method, including:

[0050] Step S11: If the response data of the target interface of the backend is intercepted, the path information corresponding to the target interface is obtained, and the path information is matched with the preset interface field table to determine the switchable field.

[0051] In this embodiment, it is necessary to intercept the response data of the back-end interface, and then determine the path information of the intercepted interface, and match the preset interface field table according to the path information to determine the switchable field corresponding to the path information in the preset interface field table. Specifically, it is necessary to determine whether there is a target interface for data feedback among the several data interfaces of the back-end. If there is a target interface for data feedback, the data of the target interface is intercepted to obtain the response data fed back by the target interface. It should be noted that when intercepting data, it is necessary to intercept it through the interceptor set in the language switching system, and the interceptor can translate the fields that need to be internationalized in the response message of the interface according to the language environment. The language environment refers to the current language of the field in the current response message and the language that needs to be converted to, that is, the language to be converted.

[0052] Furthermore, after intercepting the response data of the target interface, it is necessary to obtain the path information corresponding to the target interface and match the path information with the preset interface field table to determine the switchable field type corresponding to the target interface, and determine the switchable field according to the switchable field type. Specifically, Figure 2 As shown, the URI (Uniform Resource Identifier) ​​path information corresponding to the target interface must be obtained and matched against the preset interface field table to determine the switchable field type corresponding to the target interface. The switchable fields are then determined based on the determined switchable field type. It should be noted that the interface field table stores which fields for each interface require language switching. For example, if the input language needs to be converted to English, but the user currently enters English in the input field, no language switching is required. For messages corresponding to certain interfaces, the code field does not require language switching, but the name field does. In this case, the name field is assigned to this table. For example, the URI in the message represents the interface URI path, and the field represents the field name. If a field has a hierarchy, the dot (.) is used to indicate the hierarchy, such as productTypeList.name. This allows precise control over which fields in each interface require internationalization, reducing maintenance costs and effectively improving management efficiency.

[0053] Step S12: determining a number of fields to be converted in the response data based on the switchable fields, and determining a current language and a language to be converted corresponding to the response data, so as to match the fields to be converted with a preset dictionary table based on the language to be converted.

[0054] In this embodiment, it is necessary to determine the fields to be converted in the response data based on the determined switchable fields, and then match the fields to be converted with the preset dictionary table based on the language to be converted corresponding to the response data. Specifically, it is necessary to extract several fields to be converted in the response data corresponding to the switchable fields. That is, after determining the switchable fields corresponding to the target interface in the interface field, it is necessary to convert the body of the response data into a JsonNode, and then traverse the JsonNode to determine the fields corresponding to the switchable fields, and use the fields corresponding to the switchable fields as the fields to be converted to obtain several fields to be converted. Then it is necessary to determine the current language corresponding to the response data, and determine the language to be converted corresponding to the response data based on the received language conversion instruction. For example, if the field in the current response data is Chinese, and according to the received instruction, the Chinese in the field needs to be converted to English, then the current language corresponding to the response data is Chinese, and the corresponding language to be converted is English. Further, it is necessary to match the determined several fields to be converted with the fields corresponding to the language to be converted in the preset dictionary table. In this way, the language of the interface response data can be dynamically adjusted according to the user's language environment or choice, meeting the user's personalized language needs and improving the flexibility and adaptability of the system.

[0055] Step S13: If there is a complete match, the plurality of to-be-converted fields are replaced based on a plurality of first target conversion fields corresponding to the plurality of to-be-converted fields in the preset dictionary table.

[0056] In this embodiment, when matching the to-be-converted field with the field corresponding to the to-be-converted language in the preset dictionary table, an exact match must first be performed on the to-be-converted field. Specifically, if several to-be-converted fields in the determined response data completely match the fields corresponding to the to-be-converted language in the preset dictionary table, several first target conversion fields corresponding to the several to-be-converted fields are extracted from the preset dictionary table; wherein the several first target conversion fields are fields corresponding to the to-be-converted language, and then the several to-be-converted fields are replaced based on the several first target conversion fields. It should be noted that an exact match requires a complete match of the string. For example, if the interface's return message data contains the field value "云客户端" (cloud server), the Chinese column of the language dictionary table must contain the text value "云客户端" (cloud server). If at least one of the several to-be-converted fields fails to match the preset dictionary table, this indicates a failure of the exact match.

[0057] It should be noted that the preset dictionary table stores text information in each language, each column represents a language, and each row represents the same text information in different languages, such as Figure 3As shown, zh represents the Chinese column, en represents the English column, and language columns can be added, where the first column is the original language column, and the original language is the default language text in the interface response message, such as Chinese data returned by the backend interface data without switching languages. When the language is switched, the text that can match the first column is translated into the text in the corresponding language. For example, the original response message is as follows:

[0058] {

[0059] "code": "ECS",

[0060] "name": "Cloud Server",

[0061] "productTypeList": [{

[0062] "name": "FPGA model",

[0063] }]

[0064] }.

[0065] If the language information in the message header of the interface feedback is English, the text that can match the zh column is converted into the text in the en column, and the converted message is as follows:

[0066] {

[0067] "code": "ECS",

[0068] "name": "Cloud Server",

[0069] "productTypeList": [{

[0070] "name": "FPGA model",

[0071] }]

[0072] }.

[0073] Step S14, if the complete matching fails, determining a plurality of first to-be-converted fields corresponding to the current language and a plurality of second to-be-converted fields representing symbols in the plurality of to-be-converted fields, and replacing the plurality of first to-be-converted fields with a plurality of second target conversion fields corresponding to the plurality of first to-be-converted fields in the preset dictionary table, and replacing the plurality of second to-be-converted fields with a preset placeholder in the preset dictionary table.

[0074] In this embodiment, if an exact match fails, a locator match is performed. Specifically, if the fields to be converted do not fully match the fields corresponding to the language to be converted in the preset dictionary table, it is necessary to extract the first fields to be converted that correspond to the current language from the fields to be converted, and use the fields that do not match the current language as the second fields to be converted, representing the symbols. Specifically, the string is divided into two parts: the default language (the current language) and the non-default language. For example, if the default language is Chinese, during placeholder matching, the string is divided into the first fields to be converted that correspond to the Chinese portion and the second fields to be converted that correspond to the non-Chinese portion. The Chinese portion remains unchanged, while the non-Chinese portion is replaced with a placeholder. The first fields to be converted are then matched against the preset dictionary table to determine the second target conversion fields corresponding to the first fields to be converted. The first fields to be converted are then replaced with the second target conversion fields. Finally, the placeholders in the preset dictionary table are extracted, and the second fields to be converted are replaced with the placeholders. For example, if the text information in the response data is "The CPU usage of host: test-001 is higher than 20%", the text after placeholder replacement is "The {2} usage of host {1} is higher than {3}". Then, the Chinese part of the replaced text "The {2} usage of host {1} is higher than {3}" is matched with the preset dictionary table, and the Chinese part is converted into the language to be converted.

[0075] It should be noted that the back-end language switching method in the present application also includes: if the several to-be-converted fields do not completely match the fields corresponding to the to-be-converted language in the preset dictionary table, and the several first to-be-converted fields do not completely match the preset dictionary table, then exiting the back-end language switching. That is, if the several to-be-converted fields in the response data do not completely match the fields corresponding to the to-be-converted language in the preset dictionary table, locator matching is required, but when performing locator matching, if the first to-be-converted field corresponding to the current language does not completely match the field corresponding to the to-be-converted language in the preset dictionary table, then it is necessary to directly exit the language switching.

[0076] It should be further explained that the back-end language switching method in the present application also includes: if a new language request is received, the target new language corresponding to the new language request is determined, and the target new language package corresponding to the target new language is obtained; based on the target new language package, the preset dictionary table is updated to provide a language switching service corresponding to the target new language based on the updated dictionary table. That is, if a new language request is received, the target new language corresponding to the new language request needs to be added to the preset dictionary table. First, the target new language package corresponding to the target new language needs to be obtained, and then the target new language package is updated to the preset dictionary table, and the language switching service corresponding to the target new language is provided through the updated updated dictionary table. For example, if a new language request for Spanish is received, the Spanish language package needs to be obtained and installed into the new dictionary table, and then the Spanish language switching service is provided through the updated new dictionary table. In this way, the supported language types and interface ranges can be expanded to meet possible multilingual needs in the future, effectively improving the user experience.

[0077] It can be seen that, through the method of the present application, after intercepting the response data of the target interface of the back-end, the path information corresponding to the target interface is matched with the preset interface field table to determine the switchable field, and then the field to be converted in the response data is determined based on the switchable field, and then the field to be converted is matched with the preset dictionary table. If a complete match is possible, the field to be converted is replaced according to the target conversion field in the dictionary table. If a complete match is not possible, it is necessary to determine several first fields to be converted corresponding to the current language and several second fields to be converted representing symbols in the field to be converted, and replace the first field to be converted by the field in the preset dictionary table, and replace the second field to be converted by the preset placeholder. In this way, on the one hand, by performing translation directly on the back end, the time required for loading language packs on the front end is greatly reduced, thereby speeding up the user interface rendering speed, enabling users to obtain the required information more quickly, and avoiding direct exposure of sensitive back-end data to the front end. By performing translation processing on the back end, potential security risks are effectively reduced, the security of the system is enhanced, and the user experience is significantly improved; on the other hand, by introducing the interface field table and the dictionary table, it is precisely controlled which fields of which interfaces need to be internationalized, further reducing maintenance costs and improving management efficiency; on the other hand, the language of the interface response data can be dynamically adjusted according to the user's language environment or choice to meet the user's personalized language needs, and the back-end interface return data can be converted according to the language without modifying the original business code, thereby improving the flexibility and adaptability of the system.

[0078] See also Figure 4As shown, an embodiment of the present invention discloses a backend language switching system, including:

[0079] In this embodiment, Figure 4 As shown in the figure, the backend language switching system mainly includes a cache module, an interceptor module, and a text matching module. The cache module is mainly used to cache data in the preset dictionary table and the preset interface field table, so as to avoid frequent database requests when switching languages. The interceptor module is used to intercept all interface URI data and the body data in the response message, convert the information in the response message body data into the corresponding language, and then return it to the caller. The specific logic is to first perform an exact match on the data. If the exact match fails, it will perform a placeholder match. The text matching module mainly performs an exact match and a placeholder match on the data.

[0080] It should be noted that the execution logic of the backend language switching system is as follows Figure 5 As shown, it is first necessary to intercept the interface response data, then obtain the URI path information corresponding to the target interface, and match the URI path information with the preset interface field table to determine the switchable fields, and determine several fields to be converted in the response data based on the switchable fields, and accurately match the several fields to be converted with the preset dictionary table, and the matching language is the language to be converted. If all fields have matching fields of the language to be converted in the preset dictionary table, the exact match is successful, and the fields to be converted are replaced with the fields with successful matching. If the match fails, fuzzy matching, that is, placeholder matching, is performed. It is necessary to determine several first fields to be converted corresponding to the current language and several second fields to be converted representing symbols in the several fields to be converted, and then match the several first fields to be converted with the preset dictionary table. If all match successfully, the first fields to be converted are replaced with the fields with successful matching, and the second fields to be converted are replaced with the placeholders in the preset dictionary table. If the several first fields to be converted cannot be completely matched with the preset dictionary table, the language conversion is exited.

[0081] See also Figure 6 As shown, an embodiment of the present invention discloses a backend language switching device, comprising:

[0082] The information matching module 11 is used to obtain the path information corresponding to the target interface if the response data of the target interface of the backend is intercepted, and match the path information with the preset interface field table to determine the switchable field;

[0083] A field matching module 12 determines a plurality of to-be-converted fields in the response data based on the switchable fields, and determines a current language and a to-be-converted language corresponding to the response data, so as to match the plurality of to-be-converted fields with a preset dictionary table based on the to-be-converted language;

[0084] A first field conversion module 13 is configured to replace the plurality of to-be-converted fields based on a plurality of first target conversion fields corresponding to the plurality of to-be-converted fields in the preset dictionary table if there is a complete match;

[0085] The second field conversion module 14 is configured to determine, if a complete match cannot be achieved, several first fields to be converted corresponding to the current language and several second fields to be converted representing symbols among the several fields to be converted, and replace the several first fields to be converted with several second target conversion fields corresponding to the several first fields to be converted in the preset dictionary table, and replace the several second fields to be converted with preset placeholders in the preset dictionary table.

[0086] In this embodiment, after intercepting the response data of the target interface of the back-end, path information corresponding to the target interface can be obtained, and the path information can be matched with the preset interface field table to determine the switchable fields; then, based on the switchable fields, several fields to be converted in the response data are determined, and the current language and the language to be converted corresponding to the response data are determined, so as to match the several fields to be converted with the preset dictionary table based on the language to be converted; if there is a complete match, the several fields to be converted are replaced based on several first target conversion fields corresponding to the several fields to be converted in the preset dictionary table; if there is not a complete match, several first fields to be converted corresponding to the current language and several second fields to be converted representing symbols in the several fields to be converted are determined, and the several first fields to be converted are replaced by several second target conversion fields corresponding to the several first fields to be converted in the preset dictionary table, and the several second fields to be converted are replaced by preset placeholders in the preset dictionary table. It can be seen that, through the method of the present application, after intercepting the response data of the target interface of the backend, the path information corresponding to the target interface is matched with the preset interface field table to determine the switchable field, and then the field to be converted in the response data is determined based on the switchable field, and then the field to be converted is matched with the preset dictionary table. If it can be fully matched, the field to be converted is replaced according to the target conversion field in the dictionary table. If it cannot be fully matched, it is necessary to determine several first fields to be converted corresponding to the current language and several second fields to be converted representing symbols in the field to be converted, and replace the first field to be converted with the field in the preset dictionary table, and replace the second field to be converted with the preset placeholder. In this way, the real-time translation and dynamic language switching of the interface response data can be achieved by setting the language dictionary table, interface and field table and interceptor logic. And by calling the backend interface to switch the language, the efficiency of language switching can be significantly improved without modifying the original business code, effectively improving the user experience.

[0087] In some embodiments, the information matching module 11 may specifically include:

[0088] A data interception unit is used to determine whether there is a target interface for data feedback among the multiple data interfaces of the back end, and if so, intercept the data of the target interface to obtain the response data fed back by the target interface;

[0089] The switchable field determination unit is used to obtain path information corresponding to the target interface, match the path information with a preset interface field table to determine the switchable field type corresponding to the target interface, and determine the switchable field according to the switchable field type.

[0090] In some embodiments, the field matching module 12 may specifically include:

[0091] a field-to-be-converted extraction unit, configured to extract a plurality of fields to be converted corresponding to the switchable fields in the response data;

[0092] a language determining unit, configured to determine a current language corresponding to the response data, and determine a language to be converted corresponding to the response data according to a received language conversion instruction;

[0093] The field matching unit is used to match the plurality of to-be-converted fields with fields corresponding to the to-be-converted language in a preset dictionary table.

[0094] In some embodiments, the first field conversion module 13 may specifically include:

[0095] a first field extraction unit configured to extract, from the preset dictionary table, a plurality of first target conversion fields corresponding to the plurality of to-be-converted fields if the plurality of to-be-converted fields completely match the fields corresponding to the language to-be-converted in the preset dictionary table; the plurality of first target conversion fields being fields corresponding to the language to-be-converted;

[0096] The first field conversion unit is configured to replace the plurality of to-be-converted fields based on the plurality of first target conversion fields.

[0097] In some embodiments, the second field conversion module 14 may specifically include:

[0098] a second field extraction unit configured to extract, if the plurality of to-be-converted fields do not completely match the fields corresponding to the to-be-converted language in the preset dictionary table, a plurality of first to-be-converted fields corresponding to the current language from the plurality of to-be-converted fields, and use the fields that do not match the current language from the plurality of to-be-converted fields as a plurality of second to-be-converted fields representing symbols;

[0099] a second field conversion unit, configured to match the plurality of first to-be-converted fields with the preset dictionary table to determine a plurality of second target conversion fields corresponding to the plurality of first to-be-converted fields, and replace the plurality of first to-be-converted fields with the plurality of second target conversion fields;

[0100] The third field conversion unit is configured to extract placeholders from the preset dictionary table and replace the plurality of second fields to be converted with the placeholders.

[0101] In some embodiments, the backend language switching device may specifically include:

[0102] The language switching exit unit is configured to exit the backend language switching if the plurality of to-be-converted fields do not completely match the fields corresponding to the to-be-converted language in the preset dictionary table, and the plurality of first to-be-converted fields do not completely match the preset dictionary table.

[0103] In some embodiments, the backend language switching device may specifically include:

[0104] a new language package acquiring unit, configured to, upon receiving a new language request, determine a target new language corresponding to the new language request, and acquire a target new language package corresponding to the target new language;

[0105] The dictionary table updating unit is configured to update the preset dictionary table based on the target new language package, so as to provide a language switching service corresponding to the target new language based on the obtained updated dictionary table.

[0106] Furthermore, the embodiment of the present application also discloses an electronic device, Figure 7 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram should not be considered as any limitation to the scope of application of the present application.

[0107] Figure 7 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the back-end language switching method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0108] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0109] In addition, the memory 22 as a carrier for resource storage can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0110] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, and can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of implementing the back-end language switching method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program capable of implementing other specific tasks.

[0111] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the backend language switching method disclosed above is implemented. For the specific steps of this method, please refer to the corresponding content disclosed in the above embodiments and will not be repeated here.

[0112] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from the other embodiments. Reference can be made to the descriptions of the identical or similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and the relevant parts can be referred to the descriptions of the methods.

[0113] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0114] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0115] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such 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 elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0116] The above is a detailed introduction to the technical solution provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A backend language switching method, characterized in that: include: If the response data of the target interface of the backend is intercepted, the path information corresponding to the target interface is obtained, and the path information is matched with the preset interface field table to determine the switchable fields; Determining a plurality of to-be-converted fields in the response data based on the switchable fields, and determining a current language and a to-be-converted language corresponding to the response data, so as to match the plurality of to-be-converted fields with a preset dictionary table based on the to-be-converted language; If there is a complete match, replacing the fields to be converted based on the first target conversion fields corresponding to the fields to be converted in the preset dictionary table; If a complete match cannot be found, determining a number of first fields to be converted corresponding to the current language and a number of second fields to be converted representing symbols among the number of fields to be converted, and replacing the number of first fields to be converted with a number of second target conversion fields corresponding to the number of first fields to be converted in the preset dictionary table, and replacing the number of second fields to be converted with preset placeholders in the preset dictionary table; If a complete match cannot be made, determining several first fields to be converted corresponding to the current language and several second fields to be converted representing symbols among the several fields to be converted, and replacing the several first fields to be converted with several second target conversion fields corresponding to the several first fields to be converted in the preset dictionary table, and replacing the several second fields to be converted with preset placeholders in the preset dictionary table, includes: If the plurality of to-be-converted fields do not completely match the fields corresponding to the to-be-converted language in the preset dictionary table, extracting a plurality of first to-be-converted fields corresponding to the current language from the plurality of to-be-converted fields, and using the fields that do not match the current language from the plurality of to-be-converted fields as a plurality of second to-be-converted fields representing symbols; Matching the first to-be-converted fields with the preset dictionary table to determine a number of second target conversion fields corresponding to the first to-be-converted fields, and replacing the first to-be-converted fields with the second target conversion fields; Extracting placeholders from the preset dictionary table, and replacing the plurality of second fields to be converted with the placeholders.

2. The backend language switching method according to claim 1, characterized in that: If the response data of the target interface of the backend is intercepted, the path information corresponding to the target interface is obtained, and the path information is matched with the preset interface field table to determine the switchable field, including: Determine whether there is a target interface for data feedback among the multiple data interfaces of the backend; if the target interface exists, intercept data from the target interface to obtain response data fed back by the target interface; Path information corresponding to the target interface is obtained, and the path information is matched with a preset interface field table to determine a switchable field type corresponding to the target interface, and a switchable field is determined according to the switchable field type.

3. The backend language switching method according to claim 1, characterized in that: The determining, based on the switchable field, a number of to-be-converted fields in the response data, and determining a current language and a to-be-converted language corresponding to the response data, so as to match the number of to-be-converted fields with a preset dictionary table based on the to-be-converted language, includes: Extracting a plurality of fields to be converted corresponding to the switchable fields in the response data; Determining a current language corresponding to the response data, and determining a language to be converted corresponding to the response data according to the received language conversion instruction; The plurality of to-be-converted fields are matched with fields corresponding to the to-be-converted language in a preset dictionary table.

4. The backend language switching method according to claim 1, characterized in that: If there is a complete match, replacing the plurality of to-be-converted fields based on a plurality of first target conversion fields corresponding to the plurality of to-be-converted fields in the preset dictionary table includes: If the plurality of to-be-converted fields completely match the fields corresponding to the language to-be-converted in the preset dictionary table, extracting a plurality of first target conversion fields corresponding to the plurality of to-be-converted fields from the preset dictionary table; the plurality of first target conversion fields being fields corresponding to the language to-be-converted; The plurality of to-be-converted fields are replaced based on the plurality of first target conversion fields.

5. The backend language switching method according to claim 1, characterized in that: Also includes: If the plurality of to-be-converted fields do not completely match the fields corresponding to the to-be-converted language in the preset dictionary table, and the plurality of first to-be-converted fields do not completely match the preset dictionary table, then the backend language switching is exited.

6. The backend language switching method according to any one of claims 1 to 5, characterized in that: Also includes: If a new language request is received, determining a target new language corresponding to the new language request, and obtaining a target new language package corresponding to the target new language; The preset dictionary table is updated based on the target new language package, so as to provide a language switching service corresponding to the target new language based on the obtained updated dictionary table.

7. A back-end language switching device, characterized in that: include: An information matching module is used to obtain path information corresponding to the target interface if the response data of the target interface of the backend is intercepted, and match the path information with the preset interface field table to determine the switchable field; a field matching module, which determines a plurality of to-be-converted fields in the response data based on the switchable fields, and determines a current language and a to-be-converted language corresponding to the response data, so as to match the plurality of to-be-converted fields with a preset dictionary table based on the to-be-converted language; a first field conversion module, configured to replace the plurality of to-be-converted fields based on a plurality of first target conversion fields corresponding to the plurality of to-be-converted fields in the preset dictionary table if there is a complete match; a second field conversion module, configured to, if a complete match cannot be achieved, determine, among the plurality of fields to be converted, a plurality of first fields to be converted corresponding to the current language and a plurality of second fields to be converted representing symbols, and replace the plurality of first fields to be converted with a plurality of second target conversion fields corresponding to the plurality of first fields to be converted in the preset dictionary table, and replace the plurality of second fields to be converted with preset placeholders in the preset dictionary table; The second field conversion module includes: a second field extraction unit configured to extract, if the plurality of to-be-converted fields do not completely match the fields corresponding to the to-be-converted language in the preset dictionary table, a plurality of first to-be-converted fields corresponding to the current language from the plurality of to-be-converted fields, and use the fields that do not match the current language from the plurality of to-be-converted fields as a plurality of second to-be-converted fields representing symbols; a second field conversion unit, configured to match the plurality of first to-be-converted fields with the preset dictionary table to determine a plurality of second target conversion fields corresponding to the plurality of first to-be-converted fields, and replace the plurality of first to-be-converted fields with the plurality of second target conversion fields; The third field conversion unit is configured to extract placeholders from the preset dictionary table and replace the plurality of second fields to be converted with the placeholders.

8. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the back-end language switching method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that Used to store a computer program, wherein when the computer program is executed by a processor, the backend language switching method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Content replacement method and device, equipment and storage medium

    CN116501855A

  • Application internationalization implementation method and device, electronic equipment and storage medium

    CN118276971A