Code multi-language content translation method and device, electronic equipment and storage medium
By using multilingual content translation methods based on translation instructions in multilingual version project development, extracting and translating text to be translated in code and generating target language files, the problems of inefficient translation efficiency and human error in the existing technology are solved. A more efficient and accurate translation process is achieved.
Patent Information
- Application Number
- CN202411630162.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-02-18
AI Technical Summary
In the development of multilingual version projects, the translation efficiency of the existing technology is low and prone to human errors.
A multilingual content translation method for code is proposed. By scanning the files to be translated based on translation instructions, the text to be translated is extracted using the preset extraction function, the preset translation function is used for translation, and the target language file is generated based on the preset generation algorithm.
It improves the translation efficiency of multilingual version project development and reduces the risk of human errors during the translation process.
Smart Images

Figure CN119473298A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development technology, and in particular to a method, device, electronic device and storage medium for translating multi-language content of a code. Background Art
[0002] Multilingual version project development refers to designing applications or websites to support multiple languages during the software development process to meet the needs of users in different regions. This development method is becoming more and more common in modern software development, and accurately and timely ensuring the synchronization of resource updates between different language versions is a very important task in the multilingual version project development process.
[0003] In the current multi-language version project development process, developers are usually required to collect the content that needs to be translated file by file, and then send the collected text content to translators one by one or use online translation tools for translation. After the translation is completed, the translated content is replaced back to the corresponding position in the code file one by one.
[0004] The use of the above-mentioned multi-language version project development translation solution is simple and repetitive, with low work efficiency and prone to human errors during operation. Summary of the invention
[0005] The main purpose of this application is to propose a method, device, electronic device and storage medium for translating the multilingual content of a code, aiming to improve the translation efficiency of multilingual version project development and reduce the risk of human errors in the translation process.
[0006] In a first aspect, the present application provides a method for translating multilingual content of a code, comprising:
[0007] Based on the translation instructions, scan and obtain the files to be translated;
[0008] Extracting the text to be translated in the file to be translated by using a preset extraction function;
[0009] Translating the text to be translated into a target language text by using a preset translation function;
[0010] According to the preset generation algorithm and the target language text, a corresponding target language file is generated.
[0011] In an optional implementation manner, scanning and acquiring the file to be translated based on the translation instruction includes:
[0012] Based on the translation instruction, scanning and acquiring a plurality of initial files to be translated according to a preset scanning range or a preset scanning path;
[0013] The file to be translated is obtained according to a preset filtering condition and the initial file to be translated.
[0014] In an optional implementation manner, extracting the text to be translated in the file to be translated by using a preset extraction function includes:
[0015] Using preset extraction rules, identifying and extracting the content to be translated in the file to be translated, and obtaining a preliminary text to be translated;
[0016] The preliminary text to be translated is subjected to a preset processing to obtain the processed text to be translated, wherein the preset processing includes at least one of the following: removing comments, matching a preset character pattern, and de-duplication processing.
[0017] In an optional implementation manner, after extracting the text to be translated in the file to be translated by using a preset extraction function, the method further includes:
[0018] The text to be translated is stored according to a preset storage format, where the preset storage format includes a plurality of storage fields.
[0019] In an optional embodiment, the translation instruction includes: a target language identifier;
[0020] The translating the to-be-translated text into a target language text by using a preset translation function includes:
[0021] The preset translation function is called by a preset translation algorithm to translate the text to be translated into a target language text corresponding to the target language identifier.
[0022] In an optional implementation manner, after translating the text to be translated into a target language text by using a preset translation function, the method further includes:
[0023] Translating the target language text into the original language text;
[0024] Calculating and obtaining the consistency between the original language text and the text to be translated;
[0025] If the consistency between the original language text and the text to be translated is lower than a preset threshold, a prompt message is generated.
[0026] In an optional implementation manner, there are multiple files to be translated and multiple target language files;
[0027] After generating the corresponding target language file according to the preset generation algorithm and the target language text, the method further includes:
[0028] The plurality of target language files are stored according to a preset file structure.
[0029] In a second aspect, the present application provides a multi-language content translation device for a code, comprising:
[0030] A scanning module, used for scanning and obtaining files to be translated based on translation instructions;
[0031] An extraction module, used for extracting the text to be translated in the file to be translated by using a preset extraction function;
[0032] A translation module, used for translating the text to be translated into a target language text through a preset translation function;
[0033] The generating module is used to generate a corresponding target language file according to a preset generating algorithm and the target language text.
[0034] In a third aspect, the present application provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, the processor and the storage medium communicate via the bus, and the processor executes the machine-readable instructions to perform a method as described in any of the foregoing embodiments.
[0035] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method as described in any of the aforementioned embodiments is executed.
[0036] The beneficial effects of this application are:
[0037] The multilingual content translation method of the code provided in the embodiment of the present application includes: based on the translation instruction, scanning and obtaining the file to be translated; extracting the text to be translated in the file to be translated by a preset extraction function; translating the text to be translated into the target language text by a preset translation function; generating the corresponding target language file according to the preset generation algorithm and the target language text. In this embodiment, the text to be translated in the file to be translated is extracted by a preset extraction function, thereby realizing the use of a preset translation function instead of manually entering text and obtaining translation content, and using a preset generation algorithm to generate the corresponding target language file from the translated text, thereby improving the translation efficiency of multilingual version project development and reducing the risk of human error in the translation process. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying any creative work.
[0039] Figure 1A flowchart of a method for translating multilingual content of a code provided in an embodiment of the present application;
[0040] Figure 2 A flowchart of a method for translating multilingual content of a code provided by another embodiment of the present application;
[0041] Figure 3 A flowchart of a method for translating multilingual content in a code according to another embodiment of the present application;
[0042] Figure 4 A flowchart of a method for translating multilingual content in a code provided in yet another embodiment of the present application;
[0043] Figure 5 A schematic diagram of the structure of a multi-language content translation device for a code provided in an embodiment of the present application;
[0044] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0046] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0047] It should be noted that similar numbers and letters represent similar items in the following figures, so once an item is defined in one figure, it does not need to be further defined or explained in subsequent figures. The terms "comprises," "comprising," or any other variation thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or elements that are inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the statement "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device that includes the element.
[0048] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0049] The current translation method for multi-language version project development is usually that the developer manually opens the code files one by one and searches for the text content that needs to be translated in the code files, collects and summarizes them, and then sends the collected and summarized text content to the translator or uses an online translation tool for translation. After the translation is completed, the translated text content is replaced one by one back to the corresponding position in the code file. Such a translation method for multi-language version project development is not only inefficient, but also prone to errors in the process of manual collection, translation, and replacement. The main purpose of this application is to propose a multi-language content translation method, device, electronic device and storage medium for code, aiming to improve the translation efficiency of multi-language version project development and reduce the risk of human errors in the translation process.
[0050] Figure 1 The flowchart of the multi-language content translation method of the code provided in an embodiment of the present application is shown in FIG. 1 . The execution subject of the method can be a device with computing processing capabilities such as a computer, such as Figure 1 As shown, the method includes:
[0051] S101, based on the translation instruction, scanning and obtaining the file to be translated.
[0052] Exemplarily, the above-mentioned translation instructions can be issued by developers through devices with computing processing capabilities such as computers. The translation instructions can, for example, include information indicating the type, range, path, etc. of the above-mentioned files to be translated. For example, when issuing the translation instructions, the developer can specify the type of files to be translated as C language files (for example, files with the suffix ".c"), Python language files (for example, files with the suffix ".py"), Js language files (for example, files with the suffix ".js"), etc., and can also specify the range of files to be translated as files created within 3 years, files with a size of less than 10 megabytes, etc., and can also specify the path of the files to be translated as files in a certain folder or several folders, etc.
[0053] It can be understood that in the above examples, the information on the type, scope, path, etc. of the file to be translated can be specified in only one way or in multiple ways at the same time, and the specific way of issuing the translation instructions, the information content included, the specific form corresponding to the above information content, etc. can all be determined according to actual needs and are not limited to the content in the above examples.
[0054] S102: extracting the text to be translated in the above-mentioned file to be translated by using a preset extraction function.
[0055] Exemplarily, the preset extraction function may be named, for example, extract Chinese Texts, and the function of the preset extraction function may be, for example, to identify and extract text content embedded in the code in the file to be translated, that is, the text to be translated. For example, in a Js language file, the function of the code statement "alert("Login successful");" is to pop up a prompt box, and the text content displayed in the prompt box is "Login successful". When the Js language file is used for multi-language version project development, for example, for English users, the Chinese text "Login successful" in the above program statement needs to be translated into the corresponding English text "Login successful", that is, the above program statement in the Js language file should be replaced with "alert("Login successful");" after the translation is completed. successful”);”, and for example, in a C language file, the function of the code statement “printf("Hello, World!");” is to output the text content “Hello, World!”. When the C language file is used for multi-language version project development, for example, for English users, it is necessary to translate the Chinese text “Hello, World!” in the above program statement into the corresponding English text “Hello, World!”, that is, the above program statement in the C language file should be replaced with “printf("Hello, World!");” after the translation is completed. Based on the above examples, it can be seen that the above preset extraction function needs to accurately identify and extract the Chinese text content “Login successful” in the statement “alert("Login successful")” and the Chinese text content “Hello, World!” in the statement “printf("Hello, World!");”.
[0056] The principle of identifying and extracting text content embedded in the code can be, for example, extracting the embedded text content according to specific program statements, such as targeted extraction of text content in statements such as alert statements and printf statements, or it can be, for example, identifying all Chinese characters in the code and then removing the comments therein.
[0057] It is understandable that the above content is for example only, and the specific preset extraction function naming, the specific file type to be translated, the specific text content embedded in the code, the language of the text content, and the specific method of identifying and extracting the text content embedded in the code can all be selected and determined according to actual conditions, and are not limited to the above content.
[0058] S103: translating the text to be translated into a target language text by using a preset translation function.
[0059] Exemplarily, the preset translation function may be named after a related program called by the translation function, such as bingTranslator, etc. The function of the preset translation function may be, for example, to send the text to be translated extracted by the preset extraction function to various translation platforms such as Bing Translation, Baidu Translation, etc. through an API (Application Programming Interface), and receive a target language text obtained by translating the text to be translated by the translation platform; or the preset translation function may be integrated with a program with a translation function, so that the text to be translated may be directly translated to obtain the target language text.
[0060] Of course, the specific preset translation function name, function or translation path can be selected and determined according to actual conditions and is not limited to the above examples.
[0061] S104: Generate a corresponding target language file according to a preset generation algorithm and the target language text.
[0062] Exemplarily, the preset generation algorithm can write the target language text back to the text to be translated corresponding to the target language text to generate a corresponding target language file, which can be in a different language from the text content of the file to be translated, but the rest of the content is the same. Specifically, the target language text is written to the text to be translated corresponding to the target language text, for example, when the preset extraction function extracts the text to be translated in the file to be translated, the text to be translated and its location are recorded or marked, and when the preset translation function translates the text to be translated into the target language text, the location of the text to be translated corresponding to the target language text can be recorded or marked, so as to achieve writing the target language text back to the text to be translated corresponding to the target language text.
[0063] It is understandable that the above content is only one possible writing back method. How to write the target language text back to the text to be translated corresponding to the target language text to generate the corresponding target language file can be determined according to actual conditions and is not limited here.
[0064] The multilingual content translation method of the code provided in the embodiment of the present application includes: based on the translation instruction, scanning and obtaining the file to be translated; extracting the text to be translated in the above-mentioned file to be translated by a preset extraction function; translating the above-mentioned text to be translated into the target language text by a preset translation function; generating the corresponding target language file according to the preset generation algorithm and the above-mentioned target language text. In this embodiment, the text to be translated in the file to be translated is extracted by a preset extraction function, thereby realizing the use of a preset translation function instead of manually entering text and obtaining translation content, and using a preset generation algorithm to generate the corresponding target language file from the translated text, thereby improving the translation efficiency of the multilingual version project development and reducing the risk of human error in the translation process.
[0065] Figure 2 A flowchart of a multi-language content translation method of a code provided in another embodiment of the present application is shown as follows: Figure 2 As shown, in Figure 1 Based on the embodiment, the above-mentioned scanning and obtaining the file to be translated based on the translation instruction may include:
[0066] S201 : Based on a translation instruction, a plurality of initial files to be translated are scanned and acquired according to a preset scanning range or a preset scanning path.
[0067] Exemplarily, the above-mentioned preset scanning range or preset scanning path may belong to the above-mentioned Figure 1 In the embodiment, the information indicating the type, range, path, etc. of the files to be translated, wherein the preset scanning range may refer to, for example, files created within 3 years, files with a file size of less than 10 megabytes, etc., including but not limited to the range of time, file size, etc., and the preset scanning path may refer to, for example, the path range corresponding to a certain folder or several folders. It is understandable that the scanning and obtaining of multiple initial files to be translated according to the preset scanning range or the preset scanning path may refer to scanning only according to the preset scanning range or scanning only according to the preset scanning path, or may refer to scanning according to both the preset scanning range and the preset scanning path.
[0068] S202: Acquire the file to be translated according to the preset filtering condition and the initial file to be translated.
[0069] Continuing with the above example, the above initial files to be translated may refer to files to be translated that are preliminarily screened out based on the above preset scanning range or preset scanning path. However, in some cases, some initial files to be translated that meet the above preset scanning range or preset scanning path do not contain text to be translated. Therefore, after scanning and obtaining multiple initial files to be translated, the initial files to be translated may be filtered through preset filtering conditions to obtain the above files to be translated.
[0070] Exemplarily, the above-mentioned preset filtering conditions may include, for example, a condition for indicating the exclusion of initial files to be translated with certain specific suffixes. The condition for indicating the exclusion of initial files to be translated with certain specific suffixes may, for example, exclude files including but not limited to files with suffixes such as “.spec.ts” and / or “.test.ts”.
[0071] Of course, the above contents are only examples, and the specific preset filtering conditions, specific methods of obtaining the above files to be translated, etc. can be selected and determined according to actual conditions and are not limited to the above contents.
[0072] In this embodiment, based on the translation instruction, multiple initial files to be translated are scanned and obtained according to a preset scanning range or a preset scanning path; and the files to be translated are obtained according to preset filtering conditions and the initial files to be translated. Multiple initial files to be translated are scanned and obtained by a preset scanning range or a preset scanning path, and the multiple initial files to be translated are filtered and screened according to the preset filtering conditions, thereby more accurately obtaining the files to be translated in the preset scanning range or the preset scanning path, and improving the efficiency of scanning and obtaining the files to be translated.
[0073] Figure 3 A flowchart of a multi-language content translation method of a code provided in another embodiment of the present application is as follows: Figure 3 As shown, in Figure 1 Based on the embodiment, the above-mentioned extracting the text to be translated in the above-mentioned file to be translated by using a preset extraction function may include:
[0074] S301: using preset extraction rules to identify and extract the content to be translated in the above-mentioned file to be translated, and obtaining a preliminary text to be translated.
[0075] Exemplarily, the above-mentioned use of preset extraction rules to identify and extract the content to be translated in the above-mentioned file to be translated, and obtain the preliminary text to be translated, may refer to, for example Figure 1 In the embodiment, the embedded text content is extracted according to the specific program statements, for example, the text content in the alert statement, printf statement and the like is extracted in a targeted manner, or all Chinese characters in the code are identified, and then the comments are removed.
[0076] In addition, the above-mentioned preset extraction rules can not only include the targeted extraction of text content in statements such as alert statements and printf statements, identification of all Chinese characters in the code, and then removal of comments, but also refer to specific neural network algorithms and other algorithms that can realize text content extraction, such as TextCNN (Text Convolutional Neural Networks, convolutional neural network for text) algorithm, etc.
[0077] It is understandable that the above contents are only examples, and the specific preset extraction rules, how to identify and extract the content to be translated in the above-mentioned file to be translated, how to obtain the preliminary text to be translated, etc. can all be selected and determined according to the actual situation and are not limited here.
[0078] S302: performing preset processing on the preliminary text to be translated to obtain the processed text to be translated, wherein the preset processing includes at least one of the following: removing comments, matching a preset character pattern, and de-duplication processing.
[0079] Usually, the preliminary text to be translated may contain code comments in addition to the text to be translated. For example, in the Js language file, the code statement "alert("Login successful"); / / Popup window prompts login successful" has the same effect as Figure 1 The corresponding statements in the implementation example are the same, and it is still a pop-up prompt box. The text content displayed in the prompt box is "Login successful", and the " / / Pop-up box prompts that login is successful" part is a code comment, that is, the code writer's explanation and description of the code. Its purpose is to allow other developers to understand the code more easily. The code comments will not participate in the operation of the code and will not produce any effect. Therefore, this part of the code comments will not be displayed on the user side and does not need to be translated into the corresponding language of the user. Based on this, if the preliminary text to be translated contains code comments, the preliminary text to be translated can be decommented to obtain the text to be translated that actually needs to be translated.
[0080] Regardless of the language of the text content, simple errors such as text duplication may occur. For errors related to text duplication, after matching the preset character pattern, the SimHash algorithm, Python language regular expression, etc. corresponding to the preset character pattern can be used to implement deduplication processing of the preliminary text to be translated. The above-mentioned matching of the preset character pattern can refer to matching the preset character pattern of the same language as the preliminary text to be translated after identifying the character pattern of the language of the preliminary text to be translated, such as the Chinese character pattern, the English character pattern, etc., so as to facilitate the subsequent call of the deduplication algorithm corresponding to the character pattern of the language.
[0081] It is understandable that the above content is only an example, and the specific preset processing includes what content, specific removal of comments, matching preset character patterns and deduplication processing implementation methods, etc., which can all be selected and determined according to actual conditions and are not limited here.
[0082] In addition, Figure 1 Based on the embodiment, after extracting the text to be translated in the file to be translated by the preset extraction function, the method may further include:
[0083] The text to be translated is stored according to a preset storage format, wherein the preset storage format includes a plurality of storage fields.
[0084] Exemplarily, the above-mentioned preset storage format may be, for example, a storage format similar to an Excel table, and the preset storage format may include, for example, storage fields such as a file name, a file path, an original text, a translation, a code snippet, etc., which may be specifically shown in the following Table 1:
[0085]
[0086] Table 1
[0087] On this basis, the above storage fields may also include, for example, serial numbers, original text location identifiers, etc. The specific number and content of storage fields may be selected and determined according to actual needs and are not limited here.
[0088] In addition to the above examples, the above-mentioned preset storage format can also be a format such as JSON (JavaScript Object Notation), XML (Extensible Markup Language) and CSV (Comma-Separated Values) to facilitate data exchange. Of course, the specific preset storage format can be selected and determined according to actual conditions and is not limited here.
[0089] Further, in Figure 1 Based on the embodiment, the translation instruction may include: a target language identifier, and the translation of the text to be translated into the target language text by using a preset translation function may include:
[0090] The preset translation function is called through a preset translation algorithm to translate the text to be translated into a target language text corresponding to the target language identifier.
[0091] Exemplarily, the target language identifier may be used to indicate the target language text into which the text to be translated in the current language is translated. For example, the target language identifier may be an English identifier, a Japanese identifier, or the like. Taking the target language identifier as an English identifier as an example, the above-mentioned translating the text to be translated into the target language text corresponding to the target language identifier may refer to translating the text to be translated into English by calling, for example, a Chinese-to-English translation function.
[0092] It is understandable that the above content is only an example, and the specific number, type, form of target language identifiers and the number, type, form of preset translation algorithms and preset translation functions can be selected and determined according to actual needs and are not limited here.
[0093] Figure 4 A flowchart of a multi-language content translation method of a code provided in yet another embodiment of the present application is shown in FIG. Figure 4 As shown, in Figure 1 Based on the embodiment, after translating the text to be translated into the target language text by the preset translation function, the method may further include:
[0094] S401, translating the target language text into the original language text.
[0095] The above-mentioned translating the target language text into the original language text may refer to re-translating the target language text obtained by translation through a preset translation function into a text of the language corresponding to the text to be translated. For example, if the text to be translated is in Chinese, and the target language text obtained by translation through a Chinese-to-English translation function is in English, then the above-mentioned translating the target language text into the original language text may refer to re-translating the English version of the target language text into the Chinese version of the original language text.
[0096] S402: Calculate and obtain the consistency between the original language text and the text to be translated.
[0097] Exemplarily, the principle of calculating the consistency between the original language text and the text to be translated is similar to that of checking for plagiarism in a paper. For example, it can be implemented using a text plagiarism checking algorithm including but not limited to the MinHash algorithm. The consistency between the original language text and the text to be translated can be expressed in the form of a percentage, for example, the consistency between the original language text and the text to be translated is 94%, the consistency between the original language text and the text to be translated is 78%, etc. It can be understood that the consistency value between the original language text and the text to be translated should be in the range of 0%-100%, and the closer the consistency value between the original language text and the text to be translated is to 100%, the higher the similarity between the two, which can prove that the translation accuracy of the target language text is better. Conversely, the closer the consistency value between the original language text and the text to be translated is to 0%, the lower the similarity between the two, which can prove that the translation accuracy of the target language text is poor.
[0098] S403: If the consistency between the original language text and the text to be translated is lower than a preset threshold, a prompt message is generated.
[0099] Continuing with the above example, the preset threshold value may be, for example, a percentage value such as 95%, 90%, or 85%. When the consistency between the original language text and the text to be translated is lower than the preset threshold value, it can be proved that the translation effect of the target language text does not meet the translation accuracy corresponding to the preset threshold value, and a corresponding prompt message may be generated to prompt the relevant personnel that the accuracy of this translation is insufficient. The prompt message may be displayed through the above-mentioned computer and other devices, and may also be pushed to devices such as the smartphones of the relevant personnel, so that the relevant personnel may understand the relevant information more promptly.
[0100] Of course, the above contents are all examples, and the specific preset threshold form, specific prompt information prompt method, etc. can be selected and determined according to actual needs and are not limited here.
[0101] Optionally, in Figure 1 Based on the embodiment, the above-mentioned to-be-translated files and the above-mentioned target language files are both multiple, and after the corresponding target language files are generated according to the preset generation algorithm and the above-mentioned target language text, the method may also include
[0102] The plurality of target language files are stored according to a preset file structure.
[0103] Exemplarily, the above-mentioned multiple target language files are stored according to the preset file structure. Specifically, for example, a new locale (storing localization setting files) directory is generated, and the multiple target language files are stored therein to ensure the integrity and consistency of the file structure and avoid errors that may occur when manually creating files.
[0104] Of course, the above content is only an example, and the specific preset file structure can be selected and determined according to actual needs and is not limited here.
[0105] In addition, in any of the above embodiments, for example, during the process of translating the above text to be translated into the target language text through a preset translation function, generating the corresponding target language file according to a preset generation algorithm and the above target language text, etc., a log can be generated to record whether the translation and generation process are successful, thereby facilitating relevant personnel to check the results of batch translation, batch generation, etc., and accurately locate the content or files that failed to be translated or generated.
[0106] Furthermore, in the above process, for example, by translating the above text to be translated into a target language text through a preset translation function, generating a corresponding target language file according to a preset generation algorithm and the above target language text, etc., multiple versions of backup files of each node can also be generated to avoid losses caused by file damage and content loss due to failure of the translation and generation process.
[0107] Optionally, after translating the text to be translated into the target language text through the preset translation function, evaluation feedback from relevant personnel can also be received through a specific preset feedback interface. The evaluation feedback can be used to indicate the evaluation feedback of relevant personnel on, for example, the accuracy of this translation, problems existing in the translation, etc., and then the evaluation feedback can be referred to to optimize the preset translation function in a targeted manner.
[0108] Of course, the above content is just a possible concept. How to realize the generation of the above record log or backup file, how to design the above preset feedback interface, what aspects of the above evaluation feedback are included, etc. can all be selected and determined according to actual needs and are not limited here.
[0109] Figure 5 A schematic diagram of the structure of a multi-language content translation device for a code provided in an embodiment of the present application. The construction site rescue path planning device can execute the multi-language content translation method of the above code. The device can be integrated into the above-mentioned computer or other device with computing processing capabilities, such as Figure 5 As shown, the device comprises:
[0110] The scanning module 510 is used to scan and obtain the file to be translated based on the translation instruction.
[0111] An extraction module 520 is used to extract the text to be translated in the above-mentioned file to be translated by using a preset extraction function;
[0112] A translation module 530, configured to translate the text to be translated into a target language text by using a preset translation function;
[0113] The generating module 540 is used to generate a corresponding target language file according to a preset generating algorithm and the target language text.
[0114] The multilingual content translation method of the code provided in the embodiment of the present application includes: based on the translation instruction, scanning and obtaining the file to be translated; extracting the text to be translated in the above-mentioned file to be translated by a preset extraction function; translating the above-mentioned text to be translated into the target language text by a preset translation function; generating the corresponding target language file according to the preset generation algorithm and the above-mentioned target language text. In this embodiment, the text to be translated in the file to be translated is extracted by a preset extraction function, thereby realizing the use of a preset translation function instead of manually entering text and obtaining translation content, and using a preset generation algorithm to generate the corresponding target language file from the translated text, thereby improving the translation efficiency of the multilingual version project development and reducing the risk of human error in the translation process.
[0115] Optionally, the scanning module 510 is specifically configured to scan and obtain a plurality of initial files to be translated based on the translation instruction, according to a preset scanning range or a preset scanning path; and obtain the files to be translated based on preset filtering conditions and the initial files to be translated.
[0116] Optionally, the extraction module 520 is specifically used to adopt preset extraction rules to identify and extract the content to be translated in the file to be translated to obtain a preliminary text to be translated; perform preset processing on the preliminary text to be translated to obtain the processed text to be translated, wherein the preset processing includes at least one of the following: removing comments, matching preset character patterns and de-duplication processing.
[0117] Optionally, the apparatus may further include: a storage module, configured to store the text to be translated according to a preset storage format, wherein the preset storage format includes a plurality of storage fields.
[0118] Optionally, the translation instruction may include: a target language identifier;
[0119] The translation module 530 is specifically configured to call the preset translation function through a preset translation algorithm to translate the text to be translated into a target language text corresponding to the target language identifier.
[0120] Optionally, the translation module 530 may also be used to translate the target language text into the original language text; calculate and obtain the consistency between the original language text and the text to be translated; and generate a prompt message if the consistency between the original language text and the text to be translated is lower than a preset threshold.
[0121] Optionally, there are multiple files to be translated and multiple target language files;
[0122] The generating module 540 may also be used to store a plurality of target language files according to a preset file structure.
[0123] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0124] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, the electronic device may be a device having computing and processing capabilities such as the above-mentioned computer, server, etc. Figure 6 As shown, the device 600 includes:
[0125] Processor 610 , storage medium 620 and bus 630 . Processor 610 and storage medium 620 are communicatively connected via bus 630 .
[0126] The storage medium 620 stores machine-readable instructions executable by the processor 610. When the electronic device is running, the processor 610 executes the machine-readable instructions to execute the multi-language content translation method of the above code.
[0127] It should be understood that Figure 6 The structure shown is only a schematic diagram of the structure of the electronic device. The electronic device may also include Figure 6 More or fewer components as shown, or with Figure 6 Different configurations are shown. Figure 6 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0128] The embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program can be executed by a processor, the multi-language content translation method of the code described in the above method embodiment is implemented.
[0129] The computer-readable storage medium may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium has storage space for program codes that execute any of the method steps in the above method. These program codes may be read from or written to one or more computer program products. The program code may be compressed, for example, in an appropriate form.
[0130] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0131] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0132] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.
[0133] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. All equivalent structural changes made by using the contents of the present application specification and drawings under the inventive concept of the present application, or directly / indirectly applied in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A method for translating multilingual content of a code, characterized in that: include: Based on the translation instructions, scan and obtain the files to be translated; Extracting the text to be translated in the file to be translated by using a preset extraction function; Translating the text to be translated into a target language text by using a preset translation function; According to the preset generation algorithm and the target language text, a corresponding target language file is generated.
2. The method according to claim 1, characterized in that The step of scanning and obtaining the file to be translated based on the translation instruction includes: Based on the translation instruction, scanning and acquiring a plurality of initial files to be translated according to a preset scanning range or a preset scanning path; The file to be translated is obtained according to a preset filtering condition and the initial file to be translated.
3. The method according to claim 1, characterized in that The extracting the text to be translated in the file to be translated by using a preset extraction function includes: Using preset extraction rules, identifying and extracting the content to be translated in the file to be translated, and obtaining a preliminary text to be translated; The preliminary text to be translated is subjected to a preset processing to obtain the processed text to be translated, wherein the preset processing includes at least one of the following: removing comments, matching a preset character pattern, and de-duplication processing.
4. The method according to claim 1, characterized in that: After extracting the text to be translated in the file to be translated by using a preset extraction function, the method further includes: The text to be translated is stored according to a preset storage format, where the preset storage format includes a plurality of storage fields.
5. The method according to claim 1, characterized in that: The translation instruction includes: a target language identifier; The translating the to-be-translated text into a target language text by using a preset translation function includes: The preset translation function is called by a preset translation algorithm to translate the text to be translated into a target language text corresponding to the target language identifier.
6. The method according to claim 1, characterized in that After translating the text to be translated into a target language text by using a preset translation function, the method further includes: Translating the target language text into the original language text; Calculating and obtaining the consistency between the original language text and the text to be translated; If the consistency between the original language text and the text to be translated is lower than a preset threshold, a prompt message is generated.
7. The method according to claim 1, characterized in that There are multiple files to be translated and multiple target language files; After generating the corresponding target language file according to the preset generation algorithm and the target language text, the method further includes: The plurality of target language files are stored according to a preset file structure.
8. A multi-language content translation device for a code, characterized in that: include: A scanning module, used for scanning and obtaining files to be translated based on translation instructions; An extraction module, used for extracting the text to be translated in the file to be translated by using a preset extraction function; A translation module, used for translating the text to be translated into a target language text through a preset translation function; The generating module is used to generate a corresponding target language file according to a preset generating algorithm and the target language text.
9. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, the processor and the storage medium communicate via the bus, and the processor executes the machine-readable instructions to perform the method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed.