Language translation method and device, computer equipment, readable storage medium and computer program product

By automatically reading and importing the strings to be translated in the translated file into the Excel table for translation, and re-importing the translated strings into the translated file, the problem of inefficient translation file management and translation process in the existing technology is solved, efficient and accurate translation work is achieved, and development costs are reduced.

CN119830929APending Publication Date: 2025-04-15QIAOHONG NUMERICAL CONTROL TECH SHANGHAI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510082769.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-17
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

The prior art is inefficient in the process of translation file management and translation, prone to errors, and cannot batch process multiple translated files, resulting in increased workload of developers and increased possibility of errors.

Method used

Provides a language translation method, which automatically reads the string to be translated in the translation file, exports it to an Excel table for translation, and reimports the translated string into the translation file. The method includes obtaining the translation file, reading the string and context information to be translated, exporting to an Excel table, translating line by line and importing the updated translation file.

Benefits of technology

It improves the efficiency and accuracy of translation work, reduces errors caused by manual operations, avoids string omissions or duplication problems during the translation process, reduces development costs, and simplifies the management and translation process of translated files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119830929A_ABST
    Figure CN119830929A_ABST
Patent Text Reader

Abstract

The invention discloses a language translation method and device, computer equipment, a readable storage medium and a computer program product, and belongs to the technical field of computer processing. The method comprises the steps of obtaining a translation file; reading a to-be-translated character string and corresponding context information in the translated file, and exporting and generating an Excel table; translating the character strings to be translated in the Excel table line by line to obtain translated character strings, and importing the translated character strings into corresponding positions of the Excel table line by line to obtain an updated Excel table; and reading the updated Excel table, and importing the translated character string and updating the translation file. The management and translation process of the translation file can be simplified, and the efficiency and accuracy of translation work are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer processing technology, and in particular, to a language translation method, apparatus, computer equipment, readable storage medium, and computer program product. Background Art

[0002] In modern software development, internationalization and localization are key steps to ensure that applications can support multiple languages. Qt is a popular cross-platform C++ framework that is widely used to develop graphical user interface (GUI) applications. Qt provides powerful internationalization support, using .ts files to store strings to be translated and .qm files to store compiled translation results.

[0003] However, in the actual development process, translators are usually unfamiliar with programming tools or formats and find it difficult to edit .ts files directly. Existing solutions usually rely on developers to manually extract strings from .ts files and then export them as CSV or Excel files for translators to use. This approach is inefficient, error-prone, and lacks flexibility.

[0004] In addition, in the prior art, usually only one translation file can be processed at a time, and multiple translation files cannot be processed in batches. As a result, developers need to repeat the same operations for each language, increasing the workload and the possibility of errors. The management of translation files becomes complicated, especially when the project supports multiple languages, which is prone to omissions or confusion. Moreover, manually managing translation files in multiple languages ​​is prone to errors, especially when the project is large. Summary of the invention

[0005] The embodiments of the present application provide a language translation method, apparatus, computer equipment, readable storage medium and computer program product. The purpose of the embodiments of the present application is to provide a language translation method, apparatus, computer equipment, readable storage medium and computer program product, which can solve the problem of how to simplify the management and translation process of translation files and improve the efficiency and accuracy of translation work.

[0006] In order to solve the above technical problems, this application is implemented as follows: In a first aspect, a language translation method is provided, comprising: Obtain a translation file, wherein the translation file includes a .ts file or an xml file; Reading the character string to be translated and the context information corresponding to the character string to be translated in the translation file; Exporting the character string to be translated and context information corresponding to the character string to be translated to generate an Excel table; Translating the character strings to be translated in the Excel table row by row to obtain translated character strings, and importing the translated character strings row by row into corresponding positions in the Excel table according to context information corresponding to the character strings to be translated, to obtain an updated Excel table; The updated Excel spreadsheet is read, and the translated character string is imported into and updated into the translation file.

[0007] Optionally, the translation file includes one or more.

[0008] Optionally, the reading the string to be translated in the translation file and the context information corresponding to the string to be translated includes: parsing the translation file using QDomDocument class of Qt, and reading the string to be translated in the translation file and the context information corresponding to the string to be translated; The step of exporting the character string to be translated and the context information corresponding to the character string to be translated to generate an Excel table includes: using a third-party library to connect an Excel control, and reading the character string to be translated and the context information corresponding to the character string to be translated into the Excel table; The reading of the updated Excel table, importing the translated strings into and updating the translation file comprises: using Qt's QAxObject and QDomDocument classes to read the translated strings in the updated Excel table into the translation file, and replacing the corresponding strings to be translated according to the context information.

[0009] Optionally, translating the character strings to be translated in the Excel table row by row to obtain translated character strings, and importing the translated character strings row by row into corresponding positions of the Excel table according to context information corresponding to the character strings to be translated, to obtain an updated Excel table, includes: Copy the strings to be translated in the Excel table into the csv table row by row; Using the document translation function of the translation software, the character strings to be translated in the csv table are translated line by line to obtain the translated character strings; The translated character string is imported into the position corresponding to the context information corresponding to the character string to be translated in the Excel table to obtain the updated Excel table.

[0010] Optionally, after reading the updated Excel spreadsheet, importing the translated character string and updating the translation file, the method further includes: In the updated translation file, the translated string is matched according to the string to be translated and the context information corresponding to the string to be translated. If the match is successful, the string at the corresponding position in the updated translation file is replaced with the translated string.

[0011] In a second aspect, a language translation device is provided, comprising: An acquisition module, used to acquire a translation file, wherein the translation file includes a .ts file or an xml file; A parsing module, used for reading the character string to be translated in the translation file and the context information corresponding to the character string to be translated; An Excel table generating module, used for exporting the character string to be translated and the context information corresponding to the character string to be translated into an Excel table; A translation processing module, used for translating the character strings to be translated in the Excel table line by line to obtain translated character strings, and importing the translated character strings line by line into corresponding positions in the Excel table according to context information corresponding to the character strings to be translated, to obtain an updated Excel table; The import and update module is used to read the updated Excel table, import the translated character string and update the translation file.

[0012] Optionally, the parsing module reads the string to be translated in the translation file and the context information corresponding to the string to be translated in the translation file in the following manner: using QDomDocument class of Qt to parse the translation file, and reading the string to be translated in the translation file and the context information corresponding to the string to be translated; The Excel table generation module exports the character string to be translated and the context information corresponding to the character string to be translated to generate an Excel table in the following manner: using a third-party library to connect Excel controls, and reading the character string to be translated and the context information corresponding to the character string to be translated into the Excel table; The import update module reads the updated Excel table, imports the translated strings and updates the translation file in the following manner: uses Qt's QAxObject and QDomDocument classes to read the translated strings in the updated Excel table into the translation file, and replaces the corresponding strings to be translated according to the context information.

[0013] In a third aspect, a computer device is provided, the computer device comprising a processor and a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to implement the above-mentioned language translation method.

[0014] In a fourth aspect, a readable storage medium is provided, wherein at least one computer program is stored in the readable storage medium, and the computer program is loaded and executed by a processor to implement the above-mentioned language translation method.

[0015] In a fifth aspect, a computer program product is provided, the computer program product comprising at least one computer program, the computer program being loaded and executed by a processor to implement the language translation method provided in the above-mentioned various optional implementations.

[0016] The technical solution provided by this application may have the following beneficial effects: The present application provides a language translation method, device, computer equipment, readable storage medium and computer program product, which automatically reads the string to be translated in the translation file and exports it to an Excel table, completes the translation of the string to be translated in the Excel table, re-imports the translated string into the translation file, and completes the translation of the translation file. The whole process can be completed automatically, which improves the efficiency of translation work while ensuring the correctness and consistency of the translation results, reduces the errors caused by manual operation, and largely avoids the problem of missing or duplicating strings in the translation process. In addition, developers no longer need to spend a lot of time on file management and format conversion, which reduces development costs and simplifies the management and translation process of translation files. Moreover, translators can directly edit Excel tables to further ensure the accuracy of the translation, and translators do not need to understand the format of .ts files or xml files, which reduces the cost of learning.

[0017] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0019] Figure 1 A flow chart of a language translation method provided by an exemplary embodiment of the present application is shown; Figure 2 A flow chart of a language translation method provided by an exemplary embodiment of the present application is shown; Figure 3A flow chart of a language translation method provided by an exemplary embodiment of the present application is shown; Figure 4 A schematic diagram of the structure of a language translation device provided by an exemplary embodiment of the present application is shown; Figure 5 It is a structural block diagram of a computer device according to an exemplary embodiment. DETAILED DESCRIPTION

[0020] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0021] This embodiment can be applied to a development environment using the Qt development framework, or to other development environments suitable for translation processing, which is not limited in this embodiment. The following briefly describes the relevant technologies of Qt.

[0022] QT is a cross-platform C++ graphical user interface library and a set of development tools. It allows developers to write code once and then compile and run it on multiple platforms, including Windows, macOS, Linux, Android, and iOS. QT is maintained by the Qt Company and has an active community support.

[0023] Qt Linguist is a powerful translation tool provided by Qt, which is specially used to manage and edit the multi-language support of applications. It can help developers and translators easily translate the application interface into multiple languages, ensuring that the application can be used in different regions and language environments.

[0024] QDomDocument is a class provided by Qt for processing XML documents. It is based on the W3C DOM (Document Object Model) standard and allows you to create, parse, modify and save XML documents. QDomDocument provides a rich API that makes XML operations simple and efficient.

[0025] QAxObject is a class provided by Qt for interacting with ActiveX controls in Qt applications. ActiveX is a technology developed by Microsoft that allows different applications to communicate with each other through COM (Component Object Model) interfaces. QAxObject allows Qt programs to easily call applications or controls that support ActiveX on the Windows platform, such as Microsoft Office applications (such as Word, Excel), Internet Explorer, etc.

[0026] QProcess is a class provided by Qt for launching external programs and communicating between them and applications. It allows you to start other processes from within a Qt application and read the output of these processes, send input to them, monitor their status, etc. QProcess is asynchronous, which means you can start a process and continue to perform other tasks without waiting for the process to complete.

[0027] QMap is an associative container class provided by Qt for storing key-value pairs. It is a template class that allows you to use keys and values ​​of any type. The internal implementation of QMap is based on a red-black tree, which means it provides automatic sorting of keys, and the time complexity of insertion, deletion, and search operations is O(log n).

[0028] Figure 1 The flowchart of a language translation method provided by an exemplary embodiment of the present application is shown. It should be noted that the method can be executed by a language translation device, which can be implemented in the form of hardware and / or software, and can be configured in a computer device such as a mobile phone, a computer or a server. Figure 1 As shown, Figure 1 As shown, the language translation method includes the following steps (S101-S105): S101, obtaining a translation file, where the translation file includes a .ts file or an xml file; In this embodiment, the translation file includes a .ts file or an xml file, so that the string in the translation project code or the string in the read file can be translated. In specific implementation, for example, you can click Tools->External->Linguist->Update Translation in the toolbar of QtCreator, and you can see the generated .ts file in the directory where the project code is located. Thus, you can obtain the .ts file of the string in the translation project code.

[0029] As an optional implementation of an exemplary embodiment of the present application, the translation file includes one or more. In this embodiment, multiple translation files can be obtained at one time, and each translation file is translated in the same way, and subsequent steps S102-S105 are performed to finally export multiple target translation files (i.e., files after the translation files are translated). In this way, multiple translation files can be imported in batches at one time, and multiple target translation files can be exported, so as to realize batch translation processing and improve translation efficiency.

[0030] S102, reading the character string to be translated and the context information corresponding to the character string to be translated in the translation file; In this embodiment, the source text of the string to be translated and the corresponding context can be read from the translation file. The source text refers to the original language text of the string to be translated. Each string to be translated contains at least one original language vocabulary. For example, when translating Chinese into English, the source text is Chinese text, and the string to be translated contains at least one Chinese character or phrase. The context information can be used to indicate the different semantics that may exist in the source text in different scenarios, or the semantics associated with the context, or the storage location information for uniquely identifying the string to be translated, etc. In this application example, the context information is specifically the file name where the string to be translated is located, which serves as the identification index of the string to be translated. For a specific explanation, please refer to the description in the specific example below. In addition, the language text that is finally required to be translated becomes the translation text of the target language, which is the translation language text corresponding to the source text.

[0031] As an optional implementation of an exemplary embodiment of the present application, reading the string to be translated in the translation file and the context information corresponding to the translation file includes: using Qt's QDomDocument class to parse the translation file, reading the string to be translated in the translation file and the context information corresponding to the string to be translated.

[0032] In a specific example, taking .ts files as an example, Qt's QDomDocument class can be used to automatically read .ts files by parsing <message>Element, extract the string to be translated and the corresponding context information and save them into a QMap container to be translated. The context information is the file name of the string to be translated read from the .ts file and stored in the QMap to be translated. The file name can be used as the identification index of the string to be translated. The corresponding string to be translated can be found through the file name. The string to be translated and its file name can be imported into a structured Excel table later. In this embodiment, reading the string to be translated and its file name from the translation file is completed automatically, which reduces the complexity and error rate of manual operation and avoids the problem of missing or repeating strings in the translation process to a large extent.

[0033] S103, exporting the character string to be translated and the context information corresponding to the character string to be translated to generate an Excel table; As an optional implementation of an exemplary embodiment of the present application, the character string to be translated and the context information corresponding to the character string to be translated are exported to generate an Excel table, including: using a third-party library to connect Excel controls, and reading the character string to be translated and the context information corresponding to the character string to be translated into the Excel table.

[0034] In a specific example, still taking .ts file as an example, a third-party library such as Qt's QAxObject class is used to connect Excel controls, and the string to be translated is read into an Excel table. Each row of the Excel table is sequentially written with the string to be translated and the corresponding context information read from the .ts file. The columns of the Excel table specifically include: source string (i.e., string to be translated), context information (file name corresponding to the string to be translated), etc. In addition, the translation text (translated string) and notes of the target language can also be included. The notes can be, for example, English auxiliary translation information columns. When facing foreign customers, foreign customers can revise the translation text of the target language according to the English auxiliary translation information to ensure the accuracy of the translation. Of course, according to the actual situation, other columns can be specifically added, and the present invention does not limit this. As an example, reference can be made to Table 1 below. In this embodiment, by adding context information and notes and other columns in the generated Excel table, the meaning of the string can be better understood by the translator to ensure that the translation result meets the actual needs.

[0035] In this embodiment, the above process (steps S101-S103) is completed automatically, reducing the complexity and error rate of manual operations, and largely avoiding the problem of missing or duplicating strings in the translation process. In addition, developers no longer need to spend a lot of time on file management and format conversion, reducing development costs. After each code update, developers no longer need to re-extract the strings to be translated and manually update the translation files, greatly improving work efficiency.

[0036] S104, translating the character strings to be translated in the Excel table line by line to obtain translated character strings, and importing the translated character strings line by line into the Excel table to obtain an updated Excel table; Specifically, when translating the string to be translated in the Excel table line by line, as an optional implementation method, it can be translated by the translator himself, and the translator can directly edit the Excel table without understanding the format of the .ts file, which reduces the learning cost. At the same time, the translator ensures that the translation is accurate or conforms to the actual usage scenario by understanding the contextual information. As another optional implementation method, the string to be translated in the Excel table can also be automatically copied to the translation software for translation, and then filled back into the Excel table. Of course, after the translation software completes the translation, the translator can also proofread the translated string in the Excel table again to ensure the accuracy of the translation.

[0037] Here, we only take the automatic translation using Google translation software as an example for illustration.

[0038] As an optional implementation of an exemplary embodiment of the present application, the string to be translated in the Excel table is translated line by line to obtain the translated string, and the translated string is imported into the table line by line, including: copying the string to be translated into the csv table line by line; using the document translation function of the translation software (such as Google Translate) to translate each line of the string to be translated in the csv table, and after the translation is completed, importing the translated string into the Excel table line by line to obtain an updated Excel table. In the specific implementation, since the Google translation software cannot directly translate the Excel table, it can be used directly for the csv table. Therefore, in this embodiment, the string to be translated in the Excel table is automatically copied line by line to the csv table, and then the csv table is translated line by line using the Google translation software. Finally, the translated string is copied line by line to the corresponding position of the Excel table to obtain an updated Excel table. Thus, the line-by-line translation of the string to be translated in the Excel table is completed. Here, only the use of Google translation software for automatic translation is used as an example for exemplary description. Of course, other translation software such as Youdao Translation can also be used, and the present invention does not limit this. The above implementation provided by the present invention overcomes the problem that Excel tables cannot be translated by Google translation software. At the same time, this process is also automated, reducing the complexity and error rate of manual operations, and largely avoiding the problem of missing or duplicating strings in the translation process. Moreover, developers no longer need to spend a lot of time on file management and format conversion, reducing development costs. After each code update, developers no longer need to re-extract the strings to be translated and manually update the translation files, greatly improving work efficiency.

[0039] As shown in Table 1 below, in the updated Excel table, the first column is the context information (i.e., the file name of the string to be translated), the second column is the string to be translated, the string in the column is the source text in Chinese, corresponding to the context information one by one, the third and fourth columns are the translated strings (the translated text in the target language), the strings in the corresponding columns are in Russian, the third column is the abbreviated Russian, the fourth column is the detailed Russian, the fifth to seventh columns are the English auxiliary translation information items, the strings in the corresponding columns are in English, specifically the number of English abbreviation characters, the abbreviated English, and the detailed English, the English auxiliary translation information in the last three columns can solve the problem that foreign users cannot revise the translated Russian when translating Chinese into Russian because they do not know Chinese. The translated strings in the Excel table can be revised through the English auxiliary translation information items to ensure the accuracy of the translation and conform to the language habits of various countries.

[0040]

[0041] Table 1 S105, reading the updated Excel spreadsheet, importing the translated character string and updating the translation file.

[0042] As an optional implementation of an exemplary embodiment of the present application, the updated Excel spreadsheet is read, the translated strings are imported and the translation file is updated, including: using QAxObject and QDomDocument classes to read the translated strings in the updated Excel spreadsheet into the translation file, and replacing the corresponding strings to be translated according to the context information.

[0043] In a specific example, taking the .ts file as an example, first use Qt's QAxObject class to read the updated Excel table, save the file name of the string to be translated, the string to be translated, and the translated string row by row into a translated QMap container, and then use Qt's QDomDocument class to read the .ts file. In the .ts file, find the corresponding string to be translated according to the file name of the string to be translated, and replace the string to be translated with the translated string, thereby completing the translation of the string in the .ts file.

[0044] As an optional implementation in this embodiment, after completing the translation of the string in the .ts file, the method provided in this embodiment also includes: using Qt's QProcess class to generate a target translation file qm file to complete the translation of the string in the project code.

[0045] In this embodiment, after completing the translation of the string in the .ts file, in order to avoid missing or repeating the translation, an automated checking function is also provided. As an optional implementation of an exemplary embodiment of the present application, after reading the updated Excel table, importing the translated string and updating the translation file, the method provided in this embodiment also includes: in the updated translation file, matching the translated string according to the string to be translated and the context information corresponding to the string to be translated, if the match is successful, replacing the string at the corresponding position in the updated translation file with the translated string.

[0046] In a specific example, taking a .ts file as an example, in the updated translation file, the translated string is matched according to the string to be translated and the context information corresponding to the string to be translated. Specifically, each string to be translated and the file name in the updated .ts file are read according to a specific tag name, and then compared with the string to be translated and the file name in the QMap container to be translated (i.e., read from the .ts file before translation) in step S102. If the string to be translated and the file name in the same match, the match is successful. At this time, the string under the tag in the updated .ts file is replaced with the translated string stored in the translated QMap container. Of course, the translated string corresponds to the string to be translated and the file name in the same one-to-one. Therefore, each time the updated Excel table is imported into the translation file, the system will automatically check that the translated string can be correctly matched to the corresponding position in the .ts file to ensure that there is no omission or duplication of translation, and to ensure the integrity and accuracy of the translation file.

[0047] In addition, in order to facilitate the use of developers and translators, this embodiment also provides a graphical user interface (GUI) to facilitate them to select the .ts file or xml file to be processed, export or import Excel tables, etc. As an optional implementation of an exemplary embodiment of the present application, the method provided in this embodiment also includes: using Qt's QWidget and QDialog classes to implement a graphical user interface, providing function buttons, specifically including: file selection, export and import Excel and batch processing, etc., wherein the file selection function allows the user to select the translation file to be processed; the export and import Excel function allows the user to export the string to be translated and the file name where it is located as an Excel table or re-import the translated Excel table into the .ts file; the batch processing function allows the user to select multiple translation files and supports exporting or importing multiple translation files at one time. In step S101 above, it is mentioned that the translation file can include one or more. As an optional implementation, by providing a file browser in the interface, the user is allowed to select multiple translation files, and the translation process of each translation file can be executed in the manner of steps S102 to S105, thereby supporting the export or import of multiple translation files at one time, realizing batch translation processing, and improving translation efficiency. In addition, by selecting multiple translation files, it can also support complex projects in multiple languages, ensuring that translation files in all languages ​​can be updated synchronously, simplifying the development and maintenance of multi-language projects and achieving batch processing. By providing a graphical user interface (GUI), the translation operation process is simplified and the efficiency of translation work is improved.

[0048] The following is an application description of the language translation method provided in this embodiment using two specific application examples. Figure 2 The language translation method shown is suitable for translating strings in the project code (.ts files). Figure 3 The language translation method shown is suitable for translating a character string in a translation read file (xml file).

[0049] Figure 2 FIG. 1 is a flowchart of a language translation method according to an exemplary embodiment of the present application, which can be used to translate strings in project codes. Figure 2 As shown, the language translation method mainly includes the following steps: S201. Click Tools->External->Linguist->Update Translation in the toolbar of QtCreator, and you can see the generated .ts file in the directory where the project code is located; S202, using Qt's QDomDocument class to read the string to be translated in the .ts file into a QMap container, and then using the QAxObject class to connect the Excel control to read the string to be translated into the Excel table; S203, copy the string to be translated into a csv table; S204, using the document translation function of Google Translate, and after the translation is completed, copying the translated string back into the Excel table; S205. Use QAxObject and QDomDocument classes to read the translated strings in the xlsx table into the .ts file, and use QProcess class to generate a qm file to complete the translation of the strings in the project code.

[0050] Figure 3 FIG. 1 is a flow chart of a language translation method according to an exemplary embodiment of the present application, which can be used to translate character strings in a read file. Figure 3 As shown, the language translation method mainly includes the following steps: S301, using Qt's QDomDocument class to read the string to be translated in the .xml file into a QMap container; S302, use the QAxObject class to connect to the Excel control and read the string to be translated into the Excel table; S303, copy the string to be translated into a csv table; S304, using the document translation function of Google Translate, after the translation is completed, copy the translated string back to the Excel table; S305. Use QAxObject and QDomDocument classes to read the translated strings in the xlsx table into the .xml file, and complete the translation of the strings in the read file.

[0051] The language translation method provided by this embodiment automatically reads the string to be translated in the translation file and exports it to an Excel table. The translation of the string to be translated is completed in the Excel table, and the translated string is re-imported into the translation file. The whole process can be completed automatically, which improves the efficiency of translation work while ensuring the correctness and consistency of the translation results, reduces the errors caused by manual operation, and largely avoids the problem of missing or duplicating strings in the translation process. In addition, developers no longer need to spend a lot of time on file management and format conversion, which reduces development costs and simplifies the management and translation process of translation files. Moreover, translators can directly edit Excel tables to further ensure the accuracy of the translation, and translators do not need to understand the format of .ts files or xml files, which reduces the cost of learning.

[0052] Figure 4 The structure block diagram of a language translation device provided by an exemplary embodiment of the present application is shown. The language translation device is applied to the above Figures 1 to 3 The language translation method provided by any exemplary embodiment may be implemented in the form of hardware and / or software, and the language translation device may be configured in a computer device such as a mobile phone, a computer or a server. The following is only a brief description of the structure and function of the language translation device. For other matters not covered, please refer to the relevant description of the language translation method mentioned above. Figure 4 As shown, the language translation device 10 comprises: An acquisition module 100 is used to acquire a translation file, where the translation file includes a .ts file or an xml file; The parsing module 200 is used to read the character string to be translated and the context information corresponding to the character string to be translated in the translation file; The Excel table generation module 300 is used to export the character string to be translated and the context information corresponding to the character string to be translated to generate an Excel table; The translation processing module 400 is used to translate the character strings to be translated in the Excel table line by line to obtain translated character strings, and import the translated character strings line by line into corresponding positions in the Excel table according to context information corresponding to the character strings to be translated, so as to obtain an updated Excel table; The import and update module 500 is used to read the updated Excel table, import the translated character strings and update the translation file.

[0053] As an optional implementation of an exemplary embodiment of the present application, the translation file includes one or more. Thus, multiple translation files can be imported in batches at one time, and multiple target translation files can be exported, so as to realize batch translation processing and improve translation efficiency.

[0054] As an optional implementation of an exemplary embodiment of the present application, the parsing module 200 reads the string to be translated and the context information corresponding to the string to be translated in the translation file in the following manner: using the QDomDocument class of Qt to parse the translation file, and reading the string to be translated and the context information corresponding to the string to be translated in the translation file; In a specific example, taking a .ts file as an example, the parsing module 200 can use Qt's QDomDocument class to automatically read the .ts file, and parse the <message>Element, extract the string to be translated and the corresponding context information and save them into a QMap container to be translated. The context information is the file name of the string to be translated read from the .ts file and stored in the QMap to be translated. The file name can be used as the identification index of the string to be translated. The corresponding string to be translated can be found through the file name. The string to be translated and its file name can be imported into a structured Excel table later. In this embodiment, reading the string to be translated and its file name from the translation file is completed automatically, which reduces the complexity and error rate of manual operation and avoids the problem of missing or repeating strings in the translation process to a large extent.

[0055] As an optional implementation of an exemplary embodiment of the present application, the Excel table generation module 300 generates an Excel table by exporting the character string to be translated and the context information corresponding to the character string to be translated in the following manner: using a third-party library to connect the Excel control, and reading the character string to be translated and the context information corresponding to the character string to be translated into the Excel table; In a specific example, still taking .ts file as an example, the Excel table generation module 300 can use a third-party library such as Qt's QAxObject class to connect Excel controls and read the string to be translated into the Excel table. Each row of the Excel table is sequentially written into the string to be translated and the corresponding context information read from the .ts file. The columns of the Excel table specifically include: source string (i.e., string to be translated), context information (file name corresponding to the string to be translated) and other items. In addition, the translation text (translated string) and remarks of the target language can also be included. The remarks can be, for example, English auxiliary translation information columns. When facing foreign customers, foreign customers can revise the translation text of the target language according to the English auxiliary translation information to ensure the accuracy of the translation. Of course, according to the actual situation, other columns can also be specifically added, and the present invention does not limit this. In this embodiment, by adding context information and remarks and other columns in the generated Excel table, the translator can be helped to better understand the meaning of the string to ensure that the translation result meets the actual needs.

[0056] In this embodiment, the parsing module 200 and the Excel table generation module 300 automatically read the string to be translated from the translation file and export and generate an Excel table. This process is completed automatically, reducing the complexity and error rate of manual operations, and largely avoiding the problem of missing or duplicating strings in the translation process. Moreover, developers no longer need to spend a lot of time on file management and format conversion, reducing development costs. After each code update, developers no longer need to re-extract the string to be translated and manually update the translation file, greatly improving work efficiency.

[0057] In the present embodiment, when the translation processing module 400 translates the string to be translated in the Excel table line by line, as an optional implementation method, it can be translated by the translator himself, and the translator can directly edit the Excel table, and the translation processing module 400 receives the translated string input by the translator to update the Excel table, so that the translator does not need to understand the format of the .ts file, which reduces the learning cost. At the same time, the translator ensures that the translation is accurate or meets the actual use scenario by understanding the context information. As another optional implementation method, the translation processing module 400 can also automatically copy the string to be translated in the Excel table to the translation software for translation, and then fill it back into the Excel table. Of course, after the translation software completes the translation, the translator can also proofread the translated string in the Excel table again to ensure the accuracy of the translation. The specific updated Excel table can be seen in Table 1 above, which will not be repeated this time.

