Code multilingualization method, device, equipment, storage medium and program product

By identifying recognizable variables and language identifiers in the code's runtime environment, the problem of cumbersome multilingual code operations and poor readability is solved. Intelligent multilingual switching is achieved, improving efficiency and accuracy, and avoiding data redundancy and translation inconsistencies.

CN122173059APending Publication Date: 2026-06-09PATEO CONNECT (NANJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
PATEO CONNECT (NANJING) CO LTD
Filing Date
2024-12-09
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

In technology stacks such as Java, Android, iOS, and Flutter, Chinese developers face problems such as cumbersome operations, poor readability, and redundant multilingual configuration files when converting code to multiple languages. Furthermore, different developers do not use consistent English translations for the same Chinese identifiers.

Method used

By identifying code variables that can be recognized by the code execution environment, and based on the target original language text and language identifiers, the target original language text in the source code is replaced with the variable to be replaced, thus achieving multilingualization. The translation language text is adjusted using language identifiers, simplifying the operation and improving accuracy.

Benefits of technology

It enables intelligent multilingual code operation, reduces omissions and errors, improves conversion efficiency and accuracy, maintains code readability, and avoids data redundancy and translation inconsistencies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122173059A_ABST
    Figure CN122173059A_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure disclose a code multilingualization method, device, equipment, storage medium and program product, wherein the code multilingualization method comprises: determining a code variable capable of being recognized by a current code running environment; the code variable comprises original language text in source code and translated language text of the original language text in multiple languages; based on target original language text to be processed, the code variable and language identification, determining a to-be-replaced variable corresponding to the target original language text; replacing the target original language text in the source code with the to-be-replaced variable to obtain multilingual source code; the to-be-replaced variable is used to adjust the translated language text corresponding to the target original language text based on the language identification. In this way, the multilingual switching of the original language text in the source code can be intelligently realized, the operation is simple, and the applicability is strong.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to, but is not limited to, the field of computer technology, and in particular to a method, apparatus, device, storage medium, and program product for code multilingualization. Background Technology

[0002] In various technology stacks such as Java, Android, iOS, Flutter, and Hyper Text Markup Language 5 (H5), Chinese developers typically write code in Chinese. To achieve multilingual code, variables in the code need to be changed from Chinese to English. However, a single variable might be translated into different English forms by different developers, leading to cumbersome operations and poor readability. Summary of the Invention

[0003] In view of the above, embodiments of this disclosure provide at least one method, apparatus, device, storage medium, and program product for code multilingualization.

[0004] The technical solution of this disclosure embodiment is implemented as follows:

[0005] On one hand, embodiments of this disclosure provide a code multilingualization method, which includes: determining code variables that can be recognized by the current code execution environment; the code variables include the original language text in the source code and the translated language text of the original language text in multiple languages; determining the variable to be replaced corresponding to the target original language text based on the target original language text to be processed, the code variables, and the language identifier; replacing the target original language text in the source code with the variable to be replaced to obtain multilingualized source code; the variable to be replaced is used to adjust the translated language text corresponding to the target original language text based on the language identifier.

[0006] In some embodiments, the determination of code variables that can be recognized by the current code runtime environment includes: extracting the original language text from the source code; obtaining the translated language text of the original language text in multiple languages; and determining the code variables that can be recognized by the current code runtime environment based on the original language text and the translated language text.

[0007] In some embodiments, the above extraction of original language text from source code includes at least one of the following: extracting original language text from source code using regular expressions; parsing source code into a syntax tree structure and extracting original language text from source code based on the smallest structural unit in the syntax tree structure; or extracting original language text from source code using an extraction tool.

[0008] In some embodiments, the above-mentioned determination of code variables that can be recognized by the current code execution environment based on the original language text and the translated language text includes: using the original language text as a key information item and the translated language text corresponding to each original language text as a value information item to obtain a key-value pair corresponding to each original language text; and generating code variables that can be recognized by the current code execution environment based on the key-value pairs.

[0009] In some embodiments, determining the variable to be replaced corresponding to the target original language text based on the target original language text to be processed, the code variable, and the language identifier includes: taking the code variable as A, taking the target original language text as key, and taking the language identifier as lang, to obtain the variable to be replaced A[lang][key]; the code variable contains all the original language texts and multiple translated language texts corresponding to each original language text.

[0010] In some embodiments, the code multilingualization method further includes: adding the newly added original language text and / or the newly added translated language text to code variables when there are newly added original language text and / or newly added translated language text in the source code; editing the adjusted original language text and / or adjusted translated language text in code variables when there are adjusted original language text and / or adjusted translated language text in the source code; and removing the deleted original language text and / or deleted translated language text from code variables when there are deleted original language text and / or deleted translated language text in the source code, and storing the deleted original language text and deleted translated language text in a target storage area.

[0011] In some embodiments, the code multilingualization method further includes: when it is necessary to obtain the source code of the target language, adjusting the language identifier in the variable to be replaced to the identifier of the target language to obtain the source code of the target language.

[0012] On the other hand, embodiments of this disclosure provide a code multilingualization device, which includes: a determining module, configured to determine code variables that can be recognized by the current code execution environment; the code variables include original language text in the source code and translated language text of the original language text in multiple languages; a first processing module, configured to determine a variable to be replaced corresponding to the target original language text based on the target original language text to be processed, the code variables, and language identifiers; and a second processing module, configured to replace the target original language text in the source code with the variable to be replaced to obtain multilingualized source code; the variable to be replaced is used to adjust the translated language text corresponding to the target original language text based on the language identifiers.

[0013] In another aspect, embodiments of this disclosure provide a computer device, including a memory and a processor. The memory stores a computer program that can run on the processor, and the processor executes the program to implement some or all of the steps in the above-described method.

[0014] In another aspect, embodiments of this disclosure provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements some or all of the steps in the above-described method.

[0015] In another aspect, embodiments of this disclosure provide a computer program including computer-readable code, which, when executed in a computer device, causes a processor in the computer device to perform some or all of the steps in the above-described method.

[0016] In another aspect, embodiments of this disclosure provide a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. When the computer program is read and executed by a computer, it implements some or all of the steps in the above-described method.

[0017] In this embodiment, code variables that can be recognized by the current code execution environment are determined. These code variables include the original language text in the source code and the translated language text in multiple languages. Based on the target original language text to be processed, the code variables, and the language identifier, a variable to be replaced corresponding to the target original language text is determined. The target original language text in the source code is replaced with the variable to be replaced, resulting in multilingualized source code. The variable to be replaced is used to adjust the translated language text corresponding to the target original language text based on the language identifier. Thus, by simply modifying the language identifier of the variable to be replaced in the multilingualized source code, multilingual switching of the original language text in the source code can be intelligently achieved. This method is simple to operate and highly applicable. Compared to manual switching, the intelligent multilingual switching in this embodiment is less prone to omissions or errors during the conversion process, resulting in higher conversion efficiency and accuracy. In this embodiment, multilingualization of source code is achieved entirely through code variables, avoiding data redundancy and translation inconsistencies caused by too many developers. Furthermore, the variable to be replaced in the multilingualized source code contains the original language text, allowing anyone, regardless of whether they are a source code developer, to intuitively understand the original language text through the variable to be replaced, resulting in high code readability.

[0018] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of this disclosure. Attached Figure Description

[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the specification, serve to illustrate the technical solutions of this disclosure.

[0020] Figure 1 A schematic diagram of the implementation process of a code multilingualization method provided in this embodiment of the disclosure. Figure 1 ;

[0021] Figure 2 A schematic diagram of the implementation process of a code multilingualization method provided in this embodiment of the disclosure. Figure 2 ;

[0022] Figure 3 A schematic diagram of the implementation process of a code multilingualization method provided in this embodiment of the disclosure. Figure 3 ;

[0023] Figure 4 This is a schematic diagram illustrating the implementation of a JSON file in a code multilingualization method provided in this embodiment of the disclosure;

[0024] Figure 5 A schematic diagram illustrating the implementation of code variables in a code multilingualization method provided in this embodiment of the disclosure;

[0025] Figure 6 A schematic diagram illustrating the parsing of the AST syntax tree structure in a code multilingualization method provided in this disclosure embodiment;

[0026] Figure 7 A schematic diagram illustrating the implementation of language conversion in a code multilingualization method provided in this embodiment of the disclosure;

[0027] Figure 8 A schematic diagram illustrating the implementation process of a prior art solution provided in this disclosure embodiment;

[0028] Figure 9 A schematic diagram of the implementation process of a code multilingualization method provided in this embodiment of the disclosure. Figure 4 ;

[0029] Figure 10 A schematic diagram of the composition structure of code multilingualization provided in this embodiment of the disclosure;

[0030] Figure 11 This is a schematic diagram of the hardware entity of a computer device provided in an embodiment of this disclosure. Detailed Implementation

[0031] To make the objectives, technical solutions, and advantages of this disclosure clearer, the technical solutions of this disclosure are further described in detail below with reference to the accompanying drawings and embodiments. The described embodiments should not be regarded as limitations on this disclosure. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0032] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0033] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure pertains. The terminology used herein is for descriptive purposes only and is not intended to limit the scope of this disclosure.

[0034] To better understand the code multilingualization method provided in the embodiments of this disclosure, the solutions in related technologies will be described below.

[0035] The relevant technologies suffer from at least the following problems: 1. As Chinese developers, we typically write code in Chinese. Existing solutions require replacing Chinese characters with corresponding English tags, which can easily lead to omissions during addition, modification, and deletion. 2. After replacing Chinese characters with corresponding English tags, code readability suffers significantly. It's difficult to discern the meaning solely from the English tags. 3. Multilingual configuration files are difficult to maintain, especially in team development. The same Chinese tag might be developed by different people on multiple pages, adding the same content but with different English tags, resulting in highly redundant multilingual configuration files. 4. Each Chinese word or phrase that needs to be replaced requires a corresponding English tag. Ensuring that the chosen names are easy to understand and unique is a common problem in programming.

[0036] Therefore, this disclosure provides a method for code multilingualization, which can be executed by the processor of a computer device. The computer device refers to a device with data processing capabilities, such as a server, laptop, tablet, desktop computer, smart TV, set-top box, or mobile device (e.g., mobile phone, portable video player, personal digital assistant, dedicated messaging device, portable gaming device). Figure 1 As shown, the method includes the following steps 101 to 103:

[0037] Step 101: Determine the code variables that can be recognized by the current code execution environment; the code variables include the original language text in the source code and the translated language text of the original language text in multiple languages.

