File translation method and device, electronic equipment and storage medium

By traversing content and applying translation rules to front-end project files, the objects to be translated are automatically processed, which solves the problems of low manual translation efficiency and low accuracy, and achieves fast and efficient file translation.

CN119047491APending Publication Date: 2024-11-29GUANGZHOU BAOLUN ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411092835.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2024-11-29

AI Technical Summary

Technical Problem

In the prior art, the translation of front-end project files mainly relies on manual processing, resulting in low translation efficiency and low accuracy, and consuming a lot of labor costs.

Method used

The content traversal of the to-process project files is performed by pre-set translation conditions, determine the object to be translated, and apply target translation rules based on the object type, file format information and context information to achieve automated translation content replacement.

Benefits of technology

It improves the efficiency and accuracy of file translation, saves labor costs, and realizes rapid and automated translation processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119047491A_ABST
    Figure CN119047491A_ABST
Patent Text Reader

Abstract

The invention discloses a file translation method and device, electronic equipment and a storage medium. According to the specific scheme, content traversal is carried out on at least one sub-file in a to-be-processed project file according to a preset translation condition, so that at least one to-be-translated object is obtained; determining target translation content corresponding to the to-be-translated object according to the object type of the at least one to-be-translated object, file format information of a to-be-processed project file to which the to-be-translated object belongs, a target translation rule corresponding to the file format information and context information of the to-be-translated object in a file to which the to-be-translated object belongs; and replacing the to-be-translated object based on the target translation content. According to the method, the labor cost is saved, and the file translation efficiency and accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a file translation method, device, electronic equipment and storage medium. Background Art

[0002] In order to meet the internationalization requirements of software projects, the completed front-end project files need to be translated so that users from different countries can browse the web pages.

[0003] At present, the translation of front-end project files is mainly done by relevant personnel who retrieve the Chinese text to be translated in each file, then translate the Chinese text and replace the translated text with the Chinese text. However, manual processing not only consumes a lot of manpower costs, resulting in low efficiency of file translation, but also has low accuracy of file translation. Summary of the invention

[0004] The present invention provides a document translation method, device, electronic equipment and storage medium, which saves labor costs and improves the efficiency and accuracy of document translation.

[0005] According to one aspect of the present invention, a file translation method is provided, the method comprising:

[0006] Traversing the contents of at least one sub-file under the project file to be processed according to a preset translation condition to obtain at least one object to be translated;

[0007] Determining target translation content corresponding to the object to be translated according to an object type of at least one object to be translated, file format information of a project file to be processed to which the object to be translated belongs, a target translation rule corresponding to the file format information, and context information of the object to be translated in the document to which it belongs;

[0008] Replace the object to be translated based on the target translation content.

[0009] According to another aspect of the present invention, there is provided a document translation device, the device comprising:

[0010] A module for determining an object to be translated, used for traversing the content of at least one sub-file under the project file to be processed according to a preset translation condition, so as to obtain at least one object to be translated;

[0011] A translation content determination module, configured to determine a target translation content corresponding to the object to be translated based on an object type of at least one object to be translated, file format information of a project file to be processed to which the object to be translated belongs, a target translation rule corresponding to the file format information, and context information of the object to be translated in the document to which it belongs;

[0012] The content replacement module is used to replace the object to be translated based on the target translation content.

[0013] According to another aspect of the present invention, there is provided an electronic device, the electronic device comprising:

[0014] at least one processor; and

[0015] a memory communicatively connected to at least one processor; wherein,

[0016] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by at least one processor so that the at least one processor can execute the file translation method of any embodiment of the present invention.

[0017] According to another aspect of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the file translation method of any embodiment of the present invention when executed.

[0018] According to another aspect of the present invention, there is provided a computer program product, comprising a computer program, wherein the computer program implements the file translation method according to any embodiment of the present invention when executed by a processor.