[0058] As an optional implementation of an exemplary embodiment of the present application, the translation processing module 400 translates the string to be translated in the Excel table line by line to obtain the translated string, and imports the translated string line by line into the corresponding position of the Excel table according to the context information corresponding to the string to be translated, to obtain an updated Excel table: copy the string to be translated in the Excel table line by line into the csv table; use the document translation function of the translation software to translate the string to be translated in the csv table line by line to obtain the translated string; import the translated string into the Excel table to obtain the updated Excel table. Here, only the automatic translation using Google translation software is used as an example for exemplary description. Of course, other translation software such as Youdao translation can also be used, and the present invention does not limit this. The above implementation method provided by the present invention overcomes the problem that the Excel table cannot be translated by Google translation software. At the same time, this process is also automated, reducing the complexity and error rate of manual operation, and largely avoiding the problem of missing or duplicating strings in the translation process. Moreover, developers no longer need to spend a lot of time on file management and format conversion, reducing development costs. After each code update, developers no longer need to re-extract the strings to be translated and manually update the translation files, which greatly improves work efficiency.

[0059] As an optional implementation of an exemplary embodiment of the present application, the import update module 500 reads the updated Excel spreadsheet, imports the translated strings and updates the translation file in the following manner: uses Qt's QAxObject and QDomDocument classes to read the translated strings in the updated Excel spreadsheet into the translation file, and replaces the corresponding strings to be translated according to the context information.

[0060] In a specific example, taking the .ts file as an example, first use Qt's QAxObject class to read the updated Excel table, save the file name of the string to be translated, the string to be translated, and the translated string row by row into a translated QMap container, and then use Qt's QDomDocument class to read the .ts file. In the .ts file, find the corresponding string to be translated according to the file name of the string to be translated, and replace the string to be translated with the translated string, thereby completing the translation of the string in the .ts file.

[0061] As an optional implementation in this embodiment, the import update module 500 is also used to use Qt's QProcess class to generate a target translation file qm file after completing the translation of the strings in the .ts file, so as to complete the translation of the strings in the project code.

[0062] In this embodiment, after the import update module 500 completes the translation of the string in the .ts file, in order to avoid missing or repeating the translation, an automated checking function is also provided. As an optional implementation of an exemplary embodiment of the present application, the import update module 500 is also used to match the translated string in the updated translation file according to the string to be translated and the context information corresponding to the string to be translated, and if the match is successful, the string in the corresponding position in the updated translation file is replaced with the translated string.

[0063] In a specific example, taking a .ts file as an example, the import update module 500 matches the translated string in the updated translation file according to the string to be translated and the context information corresponding to the string to be translated. Specifically, the following steps are performed: traverse and read each string to be translated and its file name in the updated .ts file according to a specific tag name, and then compare it with the string to be translated and its file name stored in the QMap container to be translated in step S102 (i.e., read from the .ts file before translation). If the string to be translated and its file name match, the match is successful. At this time, the string under the tag in the updated .ts file is replaced with the translated string stored in the translated QMap container. Of course, the translated string corresponds to the string to be translated and its file name one by one. Therefore, each time the updated Excel table is imported into the translation file, the system will automatically check that the translated string can be correctly matched to the corresponding position in the .ts file to ensure that there is no omission or duplication of translation, and to ensure the integrity and accuracy of the translation file.

[0064] In addition, in order to facilitate user use, the language translation device provided in this embodiment also provides a functional module of a graphical user interface (GUI) (not shown in the figure), and the functional module of the graphical user interface (GUI) includes: The file selection module allows users to select the translation file to be processed and displays the selectable translation files to users through the file browser; Export and import modules provide buttons and menu options, allowing users to export the strings to be translated and their file names as Excel tables or re-import the translated Excel tables into .ts files; Batch processing module, which allows users to select multiple translation files by providing a file browser in the interface, and supports exporting or importing multiple translation files at one time. This function is particularly suitable for complex projects that support multiple languages, and significantly improves the development and maintenance efficiency of multi-language projects; By providing a graphical user interface (GUI), the translation operation process is simplified and the efficiency of translation work is improved.

[0065] The language translation device provided by the present embodiment automatically reads the string to be translated in the translation file and exports it to an Excel table. The translation of the string to be translated is completed in the Excel table, and the translated string is re-imported into the translation file. The whole process can be completed automatically, which improves the translation efficiency while ensuring the correctness and consistency of the translation results, reduces the errors caused by manual operation, and largely avoids the problem of missing or duplicating strings in the translation process. In addition, developers no longer need to spend a lot of time on file management and format conversion, reducing development costs. Moreover, translators can directly edit Excel tables to further ensure the accuracy of the translation, and translators do not need to understand the format of .ts files or xml files, reducing learning costs.

[0066] Figure 5 The following is a block diagram of a computer device 1000 according to an exemplary embodiment of the present application. The computer device 1000 may be implemented as the above-mentioned language translation device 10, which may be configured in a computer device such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart watch, a TV, or a server. The computer device 1000 may also be referred to as a user device, a portable terminal, a laptop terminal, a desktop terminal, or other names.

[0067] Typically, the computer device 1000 includes a processor 1001 and a memory 1002 .