[0038] Code variables refer to multilingual variables that can be recognized by the current code execution environment. Source code refers to the original code used when writing a program; it is a series of human-readable computer language instructions. Original language text refers to the text within the source code. Translated language text refers to text in multiple different languages ​​obtained after translating the original language text.

[0039] For example, the original text could be: time, uploaded file, etc. The original text "time" in English is translated as "time," the original text "time" in Japanese is translated as "じかん," and the original text "time" in Korean is translated as "じかん." The original text "upload files" in English is translated as "Upload files". The original text "time" in Japanese is translated as "ファイルのアップロード". The original text "upload files" in Korean is translated as "ファイルのアップロード".

[0040] In some implementations, step 101 can be specifically implemented as follows: obtaining the original language text and the translated language text of the original language text in multiple languages ​​from the source code; and determining the code variables that can be recognized by the current code execution environment based on the original language text and the translated language text.

[0041] Step 102: Based on the target original language text to be processed, the code variable, and the language identifier, determine the variable to be replaced corresponding to the target original language text.

[0042] The target source language text refers to the source language text currently being processed. For example, if the source language text is Chinese in the source code, then the target source language text can be a portion of the Chinese in the source code, or all of the Chinese. Language identifiers refer to identifiers for multiple different languages. The variables to be replaced refer to the code variables corresponding to each target source language text.

[0043] In some implementations, step 102 can be specifically implemented as follows: using code variables as a database, and using the target original language text and language identifier as query items, to obtain the variable to be replaced. Specifically, when the language identifier is the target language identifier, the variable to be replaced in the source code displays the translated language text of the target original language text in the target language.

[0044] Step 103: Replace the target original language text in the source code with the variable to be replaced to obtain multilingual source code; the variable to be replaced is used to adjust the translation language text corresponding to the target original language text based on the language identifier.

[0045] In some implementations, the code multilingualization method provided in this disclosure may further include: when it is necessary to obtain the source code of the target language, adjusting the language identifier in the variable to be replaced to the identifier of the target language, thereby obtaining the source code of the target language.

[0046] For example, if you want to convert Chinese characters in the source code to English, you can directly adjust the language identifier of the variable to be replaced in the multilingual source code to the English language identifier. At this time, the English language identifier and each Chinese character will be used as the query basis to find the English corresponding to each Chinese character in the code variable. The source code will then display the English corresponding to each Chinese character.

[0047] In some implementations, a general switching flag can be set. By adjusting this flag, all original language text in the source code can be converted to the translated language text in any language. This one-click switching method minimizes the complexity of code conversion and maximizes the conversion speed.

[0048] In this embodiment, code variables that can be recognized by the current code execution environment are determined. These code variables include the original language text in the source code and the translated language text in multiple languages. Based on the target original language text to be processed, the code variables, and the language identifier, a variable to be replaced corresponding to the target original language text is determined. The target original language text in the source code is replaced with the variable to be replaced, resulting in multilingualized source code. The variable to be replaced is used to adjust the translated language text corresponding to the target original language text based on the language identifier. Thus, by simply modifying the language identifier of the variable to be replaced in the multilingualized source code, multilingual switching of the original language text in the source code can be intelligently achieved. This method is simple to operate and highly applicable. Compared to manual switching, the intelligent multilingual switching in this embodiment is less prone to omissions or errors during the conversion process, resulting in higher conversion efficiency and accuracy. In this embodiment, multilingualization of source code is achieved entirely through code variables, avoiding data redundancy and translation inconsistencies caused by too many developers. Furthermore, the variable to be replaced in the multilingualized source code contains the original language text, allowing anyone, regardless of whether they are a source code developer, to intuitively understand the original language text through the variable to be replaced, resulting in high code readability.

[0049] This disclosure provides a method for code multilingualization, which can be executed by the processor of a computer device. For example... Figure 2As shown, the method includes the following steps 201 to 205:

[0050] Step 201: Extract the original language text from the source code.

[0051] In some implementations, step 201 can be achieved by at least one of the following methods:

[0052] The first method involves using regular expressions to extract the original language text from the source code.

[0053] In some implementations, the original language text in the source code can be extracted using the regular expression / \u4e00-\u9fa5 / .

[0054] The second method involves parsing the source code into a syntax tree structure and extracting the original language text from the source code based on the smallest structural unit in the syntax tree structure.

[0055] In some implementations, a syntax tree can be obtained by using the smallest structural units as nodes, based on variable definitions, function definitions, function calls, literal parameter passing, and class definitions in the source code. The original language text in the source code can then be extracted based on these smallest structural units. Furthermore, the source code can be parsed into an Abstract Syntax Tree (AST).

[0056] The third method involves using extraction tools to extract the original language text from the source code.

[0057] Step 202: Obtain the translated language texts of the original language text in multiple languages.

[0058] In some implementations, step 202 can be specifically implemented by using translation software to translate the original language text to obtain translated language text in multiple languages.

[0059] In some implementations, step 202 can also be implemented by having developers manually translate the original language text to obtain translated language texts in multiple languages.

[0060] Step 203: Based on the original language text and the translated language text, determine the code variables that can be recognized by the current code execution environment; the code variables include the original language text in the source code and the translated language text of the original language text in multiple languages.

[0061] Here, steps 201 to 203 correspond to step 101 mentioned above, and can be implemented with reference to the specific implementation of step 101 mentioned above.

[0062] In some implementations, step 203 can be specifically implemented as follows: using the original language text as a key information item and the translated language text corresponding to each original language text as a value information item to obtain a key-value pair corresponding to each original language text; and generating code variables that can be recognized by the current code execution environment based on the key-value pairs.

[0063] In some implementations, the original language text can be used as the key (key information item) of the JSON data, and the JSON data can be written back to a specified project directory to generate a JSON file; the translated language text can be written to the corresponding value field.