[0019] The technical solution of the embodiment of the present invention determines the object of subsequent translation processing by traversing the content of at least one sub-file under the project file to be processed according to the preset translation conditions to obtain at least one object to be translated. According to the object type of at least one object to be translated, the file format information of the project file to be processed to which the object to be translated belongs, the target translation rule corresponding to the file format information, and the context information of the object to be translated in the document to which it belongs, the target translation content corresponding to the object to be translated is determined. The target translation content is accurately determined, and the accuracy of the translation processing is improved. The target translation content replaces the object to be translated, and the automatic translation processing of the project file to be processed is realized. The problem of low translation efficiency and low translation accuracy caused by manual translation one by one is solved. The present invention realizes the rapid translation processing of the project file to be processed through the above method, saves labor costs, and improves the efficiency and accuracy of the translation processing.

[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0022] Figure 1 is a flow chart of a file translation method provided by an embodiment of the present invention;

[0023] Figure 2 is a flow chart of a file translation method provided by an embodiment of the present invention;

[0024] Figure 3 is an example diagram of a document to which an object to be translated belongs provided by an embodiment of the present invention;

[0025] Figure 4 It is a structural schematic diagram of a file translation device provided by an embodiment of the present invention;

[0026] Figure 5 It is a schematic diagram of the structure of an electronic device for implementing the file translation method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0029] Embodiment 1

[0030] Figure 1This is a flowchart of a file translation method provided by the first embodiment of the present invention. This embodiment is applicable to the case where the object to be translated in the project file to be processed is translated. The method can be executed by a file translation device. The file translation device can be implemented in the form of hardware and / or software. The file translation device can be configured in an electronic device such as a mobile phone, a computer or a server. Figure 1 As shown, the method includes:

[0031] S110: traverse the content of at least one sub-file under the project file to be processed according to a preset translation condition to obtain at least one object to be translated.

[0032] Among them, the pre-set translation conditions can be used to determine the objects that need to be translated in the pending project file. It can be understood that according to the pre-set translation conditions, it can be determined which language text in the pending project file is translated. For example, the pre-set translation conditions can be to translate the Chinese text in the pending project file, or to translate the Japanese text in the pending project file, or to translate the Korean text in the pending project file. If the pre-set translation condition is to translate the Chinese text in the pending project file, the Chinese text in the pending project file is the object that needs to be translated, that is, the object to be translated. The pending project file can be a project file that needs to be translated. Optionally, in order to improve the international adaptability of the front-end project, each sub-file in the front-end project can be subjected to corresponding translation processing. Then, the pending project file can be a front-end project file that has been developed in advance. Accordingly, at least one sub-file is included in the front-end project file.

[0033] Specifically, according to the preset translation conditions, the language to be translated in the pending project file is determined. According to the language to be translated in the pending project file, the content of at least one sub-file corresponding to the pending project file is traversed to obtain the object to be translated corresponding to the language to be translated in the pending project file.

[0034] Exemplary, in order to avoid direct modification of the source code in the original project file, the original project file can be copied to obtain a pending project file that is consistent with the original project file content. Take the pre-set translation condition as an example to explain the Chinese text in the pending project file. The vue-i18n plug-in is introduced to cooperate to complete the translation processing operation. According to the fs module of Node, all vue files in the pending project file are traversed, the code in the template tag and the code in the script tag in the vue file are read, and different variables are used for storage. For example, the content in the template tag is stored in the temContent variable, and the content of the script tag is stored in the scrContent variable. Traverse the content in the template tag in the vue file, match the Chinese text in temContent based on the regular expression, and obtain the object to be translated. Similarly, the content in the script tag can also be processed based on the above method to obtain the corresponding object to be translated. It should be noted that the content in the vue file can be stored separately, and the content of the vue file, js file and ts file in the pending project file can be directly traversed, and at least one object to be translated corresponding to the pending project file is obtained according to the regular expression.

[0035] Optionally, performing content traversal on at least one sub-file under the project file to be processed according to preset translation conditions to obtain at least one object to be translated, including: determining the language to be translated corresponding to the project file to be processed according to the preset translation conditions; performing content traversal processing on at least one sub-file under the project file to be processed to obtain at least one object to be translated corresponding to the language to be translated.

[0036] The language to be translated may be a language that needs to be translated in the project file to be processed, for example, Chinese, Japanese, Korean, etc.

[0037] Specifically, according to the preset translation conditions, the language to be translated corresponding to the project file to be processed is determined. The content of at least one sub-file under the project file to be processed is traversed, and at least one object to be translated corresponding to the language to be translated is determined from the at least one sub-file, so as to facilitate the subsequent direct translation processing of the object to be translated.

[0038] S120: Determine target translation content corresponding to the object to be translated according to an object type of at least one object to be translated, file format information of a project file to be processed to which the object to be translated belongs, a target translation rule corresponding to the file format information, and context information of the object to be translated in the document to which it belongs.

[0039] Among them, the object type can be determined according to the language to be translated corresponding to the object to be translated. For example, the object to be translated can be of Chinese type, Korean type and Japanese type. The file format information can be the file format corresponding to the project file to be processed. For example, taking the project file to be processed as a front-end project file as an example, the file format information can be used to distinguish whether the file currently required to be translated in the project file to be processed is a vue file, a js file or a ts file. If the vue file in the project file to be processed is translated, the file format information can be set to the first file format; if the js or ts file in the project file to be processed is translated, the file format information can be set to the second file format. The target translation rule can be the translation rule corresponding to the file format information. Different file format information corresponds to different target translation rules. The context information can be understood as the text environment of the object to be translated in the document to which it belongs. For example, the context information can be the information of the characters before and after the object to be translated in the document to which it belongs, or it can be the string information in the document to which it belongs. The target translation content can be the translation result corresponding to the object to be translated.

[0040] Specifically, according to the file format information of the to-be-translated project file to which the object to be translated belongs and the context information of the object to be translated in the document to which it belongs, the target translation rule corresponding to the file format information can be determined. The target translation language of the object to be translated is determined according to actual needs. For example, the target translation language may be English. According to the object type of at least one object to be translated, the target translation language of the object to be translated, and the target translation rule of the object to be translated, the target translation content of the object to be translated is determined. For example, if the object type is Chinese, the target translation language is English, and the object to be translated is "doctor", the target translation content determined according to the target translation rule may be {{$t(doctor)}}, where only the target translation content is given as an example, and no limitation is imposed on the specific object to be translated and the target translation content.

[0041] S130: Replace the object to be translated based on the target translation content.

[0042] Specifically, the object to be translated in the project file to be processed is replaced with the target translation content to achieve file translation of the project file to be processed.

[0043] The technical solution of this embodiment determines the object of subsequent translation processing by traversing the content of at least one sub-file under the project file to be processed according to the preset translation conditions to obtain at least one object to be translated. According to the object type of at least one object to be translated, the file format information of the project file to be processed to which the object to be translated belongs, the target translation rule corresponding to the file format information, and the context information of the object to be translated in the document to which it belongs, the target translation content corresponding to the object to be translated is determined, and the target translation content is accurately determined, and the accuracy of the translation processing is improved. The target translation content replaces the object to be translated, and the automatic translation processing of the project file to be processed is realized. The problem of low translation efficiency and low translation accuracy caused by manual translation one by one is solved. The present invention realizes the rapid translation processing of the project file to be processed through the above method, saves labor costs, and improves the efficiency and accuracy of the translation processing.

[0044] Embodiment 2

[0045] Figure 2 This is a flowchart of a file translation method provided by the second embodiment of the present invention. This embodiment is based on the above embodiment and further refines the step of determining the target translation content corresponding to the object to be translated. The specific implementation method can refer to the technical solution of this embodiment. Among them, the technical terms that are the same or corresponding to the above embodiment are not repeated here. Figure 2 As shown, the method includes:

[0046] S210: traverse the content of at least one sub-file under the project file to be processed according to a preset translation condition to obtain at least one object to be translated.

[0047] S220: Determine a target translation rule from at least one preset translation rule based on the file format information of the project file to be processed to which the object to be translated belongs and the context information of the object to be translated in the corresponding document.

[0048] The preset translation rule may be a preset translation rule of the object to be translated, and the translation format corresponding to the object to be translated may be determined by the preset translation rule.

[0049] Specifically, the file format information of the project file to be processed to which the object to be translated belongs is determined, and different file format information corresponds to different translation rules. According to the file format information and the context information of the object to be translated in the corresponding document, a preset translation rule matching the above two is selected from at least one preset translation rule, and the preset translation rule is used as the target translation rule.

[0050] Optionally, based on the file format information of the project file to be processed to which the object to be translated belongs and the context information of the object to be translated in the document to which it belongs, a target translation rule is determined from at least one preset translation rule, including: when it is determined that the file format information is a first file format and the previous character or the next character of the object to be translated in the document to which it belongs is a first preset character, the target translation rule is determined to be the first preset translation rule; when it is determined that the file format information is the first file format and the previous character of the object to be translated in the document to which it belongs is a second preset character and the previous character of the second preset character is a third preset character, the target translation rule is determined to be the second preset translation rule.

[0051] The first file format may be a preset file format information. For example, taking the project file to be processed as a front-end project file as an example, the first file format may be a vue file format. The first preset character may be a non-blank character used to represent the context information corresponding to the object to be translated. For example, the first preset character may be " > "or" < ". The first preset translation rule may be a preset translation rule. The first preset translation rule may be used to present the translation text corresponding to the object to be translated in a preset format. For example, the first preset translation rule may be a rule for presenting the translation text corresponding to the object to be translated in the format of "{{$t(translation text)}}". If the object to be translated is "doctor", the target translation language is determined to be English, and the target translation text is determined to be "doctor", then the first preset translation rule may be used to replace "doctor" with "{{$t(doctor)}}". The second preset character may be a preset non-blank character. For example, the second preset character may be a single quotation mark or a double quotation mark. The third preset character is also a preset non-blank character. For example, the third preset character may be “=”. For example, taking the first file format as the vue format, if the previous character of the object to be translated is a single quote or a double quote, and the previous character of the single quote or the double quote is “=”, then the object to be translated can be considered to be the attribute value of the tag element. The second preset translation rule may be a pre-set translation rule. The second preset translation rule may be used to present the translation text corresponding to the object to be translated in a preset format. For example, the second preset translation rule may be used to present the translation text corresponding to the object to be translated in the format of “$t(translation text)”. If the object to be translated is “doctor”, and the target translation language is determined to be English, then the target translation text is determined to be “doctor”, then the second preset translation rule may be used to replace “doctor” with “$t(doctor)”.

[0052] Specifically, the file format information corresponding to the object to be translated is determined. When the file format information is the first file format, the document to which the object to be translated belongs is traversed and processed. If it is determined that the previous non-blank character and the next non-blank character of the object to be translated are the first preset characters, the first preset translation rule is used as the target translation rule. Correspondingly, when the file format information is the first file format, if it is determined that the previous non-blank character of the object to be translated is the second preset character, and the previous non-blank character of the second preset character is the third preset character, the second preset translation rule is used as the target translation rule.

[0053] For example, in combination with the above example, the first file format is a vue file format. If the object to be translated is obtained from the content in the vue file template tag, the object to be translated and the context information corresponding to the object to be translated can be determined by traversing the corresponding content in the template tag from back to front. Figure 3 , the object to be translated can be Figure 3 The "mouse hover to view message" in the text. The preceding non-blank character and the following non-blank character of the object to be translated are ">" and "<" respectively, indicating that the object to be translated is a child node of the tag element, and the target translation rule is the first preset translation rule. That is, "mouse hover to view message" is replaced with "{{$t(A)}}". Among them, A is the translation text of the target translation language corresponding to the preset "mouse hover to view message".

[0054] Combining the above examples, the object to be translated can be Figure 3 In the example, if the first non-blank character of the object to be translated is a double quotation mark, and the first non-blank character of the double quotation mark is "=", the target translation rule can be set to the second preset translation rule. That is, "This is a Chinese message" is replaced with "$t(B)". Among them, B is the translation text of the target translation language corresponding to the preset "This is a Chinese message".