[0068] The processor 1001 may include one or more processing cores, such as a 4-core processor, a 10-core processor, etc. The processor 1001 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1001 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1001 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1001 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0069] The memory 1002 may include one or more computer-readable storage media, which may be non-transitory. The memory 1002 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1002 is used to store at least one instruction, which is used to be executed by the processor 1001 to implement all or part of the steps in the language translation method shown in the method embodiment of the present application.

[0070] Those skilled in the art will understand that Figure 5 The structure shown in the figure does not constitute a limitation on the computer device 1000, and the computer device 1000 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.

[0071] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one computer program is stored, and the computer program is loaded and executed by a processor to implement all or part of the steps in the above-mentioned language translation method. For example, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.

[0072] In an exemplary embodiment, a computer program product is also provided, the computer program product comprising at least one computer program, the computer program being loaded and executed by a processor Figures 1 to 3 All or part of the steps of the language translation method shown in any embodiment.

[0073] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the claims.

[0074] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.< / message> < / message>

Claims

1. A language translation method, characterized in that: include: Obtain a translation file, wherein the translation file includes a .ts file or an xml file; Reading the character string to be translated and the context information corresponding to the character string to be translated in the translation file; Exporting the character string to be translated and context information corresponding to the character string to be translated to generate an Excel table; Translating the character strings to be translated in the Excel table row by row to obtain translated character strings, and importing the translated character strings row by row into corresponding positions in the Excel table according to context information corresponding to the character strings to be translated, to obtain an updated Excel table; The updated Excel spreadsheet is read, and the translated character string is imported into and updated into the translation file.

2. The method according to claim 1, characterized in that The translation files include one or more.

3. The method according to claim 1 or 2, characterized in that: The reading of the character string to be translated in the translation file and the context information corresponding to the character string to be translated comprises: parsing the translation file using the QDomDocument class of Qt, and reading the character string to be translated in the translation file and the context information corresponding to the character string to be translated; The step of exporting the character string to be translated and the context information corresponding to the character string to be translated to generate an Excel table includes: using a third-party library to connect an Excel control, and reading the character string to be translated and the context information corresponding to the character string to be translated into the Excel table; The reading of the updated Excel table, importing the translated strings into and updating the translation file comprises: using Qt's QAxObject and QDomDocument classes to read the translated strings in the updated Excel table into the translation file, and replacing the corresponding strings to be translated according to the context information.

4. The method according to claim 1 or 2, characterized in that: The method of translating the character strings to be translated in the Excel table row by row to obtain translated character strings, and importing the translated character strings row by row into corresponding positions of the Excel table according to context information corresponding to the character strings to be translated, to obtain an updated Excel table, includes: Copy the strings to be translated in the Excel table into the csv table row by row; Using the document translation function of the translation software, the character strings to be translated in the csv table are translated line by line to obtain the translated character strings; The translated character string is imported into the position corresponding to the context information corresponding to the character string to be translated in the Excel table to obtain the updated Excel table.

5. The method according to claim 1, characterized in that After reading the updated Excel table, importing the translated character string and updating the translation file, the method further includes: In the updated translation file, the translated string is matched according to the string to be translated and the context information corresponding to the string to be translated. If the match is successful, the string at the corresponding position in the updated translation file is replaced with the translated string.

6. A language translation device, characterized in that: include: An acquisition module, used to acquire a translation file, wherein the translation file includes a .ts file or an xml file; A parsing module, used for reading the character string to be translated in the translation file and the context information corresponding to the character string to be translated; An Excel table generating module, used for exporting the character string to be translated and the context information corresponding to the character string to be translated into an Excel table; A translation processing module, used for translating the character strings to be translated in the Excel table line by line to obtain translated character strings, and importing the translated character strings line by line into corresponding positions in the Excel table according to context information corresponding to the character strings to be translated, to obtain an updated Excel table; The import and update module is used to read the updated Excel table, import the translated character string and update the translation file.

7. The device according to claim 6, characterized in that The parsing module reads the character string to be translated and the context information corresponding to the character string to be translated in the translation file in the following manner: using QDomDocument class of Qt to parse the translation file, and reading the character string to be translated and the context information corresponding to the character string to be translated in the translation file; The Excel table generation module exports the character string to be translated and the context information corresponding to the character string to be translated to generate an Excel table in the following manner: using a third-party library to connect Excel controls, and reading the character string to be translated and the context information corresponding to the character string to be translated into the Excel table; The import update module reads the updated Excel table, imports the translated strings and updates the translation file in the following manner: uses Qt's QAxObject and QDomDocument classes to read the translated strings in the updated Excel table into the translation file, and replaces the corresponding strings to be translated according to the context information.

8. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the language translation method according to any one of claims 1 to 5 are implemented.

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

10. A computer program product, comprising a computer program stored on a non-transitory computer-readable storage medium, wherein the computer program comprises program instructions, and when the program instructions are executed by a computer, the computer is caused to perform the steps of the language translation method according to any one of claims 1 to 5.