[0064] Step 204: Based on the target original language text to be processed, the code variable, and the language identifier, determine the variable to be replaced corresponding to the target original language text.

[0065] In some implementations, step 204 can be specifically implemented as follows: based on the current code language environment, and based on the target original language text to be processed, code variables, and language identifiers, determine the variable to be replaced corresponding to the target original language text. The variable to be replaced can extract the corresponding value (translated language text) through the key (original language text) and language identifier (current multilingual environment identifier) ​​in the JSON data.

[0066] In some implementations, step 204 can be specifically implemented as follows: using the code variable as A, the target original language text as key, and the language identifier as lang, to obtain the variable to be replaced A[lang][key]; the code variable contains all the original language texts and multiple translated language texts corresponding to each original language text.

[0067] Step 205: Replace the target original language text in the source code with the variable to be replaced to obtain multilingual source code; the variable to be replaced is used to adjust the translated language text corresponding to the target original language text based on the language identifier.

[0068] In some implementations, when the source code of the target language is needed, the language identifier lang in the variable to be replaced A[lang][key] is adjusted to the identifier of the target language, and the original language text and the translated language text are displayed in key at the same time; or, the language identifier lang and / or the original language text can be attached to the translated language text in the form of annotations.

[0069] In some embodiments, the code multilingualization method provided in this disclosure may further include the following steps 206 to 208:

[0070] Step 206: If there is newly added original language text and / or newly added translated language text in the source code, add the newly added original language text and / or the newly added translated language text to the code variable.

[0071] Step 207: If there is adjusted original language text and / or adjusted translated language text in the source code, edit the adjusted original language text and / or the adjusted translated language text in the code variables.

[0072] Step 208: If there is deleted original language text and / or deleted translated language text in the source code, remove the deleted original language text and / or deleted translated language text from the code variable, and store the deleted original language text and deleted translated language text in the target storage area.

[0073] Storing the deleted original language text and the deleted translated language text in the target storage area is to cache the deleted text for easy use later.

[0074] It should be noted that in the embodiments of this disclosure, adding, adjusting, or deleting original language text and / or translated language text only requires adjusting code variables, without any intrusion into the source code, and adding multiple languages ​​has no impact on code readability.

[0075] In some implementations, certain tags can be used to mark content in the source code that does not need to be translated. For example, "[undo]time" indicates that the corresponding Chinese word "time" does not need to be translated.

[0076] In this embodiment, only the language identifier of the variable to be replaced in the multilingualized source code needs to be modified to intelligently achieve multilingual switching of the original language text in the source code. This is simple to operate and highly applicable. Compared to manual switching, the intelligent multilingual switching in this embodiment is less prone to omissions or errors during the conversion process, resulting in higher conversion efficiency and accuracy. In this embodiment, multilingualization of source code is achieved entirely through code variables, avoiding data redundancy and translation inconsistencies caused by too many developers. Furthermore, the variable to be replaced in the multilingualized source code contains the original language text, allowing anyone, regardless of whether they are a source code developer, to intuitively understand the original language text through the variable to be replaced, resulting in high code readability.

[0077] The following describes the application of the code multilingualization method provided in the embodiments of this disclosure in real-world scenarios.

[0078] The code multilingualization method provided in this disclosure can be applied to projects with multilingual requirements. Specific solutions include:

[0079] 1. Use extraction techniques to extract Chinese characters (original language text) from the source code. Extraction techniques can be general-purpose tools; for example, parsing the source code into an AST (Abstract Syntax Tree) for extraction; or, the source code can be treated as plain text and extracted using regular expressions.

[0080] 2. Use the extracted Chinese characters as the key of the JSON data, and write this JSON data back to a specified project directory to generate a JSON file.

[0081] 3. Take the JSON file generated in the previous step, translate it into the corresponding English or other language based on the Chinese characters in the key (translate the language text), and write it into the corresponding value field.

[0082] 4. Take the translated data containing Chinese text and the translated text, and generate a code variable A that can be recognized by the current code language at runtime, based on the current code language environment. The code variable A can extract the corresponding translation value using the Chinese identifier key in the previous JSON data and the current multilingual environment identifier, in a format similar to A[language][key].

[0083] 5. During the source code compilation stage, or before the code is packaged, replace the Chinese characters in the source code with A[language][key].

[0084] like Figure 3 As shown, the process of the self-developed tool includes: extracting Chinese characters from the source code; generating a configuration file (JSON file); and translating and configuring it. The front-end packaging process includes: source code; AST syntax tree structure; and the final product (multilingual source code).

[0085] like Figure 4As shown, the configuration file (json file) may include: the original language text "Save" and its corresponding translated language text "Save"; the original language text "Edit" and its corresponding translated language text "Edit"; the original language text "It is not empty and does not contain special characters" and its corresponding translated language text "It is not empty and does not contain special characters"; the original language text "Menu query mode" and its corresponding translated language text "Menu query mode"; the original language text "Menu type" and its corresponding translated language text "Menu type"; the original language text "Menu list" and its corresponding translated language text "Menu list"; the original language text "Menu path" and its corresponding translated language text "Menu path".

[0086] As Figure 5 shown, the json file generates a code variable PATEO that can be recognized by the current code language (JavaScript) at runtime according to the current code language environment.

[0087] As Figure 6 shown, the source code is converted into an AST syntax structure tree to implement the extraction of Chinese and the packaging and replacement of the final _PATEO_ variable. For example, "Please enter a new password" is parsed according to the syntax structure tree as: type (type): "Literal"; value (value): "Please enter a new password"; raw (raw data): "Please enter a new password"; range (range): [8188, 8196]; loc (code line): (start, end); parent (parent class): NewExpression(type arguments, callee,...).

[0088] As Figure 7 shown, during the source code compilation stage or before code packaging, the Chinese in the source code is replaced with the form A[language][key]. A is PATEO_.118n; language is PATEO_.lang[0], and PATEO_.lang[0] represents Chinese; the first "Ecological Management Platform" is the key, and the second "Ecological Management Platform" is the value.

[0089] From Figure 8As can be seen, the existing solution requires multiple operations, including modifying multilingual configurations, configuring multilingual configuration files, translating, and replacing Chinese characters in the source code, when dealing with basic coding techniques for the main functions, new requirements, bug fixes, and feature deletions. However, from... Figure 9 As can be seen from this, in the case of basic coding technology of main functions, new requirements, bug fixes, and function deletion, the language replacement of the source code can be achieved simply by executing an automated script.

[0090] It should be noted that the points to be protected in this disclosure include: 1. The multilingual implementation of the source code does not intrude on the source code and has no impact on code readability after adding multiple languages. 2. The code multilingualization method provided in this disclosure can achieve one-click extraction and facilitate maintenance.

[0091] It should be noted that the embodiments disclosed herein achieve at least the following technical effects: 1. For projects involving multilingual requirements, the translation of multiple languages ​​is independent of the developer. 2. Significantly simplifies changes such as adding, editing, and deleting languages. 3. When adding a new language adaptation, this tool can automatically extract the language, and then translate the extracted JSON file.

[0092] Based on the foregoing embodiments, this disclosure provides a code multilingualization device, which includes the included units and the modules included in each unit, which can be implemented by a processor in a computer device; of course, it can also be implemented by specific logic circuits; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.

[0093] Figure 10 This is a schematic diagram of the composition structure of a code multilingualization device provided in an embodiment of this disclosure, such as... Figure 10 As shown, the code multilingualization device 1000 includes: an acquisition module 1010, a first determination module 1020, and a second determination module 1030, wherein:

[0094] The determination module 1010 is used to determine code variables that can be recognized by the current code execution environment; the code variables include the original language text in the source code and the translated language text of the original language text in multiple languages;

[0095] The first processing module 1020 is used to determine the variable to be replaced corresponding to the target original language text based on the target original language text to be processed, the code variable and the language identifier;

[0096] The second processing module 1030 is used to replace the target original language text in the source code with the variable to be replaced to obtain multilingual source code; the variable to be replaced is used to adjust the translation language text corresponding to the target original language text based on the language identifier.

[0097] In some embodiments, the determining module 1010 is further configured to: extract the original language text from the source code; obtain the translated language text of the original language text in multiple languages; and determine code variables that can be recognized by the current code execution environment based on the original language text and the translated language text.

[0098] In some embodiments, the determining module 1010 is further configured to perform at least one of the following: extracting the original language text from the source code using regular expressions; parsing the source code into a syntax tree structure and extracting the original language text from the source code based on the smallest structural unit in the syntax tree structure; and extracting the original language text from the source code using an extraction tool.

[0099] In some embodiments, the determining module 1010 is further configured to: use the original language text as a key information item and the translated language text corresponding to each original language text as a value information item to obtain a key-value pair corresponding to each original language text; and generate code variables that can be recognized by the current code execution environment based on the key-value pairs.

[0100] In some embodiments, the first processing module 1020 is further configured to: use the code variable as A, the target original language text as key, and the language identifier as lang to obtain a variable to be replaced A[lang][key]; the code variable contains all the original language texts and multiple translated language texts corresponding to each original language text.

[0101] In some embodiments, the second processing module 1030 is further configured to: add the newly added original language text and / or the newly added translated language text to the code variable when there is newly added original language text and / or newly added translated language text in the source code; edit the adjusted original language text and / or the adjusted translated language text in the code variable when there is adjusted original language text and / or adjusted translated language text in the source code; and remove the deleted original language text and / or the deleted translated language text from the code variable when there is deleted original language text and / or deleted translated language text in the source code, and store the deleted original language text and the deleted translated language text in the target storage area.

[0102] In some embodiments, the second processing module 1030 is further configured to: when it is necessary to obtain the source code of the target language, adjust the language identifier in the variable to be replaced to the identifier of the target language, and obtain the source code of the target language.

[0103] The descriptions of the apparatus embodiments above are similar to those of the method embodiments above, and have similar beneficial effects. In some embodiments, the functions or modules included in the apparatus provided in this disclosure can be used to perform the methods described in the method embodiments above. For technical details not disclosed in the apparatus embodiments of this disclosure, please refer to the descriptions of the method embodiments of this disclosure for understanding.

[0104] It should be noted that, in the embodiments of this disclosure, if the above-described code multilingualization method is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this disclosure, or the part that contributes to related technologies, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this disclosure are not limited to any specific hardware, software, or firmware, or any combination of hardware, software, and firmware.

[0105] This disclosure provides a computer device including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the program, it implements some or all of the steps in the above-described method.

[0106] This disclosure provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements some or all of the steps in the above-described method. The computer-readable storage medium may be transient or non-transient.

[0107] This disclosure provides a computer program including computer-readable code, wherein when the computer-readable code is executed in a computer device, a processor in the computer device performs some or all of the steps in the above-described method.

[0108] This disclosure provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. When the computer program is read and executed by a computer, it implements some or all of the steps in the above-described method. This computer program product can be implemented specifically through hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium; in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.

[0109] It should be noted that the descriptions of the various embodiments above tend to emphasize the differences between them, while their similarities or commonalities can be referenced interchangeably. The descriptions of the above embodiments of the device, storage medium, computer program, and computer program product are similar to the descriptions of the above method embodiments and have similar beneficial effects. For technical details not disclosed in the embodiments of the device, storage medium, computer program, and computer program product of this disclosure, please refer to the descriptions of the method embodiments of this disclosure for understanding.

[0110] It should be noted that, Figure 11 This is a schematic diagram of a hardware entity of a computer device in an embodiment of this disclosure, such as... Figure 11 As shown, the hardware entity of the computer device 1100 includes: a processor 1101, a communication interface 1102, and a memory 1103, wherein:

[0111] Processor 1101 typically controls the overall operation of computer device 1100.

[0112] Communication interface 1102 enables computer devices to communicate with other terminals or servers via a network.

[0113] The memory 1103 is configured to store instructions and applications executable by the processor 1101, and can also cache data to be processed or already processed (e.g., image data, audio data, voice communication data, and video communication data) in the processor 1101 and various modules in the computer device 1100. It can be implemented using flash memory or random access memory (RAM). Data transfer between the processor 1101, the communication interface 1102, and the memory 1103 can be performed via bus 1104.