[0055] It should be noted that, in the process of traversing the text to be translated from back to front, if it is detected that the previous non-blank character of the object to be translated is not the first preset character, such as the previous non-blank character is not ">", then continue to traverse forward until the third preset character "=" is detected, and determine that the object to be translated is the attribute value of the tag element. Continue to traverse forward from the third preset character until an empty character is detected, determine the attribute name corresponding to the attribute value, and determine whether the previous character of the attribute name is ":". If so, replace ": attribute name = 'object to be translated'" with ": attribute name = '$t(C)'". If the previous character of the attribute name is not ":", replace ": attribute name = 'object to be translated'" with ": attribute name = '$t(C)'". Wherein, C is the translation text corresponding to the object to be translated. In addition, if there are other situations, other preset translation rules can be added on the basis of the above method, and the translation replacement processing of the object to be translated can be implemented based on the preset translation rules.

[0056] Optionally, the method also includes: when it is determined that the file format information is the first file format and the document to which the object to be translated belongs contains a preset string, determining that the target translation rule is a third preset translation rule; when it is determined that the file format information is the first file format and the document to which the object to be translated belongs does not contain the preset string, determining that the target translation rule is a fourth preset translation rule.

[0057] Among them, the preset string can be a string contained in the document to which the object to be translated belongs. The version type of the document to which the object to be translated belongs can be determined by the preset string, so as to determine the corresponding preset translation rule according to the version type. For example, taking the first file format as the vue format as an example, the preset string can be "setup". If the document to which the object to be translated belongs contains "setup", it means that the project file to be processed is a vue3 version file. If the document to which the object to be translated belongs does not contain "setup", it means that the project file to be processed is a vue2 version file. The third preset translation rule and the fourth preset translation rule can be rules for presenting the translation text corresponding to the object to be translated in a preset format. For example, the third preset translation rule can be to replace the object to be translated with "proxy.$t(E)". The fourth preset translation rule can be to replace the object to be translated with "this.$t(E)". Among them, E is the translation text corresponding to the object to be translated.

[0058] Specifically, when it is determined that the file format information is the first file format, the document to which the translation object belongs is traversed to determine whether the document contains a preset string. If the document contains the preset string, the version type corresponding to the project file to be processed is determined, and the third preset translation rule is used as the target translation rule. If the document does not contain the preset string, the fourth preset translation rule is used as the target translation rule.

[0059] Exemplary, in combination with the above example, the first file format is a vue file format as an example for explanation. If the object to be translated belongs to the corresponding content in the script tag in the vue file, the object to be translated and the context information corresponding to the object to be translated can be determined by traversing the corresponding content in the script tag from back to front. If, according to the context information, it is determined that the document to which the object to be translated belongs contains the preset string "setup", it indicates that the project file to be processed is a vue3 version of the file. When the object to be translated is subjected to translation replacement processing, a custom global object mounted under the t function of vue-i18n can be used. That is, the object to be translated is replaced with the global object "proxy.$t(E)", and E is the translation text corresponding to the object to be translated. Correspondingly, if, according to the context information, it is determined that the document to which the object to be translated belongs does not contain the preset string "setup", it indicates that the project file to be processed is a vue2 version of the file. When the object to be translated is subjected to translation replacement processing, this can be used to access the t function of vue-i18n. That is, the object to be translated is replaced with "this.$t(E)", and E is the translation text corresponding to the object to be translated.

[0060] Optionally, the method further includes: when determining that the file format information is the second file format, determining version type information corresponding to the project file to be processed based on context information; and determining that the target translation rule is a fifth preset translation rule based on the preset object instance and the version type information.

[0061] Among them, the second file format can be a pre-set file format information. For example, taking the project file to be processed as a front-end project file as an example, the second file format can be a js file format or a ts file format. The version type information can be the version type corresponding to the project file to be processed determined according to the context information. The preset object instance can be a pre-created object instance. For example, in order to facilitate the introduction of the vue-i 18n plug-in to cooperate with the translation processing of the object to be translated, a corresponding object instance can be created. The fifth preset translation rule can be a preset translation rule corresponding to the second file format.

[0062] Specifically, when the file format information is determined to be the second file format, the version type information corresponding to the project file to be processed is determined according to the context information. According to the version type information and the preset object instance, a fifth preset translation rule corresponding to the version type information is determined.

[0063] Exemplarily, in combination with the above example, all js and ts files in the project file to be processed are traversed through Node's fs module to determine the preset object instance that needs to be created when each js and ts file is introduced into the vue-i18n plug-in separately, and the object to be translated is translated according to the preset object instance and the corresponding version type information.

[0064] S230: Based on the object type of at least one object to be translated and a target translation rule, translate the object to be translated to obtain target translation content corresponding to the object to be translated.

[0065] Specifically, the language to be translated of the object to be translated is determined according to the object type of the object to be translated. The target translation language of the object to be translated is set according to actual needs. Then, according to the language to be translated, the target translation language and the target translation rule, the object to be translated is translated to obtain the target translation content corresponding to the object to be translated.

[0066] Optionally, based on the object type of at least one object to be translated and a target translation rule, the object to be translated is translated to obtain target translation content corresponding to the object to be translated, including: determining a translation file to be applied based on the object type of at least one object to be translated, and determining the target translation content of the object to be translated based on the translation file to be applied and the target translation rule, wherein the translation file to be applied includes a source text corresponding to the object to be translated and at least one translation text to be used corresponding to the source text.

[0067] Among them, the translation file to be applied can be a translation text file in a preset format corresponding to the text of the project to be processed. For example, the translation file to be applied can be a file in JSON format. The translation file to be applied includes a source text corresponding to the object to be translated and at least one translation text to be used corresponding to the source text. The source text can be a text of the same object type as the object to be translated. The translation text to be used can be a text in a different target translation language corresponding to the source text. For example, the translation file to be applied can include a source text in Chinese and translation texts to be used in target translation languages ​​such as English, Japanese and Korean.

[0068] Specifically, according to the object type of at least one object to be translated, a translation file to be applied corresponding to the object type is determined. In the translation file to be applied, a source text consistent with the object to be translated is determined. According to the source text, a corresponding translation text to be used is determined. According to the translation text to be used and the target translation rule, a target translation content of the object to be translated is determined.

[0069] Optionally, all source texts in the project file to be processed are retrieved by regular expressions, and all source texts are deduplicated to obtain deduplicated source texts. According to the source text and at least one translation text to be used corresponding to the source text, a JSON format file is constructed with the source text as the key and the translation text to be used as the value, i.e., the translation file to be applied. For example, the translation file to be applied translations can be expressed as:

[0070]

[0071] S240: Replace the object to be translated based on the target translation content.

[0072] The technical solution of this embodiment performs content traversal on at least one sub-file under the project file to be processed according to a preset translation condition to obtain at least one object to be translated. Based on the file format information of the project file to be processed to which the object to be translated belongs and the context information of the object to be translated in the document to which it belongs, a target translation rule is determined from at least one preset translation rule. Based on the object type of at least one object to be translated and the target translation rule, the object to be translated is translated to obtain the target translation content corresponding to the object to be translated. Accurate determination of the target translation content is achieved, and the accuracy of the translation process is improved. The target translation content is replaced with the object to be translated, and automatic translation processing of the project file to be processed is achieved. The problem of low translation efficiency and low translation accuracy caused by manual translation one by one is solved. The present invention realizes rapid translation processing of the project file to be processed through the above method, saves labor costs, and improves the efficiency and accuracy of the translation process.

[0073] Embodiment 3

[0074] Figure 4 Schematic diagram of the structure of a file translation device provided by Embodiment 3 of the present invention. Figure 4 As shown, the device includes: a to-be-translated object determination module 310 , a translation content determination module 320 , and a content replacement module 330 .