[0114] It should be understood that the phrase "an embodiment" or "one embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this disclosure. Therefore, "in one embodiment" or "one embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this disclosure, the sequence numbers of the above steps / processes do not imply a sequential order of execution; the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this disclosure. The sequence numbers of the above embodiments of this disclosure are merely descriptive and do not represent the superiority or inferiority of the embodiments.

[0115] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0116] In the several embodiments provided in this disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components may be combined, or integrated into another system, or some features may be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0117] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.

[0118] In addition, each functional unit in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0119] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.

[0120] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, or the part that contributes to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, magnetic disks, or optical disks.

[0121] The above description is merely an embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A method for code multilingualization, characterized in that, The code multilingualization methods include: Identify code variables that can be recognized by the current code execution environment; the code variables include the original language text in the source code and the translated language text of the original language text in multiple languages; Based on the target original language text to be processed, the code variables, and the language identifier, determine the variables to be replaced corresponding to the target original language text; The target original language text in the source code is replaced with the variable to be replaced to obtain multilingual source code; the variable to be replaced is used to adjust the translated language text corresponding to the target original language text based on the language identifier.

2. The code multilingualization method according to claim 1, characterized in that, The determination of code variables that can be recognized by the current code execution environment includes: Extract the original language text from the source code; Obtain the translated language texts of the original language text in multiple languages; Based on the original language text and the translated language text, determine the code variables that can be recognized by the current code execution environment.

3. The code multilingualization method according to claim 2, characterized in that, The extraction of raw language text from the source code includes at least one of the following: The original language text in the source code is extracted using regular expressions; The source code is parsed into a syntax structure tree, and the original language text in the source code is extracted based on the smallest structural unit in the syntax structure tree. The original language text in the source code was extracted using an extraction tool.

4. The code multilingualization method according to claim 2, characterized in that, The process of determining code variables that can be recognized by the current code execution environment based on the original language text and the translated language text includes: The original language text is used as the key information item, and the translated language text corresponding to each original language text is used as the value information item to obtain the key-value pair corresponding to each original language text; Based on the key-value pairs, code variables that can be recognized by the current code execution environment are generated.

5. The code multilingualization method according to any one of claims 1 to 4, characterized in that, The process of determining the replacement variable corresponding to the target original language text based on the target original language text to be processed, the code variable, and the language identifier includes: The code variable is designated as A, the target original language text is designated as key, and the language identifier is designated as lang, resulting in the variable to be replaced A[lang][key]. The code variable contains all the original language texts and multiple translation language texts corresponding to each original language text.

6. The code multilingualization method according to any one of claims 1 to 4, characterized in that, The code multilingualization method also includes: If there are newly added original language text and / or newly added translated language text in the source code, add the newly added original language text and / or the newly added translated language text to the code variable; If there is adjusted original language text and / or adjusted translated language text in the source code, edit the adjusted original language text and / or the adjusted translated language text in the code variables; If there is deleted original language text and / or deleted translated language text in the source code, the deleted original language text and / or deleted translated language text are removed from the code variables, and the deleted original language text and deleted translated language text are stored in the target storage area.

7. The code multilingualization method according to claim 1, characterized in that, The code multilingualization method also includes: When it is necessary to obtain the source code of the target language, the language identifier in the variable to be replaced is adjusted to the identifier of the target language to obtain the source code of the target language.

8. A code multilingualization device, characterized in that, The code multilingualization device includes: The determination module is used to determine code variables that can be recognized by the current code execution environment; the code variables include the original language text in the source code and the translated language text of the original language text in multiple languages; The first processing module is used to determine the variable to be replaced corresponding to the target original language text based on the target original language text to be processed, the code variable, and the language identifier; The second processing module is used to replace the target original language text in the source code with the variable to be replaced, thereby obtaining multilingual source code; the variable to be replaced is used to adjust the translated language text corresponding to the target original language text based on the language identifier.

9. A computer device comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 7.

11. A computer program product comprising a non-transitory computer-readable storage medium storing a computer program, wherein when the computer program is read and executed by a computer, it implements the steps of the method according to any one of claims 1 to 7.