[0075] The module 310 for determining an object to be translated is used to perform content traversal on at least one subfile under the project file to be processed according to a preset translation condition to obtain at least one object to be translated; the module 320 for determining the translation content is used to determine the target translation content corresponding to the object to be translated according to the object type of the at least one object to be translated, the file format information of the project file to be processed to which the object to be translated belongs, the target translation rule corresponding to the file format information, and the context information of the object to be translated in the document to which it belongs; the content replacement module 330 is used to replace the object to be translated based on the target translation content.

[0076] The technical solution of this embodiment determines the object of subsequent translation processing by traversing the content of at least one sub-file under the project file to be processed according to the preset translation conditions to obtain at least one object to be translated. According to the object type of at least one object to be translated, the file format information of the project file to be processed to which the object to be translated belongs, the target translation rule corresponding to the file format information, and the context information of the object to be translated in the document to which it belongs, the target translation content corresponding to the object to be translated is determined, and the target translation content is accurately determined, and the accuracy of the translation processing is improved. The target translation content replaces the object to be translated, and the automatic translation processing of the project file to be processed is realized. The problem of low translation efficiency and low translation accuracy caused by manual translation one by one is solved. The present invention realizes the rapid translation processing of the project file to be processed through the above method, saves labor costs, and improves the efficiency and accuracy of the translation processing.

[0077] On the basis of the above embodiment, optionally, the module for determining an object to be translated includes: a unit for determining a language to be translated, which is used to determine the language to be translated corresponding to the project file to be processed according to a preset translation condition; and a content traversal unit, which is used to perform content traversal processing on at least one sub-file under the project file to be processed to obtain at least one object to be translated corresponding to the language to be translated.

[0078] Optionally, the translation content determination module includes: a target translation rule determination unit, which is used to determine a target translation rule from at least one preset translation rule based on file format information of a project file to be processed to which the object to be translated belongs and context information of the object to be translated in the corresponding document; and a target translation content determination unit, which is used to translate the object to be translated based on at least one object type of the object to be translated and the target translation rule, to obtain a target translation content corresponding to the object to be translated.

[0079] Optionally, the target translation rule determination unit includes: when it is determined that the file format information is a first file format and the previous character or the next character of the object to be translated in the corresponding document is a first preset character, determining the target translation rule to be a first preset translation rule; when it is determined that the file format information is the first file format and the previous character of the object to be translated in the corresponding document is a second preset character and the previous character of the second preset character is a third preset character, determining the target translation rule to be a second preset translation rule.

[0080] Optionally, the target translation rule determination unit also includes: when it is determined that the file format information is the first file format and the document to which the object to be translated belongs contains a preset string, determining the target translation rule to be a third preset translation rule; when it is determined that the file format information is the first file format and the document to which the object to be translated belongs does not contain the preset string, determining the target translation rule to be a fourth preset translation rule.

[0081] Optionally, the target translation rule determination unit further includes: when determining that the file format information is the second file format, determining version type information corresponding to the project file to be processed based on context information; and determining that the target translation rule is a fifth preset translation rule based on the preset object instance and the version type information.

[0082] Optionally, the target translation content determination unit is used to determine a translation file to be applied based on an object type of at least one object to be translated, and to determine a target translation content of the object to be translated based on the translation file to be applied and a target translation rule, wherein the translation file to be applied includes a source text corresponding to the object to be translated and at least one translation text to be used corresponding to the source text.

[0083] The file translation device provided in the embodiment of the present invention can execute the file translation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0084] Embodiment 4

[0085] Figure 5 1 is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0086] like Figure 5 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0087] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0088] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a file translation method.

[0089] In some embodiments, the file translation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the file translation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the file translation method in any other appropriate manner (e.g., by means of firmware).

[0090] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0091] The computer programs for implementing the document translation method of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that when the computer programs are executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer programs may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0092] Embodiment 5

[0093] Embodiment 5 of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to execute a file translation method, the method comprising:

[0094] According to a preset translation condition, at least one sub-file under the to-be-processed project file is traversed to obtain at least one to-be-translated object; according to the object type of the at least one to-be-translated object, the file format information of the to-be-translated project file to which the to-be-translated object belongs, the target translation rule corresponding to the file format information, and the context information of the to-be-translated object in the to-be-translated document, the target translation content corresponding to the to-be-translated object is determined; and the to-be-translated object is replaced based on the target translation content.

[0095] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0096] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0097] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0098] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0099] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0100] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for translating a document, characterized in that: include: Traversing the contents of at least one sub-file under the project file to be processed according to a preset translation condition to obtain at least one object to be translated; Determining target translation content corresponding to the at least one object to be translated according to the object type of the at least one object to be translated, the file format information of the project file to be processed to which the object to be translated belongs, the target translation rule corresponding to the file format information, and the context information of the object to be translated in the document to which it belongs; The object to be translated is replaced based on the target translation content.

2. The method according to claim 1, characterized in that The step of traversing the content of at least one sub-file under the project file to be processed according to the preset translation condition to obtain at least one object to be translated includes: Determining the language to be translated corresponding to the project file to be processed according to the preset translation conditions; Perform content traversal processing on at least one subfile under the to-be-processed project file to obtain at least one to-be-translated object corresponding to the to-be-translated language.

3. The method according to claim 1, characterized in that The determining, according to the object type of the at least one object to be translated, the file format information of the project file to be processed to which the object to be translated belongs, the target translation rule corresponding to the file format information, and the context information of the object to be translated in the document to which it belongs, the target translation content corresponding to the object to be translated comprises: Determining a target translation rule from at least one preset translation rule based on file format information of a project file to be processed to which the object to be translated belongs and context information of the object to be translated in the corresponding document; Based on the object type of the at least one object to be translated and the target translation rule, the object to be translated is translated to obtain target translation content corresponding to the object to be translated.

4. The method according to claim 3, characterized in that The determining of a target translation rule from at least one preset translation rule based on the file format information of the to-be-translated project file to which the to-be-translated object belongs and the context information of the to-be-translated object in the to-be-translated document includes: When it is determined that the file format information is a first file format and the preceding character or the succeeding character of the object to be translated in the corresponding document is a first preset character, determining that the target translation rule is the first preset translation rule; When it is determined that the file format information is the first file format, and the previous character of the object to be translated in the corresponding document is a second preset character and the previous character of the second preset character is a third preset character, the target translation rule is determined to be the second preset translation rule.

5. The method according to claim 4, characterized in that Also includes: When it is determined that the file format information is the first file format and the document to which the object to be translated belongs contains a preset character string, determining that the target translation rule is a third preset translation rule; When it is determined that the file format information is the first file format and the document to which the object to be translated belongs does not contain a preset character string, the target translation rule is determined to be a fourth preset translation rule.

6. The method according to claim 4, characterized in that Also includes: When it is determined that the file format information is the second file format, based on the context information, determining version type information corresponding to the to-be-processed project file; Based on the preset object instance and the version type information, the target translation rule is determined to be a fifth preset translation rule.

7. The method according to claim 3, characterized in that The translating process of the at least one object to be translated based on the object type of the at least one object to be translated and the target translation rule to obtain the target translation content corresponding to the object to be translated includes: Based on the object type of the at least one object to be translated, a translation file to be applied is determined, so as to determine the target translation content of the object to be translated based on the translation file to be applied and the target translation rule, wherein the translation file to be applied includes a source text corresponding to the object to be translated and at least one translation text to be used corresponding to the source text.

8. A document translation device, characterized in that: include: A module for determining an object to be translated, used for traversing the content of at least one sub-file under the project file to be processed according to a preset translation condition, so as to obtain at least one object to be translated; a translation content determination module, configured to determine a target translation content corresponding to the at least one object to be translated according to an object type of the at least one object to be translated, file format information of a project file to be processed to which the object to be translated belongs, a target translation rule corresponding to the file format information, and context information of the object to be translated in a corresponding document; A content replacement module is used to replace the object to be translated based on the target translation content.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the document translation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the file translation method according to any one of claims 1 to 7 when executed.