Automated translation of resource files

CN122528918APending Publication Date: 2026-08-07CRSC URBAN RAIL TRANSIT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CRSC URBAN RAIL TRANSIT TECH CO LTD
Filing Date
2026-03-23
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

[0005]本发明提供一种翻译资源文件自动化翻译方法以及装置,用以解决现有技术中翻译资源文件的翻译方法效率不高的缺陷,实现提升文件翻译的效率和可靠性

Benefits of technology

[0014]本发明还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如上述任一种所述翻译资源文件自动化翻译方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122528918A_ABST
    Figure CN122528918A_ABST
Patent Text Reader

Abstract

The application provides a kind of automatic translation method and device of translation resource file, applied in computer software technical field, the above-mentioned method includes: obtaining the translation resource file to be translated, wherein the translation resource file is the XML format file for storing translation entry of Qt framework;Translation resource file is parsed, and all unfinished translation entries in translation resource file are obtained, and untranslated entry set is obtained;According to the target language specified by user, each entry in untranslated entry set is executed translation processing, and translation result is obtained;Based on translation result, the translation content of corresponding entry in translation resource file is updated, and the translation completed translation resource file is obtained.By the present application, the efficiency and reliability of file translation can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer software technology, and in particular to a method and apparatus for automated translation of translation resource files. Background Technology

[0002] In software development, especially in the development of cross-platform applications based on the Qt framework, internationalization and localization are crucial aspects. The Qt framework typically uses specific XML format files (such as .ts files) to store and manage text entries in the source code that need to be translated.

[0003] Traditional translation processes rely on manual labor or basic translation tools, meaning developers or translators need to manually open these resource files and search for untranslated original text one by one. <source> (Tag content), and in the corresponding <translation>The process of filling in the target language translation within the label is tedious and highly repetitive.

[0004] This demonstrates that the translation methods for resource files in related technologies suffer from inefficiency. Summary of the Invention

[0005] This invention provides an automated translation method and apparatus for translating resource files, which addresses the shortcomings of existing methods for translating resource files due to low efficiency, thereby improving the efficiency and reliability of file translation.

[0006] This invention provides an automated translation method for translation resource files, comprising the following steps: Obtaining a translation resource file to be translated, wherein the translation resource file is an XML format file used by the Qt framework to store translation entries; parsing the translation resource file to obtain all untranslated entries, resulting in a set of untranslated entries; performing translation processing on each entry in the set of untranslated entries according to a user-specified target language to obtain a translation result; updating the translation content of the corresponding entries in the translation resource file based on the translation result to obtain a translated resource file that has been fully translated.

[0007] According to the present invention, an automated translation method for translation resource files is provided. The method involves performing translation processing on each entry in a set of untranslated entries based on a user-specified target language to obtain a translation result. The method includes: generating a query key for each entry in the set of untranslated entries based on the source text and the target language; performing a query in a pre-established translation cache based on the query key, wherein the translation cache is used to store historical translation results categorized by source language-target language pair; if the query is successful, retrieving the historical translation result corresponding to the query key from the translation cache as the translation result of the entry; if the query is unsuccessful, calling an external translation interface to retrieve the translation result of the entry, and storing the correspondence between the translation result of the entry and the query key in the translation cache.

[0008] According to the present invention, an automated translation method for translation resource files includes the following steps: calling an external translation interface to obtain the translation results of the entries; combining one or more entries that were not found in the query into a batch translation request, wherein the batch translation request includes the source text of each entry and the target language; sending the batch translation request to the external translation interface; if an error response is received from the external translation interface or a response is not received within a preset timeout period, resending the batch translation request according to a preset retry strategy and a maximum number of retries; and if the batch translation result corresponding to the batch translation request is received from the external translation interface, extracting the translation results corresponding to each entry in the batch translation result.

[0009] According to the present invention, an automated translation method for translation resource files includes parsing the translation resource file to obtain all incomplete translation entries and a set of incomplete translation entries. The method comprises: parsing the XML structure of the translation resource file and identifying all message elements in the file; for each identified message element, determining whether the message element is an incomplete translation entry: detecting whether the message element contains an attribute indicating incomplete translation; extracting the source text of the message element and detecting whether the source text contains characters of a preset source language; if the message element contains the attribute indicating incomplete translation and / or the source text of the message element contains characters of the preset source language, then the message element is determined to be an incomplete translation entry; and constructing a set of incomplete translation entries based on all incomplete translation entries.

[0010] According to the present invention, an automated translation method for translation resource files is provided. When performing translation processing on each item in the set of untranslated items according to the target language specified by the user to obtain a translation result, the method further includes: during the translation processing, saving the item status of the translated item and the corresponding translation result to a translation progress file; when the translation processing is interrupted, reading the translation progress file to determine the item status before the interruption; based on the item status, continuing the translation processing from the interruption point in the set of untranslated items, and updating the translation progress file.

[0011] According to the present invention, an automated translation method for translation resource files is provided. After obtaining the translation resource file to be translated, the method further includes: receiving at least one translation parameter configured by the user through a graphical user interface, wherein the translation parameter includes the target language and the number of entries to be processed in batches.

[0012] This invention also provides an automated translation device for translation resource files, comprising the following modules: an acquisition module for acquiring a translation resource file to be translated, wherein the translation resource file is an XML format file used by the Qt framework to store translation entries; a parsing module for parsing the translation resource file to obtain all untranslated entries in the translation resource file, thereby obtaining a set of untranslated entries; a translation module for performing translation processing on each entry in the set of untranslated entries according to a target language specified by the user, thereby obtaining a translation result; and an update module for updating the translation content of the corresponding entries in the translation resource file based on the translation result, thereby obtaining a translated resource file that has been translated.

[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the automated translation method for translation resource files as described above.

[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the automated translation method for translation resource files as described above.

[0015] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the automated translation method for translation resource files as described above.

[0016] The automated translation method and apparatus for translation resource files provided by this invention automatically acquires translation resource files in a specific XML format from the Qt framework, providing a correct input source for subsequent processing and avoiding the tediousness and potential errors of manual file manipulation. Secondly, by automatically parsing the file structure and accurately identifying all incomplete translation entries to form a set of untranslated entries, the integrity of the content to be processed is ensured, eliminating omissions that may occur during manual searching. Next, translation processing is automatically performed on each entry in the set according to the target language specified by the user, enabling rapid and batch generation of translation results, significantly improving translation speed and supporting multilingual targets. Finally, based on the translation results, the corresponding entries in the original translation resource file are automatically updated, ensuring that the output file format is fully compatible with the original structure while directly generating the final translated file. This completely liberates manual labor from repetitive tasks, greatly improving the efficiency and reliability of localization work. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced one by one below. Obviously, the accompanying drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a flowchart illustrating the automated translation method for translation resource files provided by the present invention.

[0019] Figure 2 This is a schematic diagram of the incomplete item identification algorithm provided by the present invention.

[0020] Figure 3 This is a schematic diagram of the intelligent batch translation algorithm provided by the present invention.

[0021] Figure 4 This is a flowchart illustrating the overall business process of the automated translation method for translation resource files provided by this invention.

[0022] Figure 5 This is a detailed flowchart of the translation processing provided by the present invention.

[0023] Figure 6 This is a schematic diagram of the interface of the TS file translation tool provided by the present invention.

[0024] Figure 7 This is a schematic diagram showing the result of the TS file translation tool provided by this invention.

[0025] Figure 8 This is an updated schematic diagram of the TS file translation tool provided by the present invention.

[0026] Figure 9 This is a schematic diagram of a module of an automated translation device for translation resource documents provided by the present invention.

[0027] Figure 10 This is a schematic diagram of the physical structure of the electronic device provided by the present invention. Detailed Implementation

[0028] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0029] With the globalization of software, multilingual support has become a basic requirement. The Qt framework, as an important tool for cross-platform application development, uses Qt Linguist to manage translation resources, such as Translation Source (TS) files.

[0030] The main technical problems currently include: traditional methods require manual translation of text in TS files line by line, which is labor-intensive and prone to errors; different translators have varying skill levels, making it difficult to ensure translation consistency; repeated translation of the same content leads to resource waste; the translation completion status cannot be effectively tracked and managed; and there is a lack of a user-friendly configuration interface, making parameter adjustment complex.

[0031] Existing translation tools are mostly general-purpose translation software, which have the following limitations: they cannot be optimized specifically for the TS file structure and Qt framework features; they lack the ability to intelligently identify incomplete translation items; they lack a professional interface design for software developers; and they do not support real-time saving and restoration of translation progress.

[0032] This invention aims to solve the above-mentioned technical problems and provides an automated translation method for translation resource files. Its main objectives include: automatically identifying and batch translating incomplete translation entries in TS files; providing an intuitive graphical interface for parameter configuration and progress monitoring; avoiding duplicate translations and improving resource utilization through an intelligent caching mechanism; supporting real-time saving of translation progress and recovery from abnormal interruptions; and ensuring the consistency and accuracy of translation quality.

[0033] Figure 1 This is a flowchart illustrating the automated translation method for translation resource files provided by the present invention, as shown below. Figure 1 As shown, the method includes the following steps.

[0034] Step 101: Obtain the translation resource file to be translated. The translation resource file is an XML format file used by the Qt framework to store translation entries.

[0035] The translation resource file to be translated is obtained by receiving the file path specified by the user through the file selection interface or command line parameters.

[0036] Translation resource files are TS (Translation Source) files used by the Qt framework to store and manage translation entries. Essentially, they are XML format files that conform to a specific schema definition. The Qt framework (often simply referred to as Qt) is a cross-platform C++ graphical user interface application development framework widely used for developing GUI programs, but it can also be used to develop non-GUI programs (such as console tools and servers).

[0037] Step 102: Parse the translation resource file to obtain all untranslated entries in the translation resource file, thus obtaining a set of untranslated entries.

[0038] The obtained translation resource file is parsed using a translation resource file XML structure parser to extract all message elements from the file. <message>Element). Then, each message element is filtered: the message element's unfinished attribute indicating incomplete translation is checked for truth, while simultaneously identifying the source text ( <source> Check whether the tag content contains characters of the default source language (by checking the Unicode range).

[0039] An entry is considered to need translation only when it meets both the "unfinished attribute" and "the source text contains Chinese characters to be translated". All selected entries together constitute the set of untranslated entries.

[0040] Step 103: Perform translation processing on each entry in the untranslated entry set according to the target language specified by the user, and obtain the translation result.

[0041] Read the target language (e.g., en-US, fr-FR) configured by the user in the graphical interface or command line. For each entry in the untranslated entry set, store historical translation results categorized by "source language - target language" and use an intelligent cache key-value generation algorithm for matching. If the cache is hit, the cached translation result is returned directly. If the cache is not hit, the entry is added to the translation queue.

[0042] The MyMemory translation API interface is used to batch translate requests to the queue at configurable batch sizes (e.g., 10 entries per batch). Intelligent request frequency control and error retry mechanisms (e.g., exponential backoff) are implemented during the process to ensure translation efficiency and success rate. Finally, the translation results of all entries (whether from the cache or new translations) are aggregated and output.

[0043] Step 104: Update the translation content of the corresponding entries in the translation resource file based on the translation results to obtain the translated resource file.

[0044] Based on the obtained translation results, locate the corresponding entry in the original translation resource file and... <translation>The tag content is updated to the obtained translated text, and the `unfinished` attribute of the entry is removed or marked as complete. This update process is atomic, ensuring the integrity of file operations. After all entries have been updated, a new translation resource file containing all translated content will be generated, i.e., the translated resource file, which can be used directly by the Qt framework or compiled into a runtime translation file in .qm format.

[0045] Through this invention, by automatically acquiring specific XML format translation resource files for the Qt framework, a correct input source is provided for subsequent processing, avoiding the tediousness and potential errors of manual file manipulation. Secondly, by automatically parsing the file structure and accurately identifying all incomplete translations to form a set of untranslated entries, the integrity of the content to be processed is ensured, eliminating omissions that may occur during manual searching. Next, translation processing is automatically performed on each entry in the set according to the user-specified target language, enabling rapid and batch generation of translation results, significantly improving translation speed and supporting multilingual targets. Finally, based on the translation results, the corresponding entries in the original translation resource file are automatically updated, ensuring that the output file format is fully compatible with the original structure while directly generating the final translated file. This completely liberates manual labor from repetitive tasks, greatly improving the efficiency and reliability of localization work.

[0046] According to the present invention, an automated translation method for translation resource files is provided, which parses the translation resource files to obtain all untranslated entries in the translation resource files, resulting in a set of untranslated entries, including: Parse the XML structure of the translation resource file and identify all message elements in the translation resource file; For each identified message element, determine whether the message element is an entry that has not been translated: Check if the message element contains an attribute indicating that the translation is incomplete; Extract the source text of the message element and detect whether the source text contains characters of the preset source language; If a message element contains an attribute indicating that the translation is incomplete and / or the source text of the message element contains characters of the default source language, then the message element is determined to be an entry for incomplete translation. Based on all entries that have not been translated, construct a set of untranslated entries.

[0047] In this embodiment of the invention, a translation resource file XML structure parser is used to parse the obtained Qt framework translation resource file (i.e., a translation resource file in a specific XML format), identify and extract all message elements (i.e., ...) in the file. <message>(Elements). Subsequently, for each identified message element, an intelligent judgment is performed on incomplete translation entries.

[0048] This judgment process is based on two conditions: first, detecting whether the message element contains an attribute that explicitly indicates the translation is incomplete, specifically checking whether its `unfinished` attribute exists or whether its value is true; second, extracting the source text of the message element (i.e., <source> The text is analyzed to determine if it contains characters of a preset source language (such as Chinese). This detection is achieved by analyzing the Unicode encoding range of the text.

[0049] In practice, if a message element is marked as incomplete (meeting the first condition) and / or its source text contains Chinese characters to be translated (meeting the second condition), then the message element is determined to be an incomplete translation entry. All entries determined to be incomplete translation are collected after iteration, thus constructing a complete set of untranslated entries, providing accurate input for subsequent batch translation processing.

[0050] refer to Figure 2 , Figure 2 This is a schematic diagram of the incomplete item identification algorithm provided by the present invention.

[0051] Through this invention, by parsing the XML structure and combining a dual detection mechanism of incomplete attributes and source language characters, entries to be translated can be accurately identified. This automates the filtering of untranslated content, avoiding the tediousness and omissions of manual, item-by-item checking; the dual verification logic improves the recognition accuracy and prevents misclassification of translated entries; the final untranslated set provides high-quality input for subsequent automated translation, significantly improving the efficiency and reliability of the internationalization process in Qt projects.

[0052] According to the present invention, an automated translation method for translation resource files is provided, which performs translation processing on each entry in a set of untranslated entries based on a user-specified target language to obtain a translation result, including: For each entry in the set of untranslated entries, generate a query key based on the source text and target language of each entry; The query is performed based on the query key in a pre-established translation cache, which is used to store historical translation results categorized by source language-target language pairs. If the query is successful, the historical translation results corresponding to the query key are retrieved from the translation cache and used as the translation result for the entry. If the query does not find the match, the external translation interface is called to obtain the translation result of the entry, and the correspondence between the translation result of the entry and the query key is stored in the translation cache.

[0053] In this embodiment of the invention, a query key is generated for each entry in the set of untranslated entries. The query key is composed of the source text of the entry (i.e. the original text to be translated) and the target language specified by the user, and is generated by a specific key-value generation algorithm (such as plaintext hash) to ensure its uniqueness.

[0054] The query is performed based on the query key in a pre-built translation cache, which is a persistent storage system organized by "source language - target language" for efficient storage and management of historical translation results.

[0055] If the query is successful, the historical translation results corresponding to the query key are retrieved directly from the translation cache and immediately returned as the translation result of the current entry. This process avoids the resource consumption of repeatedly calling external interfaces.

[0056] If the query fails to find the result, an external translation interface (such as the MyMemory translation API) is invoked to retrieve the translation result for that entry. During this process, intelligent request frequency control and error retry mechanisms are implemented to ensure the smooth completion of the translation task. Once a new translation result is obtained, a mapping relationship is established between the translation result and its corresponding query key, and it is stored as a new entry in the translation cache. This enables continuous updating and accumulation of the cache, accelerating subsequent translation requests. Through this cache-first mechanism, the overall efficiency and resource utilization of translation processing are significantly improved.

[0057] refer to Figure 3 , Figure 3 This is a schematic diagram of the intelligent batch translation algorithm provided by the present invention.

[0058] Through the embodiments of this invention, historical translation caching is used to quickly respond to duplicate or similar entries, significantly reducing the number of external API calls and lowering translation costs and network latency. Simultaneously, a source-target language pair classification storage mechanism is established to improve cache hit rate and retrieval efficiency. This mechanism, while ensuring translation consistency, significantly improves the overall execution speed and stability of batch automated translation.

[0059] According to the present invention, an automated translation method for translation resource files is provided, which calls an external translation interface to obtain the translation results of entries, including: Combine one or more entries that did not match the query into a batch translation request. The batch translation request includes the source text and target language of each entry. Send batch translation requests to an external translation interface; If an error response is received from the external translation interface or if a response is not received within the preset timeout period, the batch translation request will be resent according to the preset retry policy and the maximum number of retries. If a batch translation request corresponding to a batch translation result is received from an external translation interface, extract the translation result corresponding to each item in the batch translation result.

[0060] In this embodiment of the invention, all entries that fail to be found in the cache query are combined to form a batch translation request. The batch translation request groups the entries according to a preset or user-configured batch size (e.g., 10 entries per batch). Each batch translation request contains the source text of each entry in the batch and the target language parameters uniformly specified by the user.

[0061] This batch translation request is sent to an external translation interface via the encapsulated MyMemory translation API. During the sending process, the response waiting time is constrained by a preset timeout setting (e.g., 30 seconds, 60 seconds). If an error response is received from the external translation interface during this process (e.g., network error, API limit error), or if no response is received within the preset timeout period, an error retry mechanism will be triggered. This mechanism will automatically resend the batch translation request according to a preset retry strategy (e.g., using an exponential backoff algorithm to gradually increase the retry interval) and a maximum number of retries, thereby enhancing robustness in unstable network environments.

[0062] Upon successfully receiving the batch translation results from the external translation interface, corresponding to the batch translation request, the system precisely parses and extracts the individual translation result for each entry from the structured result. These newly acquired translation results are simultaneously stored in the translation cache for future reuse while being delivered to subsequent processes.

[0063] This invention introduces a timeout detection and automatic retry mechanism to effectively address network fluctuations or temporary service failures, enhancing system robustness. This design ensures reliable translation results even when external interfaces are unstable, preventing single-point failures from disrupting the entire process and significantly improving the success rate and execution efficiency of automated translation tasks.

[0064] According to the present invention, an automated translation method for translation resource files, when performing translation processing on each entry in a set of untranslated entries according to a user-specified target language to obtain a translation result, the method further includes: During the translation process, the status of the translated entries and the corresponding translation results are saved to the translation progress file; When the translation process is interrupted, the translation progress file is read to determine the status of the entries before the interruption. Based on the entry status, the translation process continues from the breakpoint in the set of untranslated entries and the translation progress file is updated.

[0065] During the translation process, the status of each processed entry (including entries that have been translated successfully or have been skipped) and its corresponding translation result are serialized and saved to a separate translation progress file in real time. The entry status includes at least the entry's unique identifier, the processing result (success, failure, or pending), and a timestamp.

[0066] When the translation process is interrupted due to an accident (such as program crash, network interruption, or user-initiated pause), upon restarting or resuming operation, the translation progress file will be read first. By parsing the recorded entry status, the last entry processed before the interruption and the processing status of all entries will be accurately determined, thus pinpointing the exact interruption point.

[0067] Based on the determined entry status, successfully processed entries are removed from the set of untranslated entries, and translation processing of subsequent entries resumes from the point of interruption. During this resumption process, the translation progress file is updated synchronously to reflect the latest processing progress, thereby ensuring that the translation task can be seamlessly resumed from the point of interruption until final completion, achieving the reliability and recoverability of the translation task.

[0068] Through the embodiments of this invention, when the translation process is unexpectedly interrupted due to network failures, system crashes, or other unforeseen circumstances, it is not necessary to start from scratch; execution can be resumed directly from the breakpoint by reading the progress file. This avoids repeatedly translating completed items, significantly saving time and API costs, while ensuring the continuity and data integrity of large-scale translation tasks under abnormal environments, thus improving the system's fault tolerance.

[0069] According to the present invention, an automated translation method for translation resource files, after obtaining the translation resource file to be translated, the method further includes: The system receives at least one translation parameter configured by the user through a graphical user interface. The translation parameters include the target language and the number of entries to be processed in batches.

[0070] In this embodiment of the invention, after the TS file to be translated (i.e., the translation resource file) is successfully loaded, the graphical user interface will activate the parameter configuration area. The key translation parameters that the user needs to configure include at least: the target language and the number of items to be processed in the batch (i.e., the batch size).

[0071] For the target language, users can choose from a predefined list of languages ​​(e.g., including en-US, fr-FR, de-DE, etc.) or enter it directly; intelligent recommendations can be provided based on the analysis of the TS file content.

[0072] For the number of items to be processed in a batch, users can select from preset options (such as 5, 10, 20, 50) based on network conditions or processing efficiency requirements. The system has an adaptive adjustment mechanism for batch size. After all parameters are configured, users submit the settings through confirmation controls on the interface (such as the "Start Translation" button), and the system then starts the subsequent parsing, translation, and update process based on these parameters.

[0073] Refer to Table 1, which is a comparison table of the technical effect indicators provided by the present invention.

[0074] Through the embodiments of the present invention, the graphical interface greatly reduces the threshold for use, requiring no professional technical background; progress and results are visible in real time, enhancing the user's sense of control; parameters can be flexibly adjusted according to specific needs to adapt to different scenarios; and translation can be resumed from the breakpoint, avoiding work loss.

[0075] The following describes an example of the automated translation method for translation resource files provided by this invention in a practical application scenario.

[0076] The first step is environment preparation. This step requires configuring a Python 3.6 or higher runtime environment and automatically installing necessary dependency libraries, including deep-translator for translation and tkinter for building graphical interfaces. Finally, it is also necessary to verify the network connection status and the availability of the external translation APIs.

[0077] The next step is the file preparation stage. This stage requires verifying the integrity of the TS files to be translated to ensure that their format is correct. At the same time, it checks the read and write permissions of the cache file storage path and confirms that the output directory has enough disk space to ensure the smooth progress of subsequent processes.

[0078] Next is the parameter configuration stage, where users set key parameters: the system can intelligently recommend target languages ​​based on the analysis of file content; it can adaptively adjust the batch processing size according to the current network conditions; and it provides advanced parameters for expert users to make more refined configurations.

[0079] Finally, the translation phase begins. The system initiates its core process: using intelligent algorithms to automatically identify all incomplete translation entries in the TS file; then, these entries are processed in batches and concurrently; after translation is completed, the results are saved to the output file in an atomic manner and the translation cache is updated synchronously.

[0080] This invention provides a structured, configurable parameter system, specifically divided into three categories. The first category is translation parameters, including flexibly selectable target languages ​​(e.g., en-US, zh-CN), adjustable batch entry counts (e.g., 5, 10, 20, 50), and network request timeout settings (e.g., 30, 60, 120 seconds). The second category is caching parameters, involving the selection of caching strategies (e.g., memory, file, or database storage) and the configuration of cache cleanup strategies (e.g., LRU, FIFO, or time-based). The third category is interface parameters, allowing users to customize the graphical interface theme (e.g., light, dark, or automatic) and layout mode (e.g., basic, advanced, or expert mode). It supports users in fine-tuning the translation process, resource management, and interactive interface according to actual needs. See the following code for details.

[0081] # System Configurable Parameters Classification CONFIG_CATEGORIES = { 'translation_params': { 'target_languages': ['en-US', 'zh-CN', 'fr-FR', 'de-DE', 'ja-JP'], 'batch_sizes': [5, 10, 20, 50], 'timeout_settings': [30, 60, 120] }, 'cache_params': { 'cache_strategies': ['memory', 'file', 'database'], 'cleanup_policies': ['lru', 'fifo', 'time_based'] }, 'ui_params': { 'theme_options': ['light', 'dark', 'auto'], 'layout_modes': ['basic', 'advanced', 'expert'] } } Through this invention, an intelligent translation recognition mechanism based on the TS file structure accurately locates the content to be translated by combining an automatic identification algorithm for incomplete items with an intelligent detection method for Chinese text. Unified cache management for multilingual pairs employs a cache storage structure categorized by source language-target language pairs, coupled with an intelligent cache key-value generation algorithm, significantly improving translation reuse efficiency. Seamless switching between graphical interface and command-line mode, based on a dual-mode architecture design, implements parameter passing and state synchronization mechanisms, providing users with flexible operation methods. Real-time saving and recovery technology for translation progress, through serialized storage of progress status and an intelligent recovery algorithm for abnormal interruptions, ensures the reliability and recoverability of long-term translation tasks.

[0082] refer to Figure 4 , Figure 4 This is a flowchart illustrating the overall business process of the automated translation method for translation resource files provided by this invention.

[0083] The process begins with file selection and mode selection. Mode selection offers two options: GUI mode and command-line mode, leading to graphical interface configuration and parameter parsing respectively, enabling seamless switching between the two modes. Subsequently, the process converges on the core processing stage, sequentially executing TS file parsing, incomplete item identification, cache checking, batch translation processing, result updating, and progress saving. A loop is formed by checking completion status until all items are processed. Upon completion, the process continues with file saving and cache persistence, finally reaching the end node. In some embodiments, the TS file is first parsed, sequentially extracting all message elements, filtering incomplete entries based on the `unfinished` attribute, detecting Chinese text using Unicode range checks, and finally generating a translation task queue. Then, a cache-first processing phase begins: the system prioritizes checking the cache; if a cached match is found, the TS file is updated directly using the cached result; otherwise, the entry is added to the translation queue. Batch translation processing then proceeds in stages, encompassing API calls and frequency control, an error retry mechanism employing exponential backoff, verification and format adjustment of the returned results, and subsequent cache updates and progress saving. After each batch is completed, a completion check is performed: if there are still incomplete entries, processing continues to the next batch; if all entries are completed, the final file is saved, and the entire process ends.

[0084] refer to Figure 5 , Figure 5 This is a detailed flowchart of the translation processing provided by the present invention.

[0085] The process begins with parsing the TS file, sequentially extracting message elements, filtering incomplete entries, and detecting Chinese text, ultimately generating a translation task queue. Next, a cache-priority processing phase begins, where tasks are routed based on a "cache hit?" (i.e., whether the cache has been hit): if a hit, the cache is used directly and the TS file is updated; if a miss, the task is added to the translation queue. Afterward, batch translation processing and result verification are performed. Upon completion, a "queue complete?" (i.e., whether the queue has been built) check is performed: if not, processing continues; if complete, the process reaches its end.

[0086] In some embodiments, the Chinese Qt software is translated into an English version, as shown below.

[0087] Preparation phase: Collect Chinese TS files (such as en_US.ts).

[0088] Configuration phase: Set the target language to en-US and the batch size to 10.

[0089] Execution phase: Initiate the automated translation process.

[0090] Verification phase: Check the generated English TS file (en_US_translated.ts).

[0091] Integration phase: Test using the translation file (en_US.qm) in the Qt project.

[0092] Through the embodiments of the present invention, the estimated 3 person-days are reduced to 2 hours, professional API guarantees consistency of over 95%, and labor costs are reduced by approximately 85%.

[0093] refer to Figure 6 , Figure 6 This is a schematic diagram of the interface of the TS file translation tool provided by the present invention.

[0094] refer to Figure 7 , Figure 7 This is a schematic diagram showing the result of the TS file translation tool provided by this invention.

[0095] In some embodiments, all language versions are updated synchronously after the software version is updated, as shown below.

[0096] Difference analysis: Identifies newly added or modified translation entries.

[0097] Cache utilization: Quickly translate duplicate content using existing cache.

[0098] Batch update: Synchronously update TS files in all languages.

[0099] Quality Assurance: Ensure consistency in translation across all language versions.

[0100] Through the embodiments of the present invention, the update cycle is shortened from 1 week to 4 hours; versions of each language are updated synchronously to avoid version differences; and cache reuse reduces the number of API calls by 70%.

[0101] refer to Figure 8 , Figure 8 This is an updated schematic diagram of the TS file translation tool provided by the present invention.

[0102] Refer to Table 2, which is a comparison table between the traditional method and the method provided by the present invention.

[0103] This invention is specifically optimized for TS file format, rather than general translation tools; it has the ability to automatically identify incomplete entries; it highly integrates functions such as file parsing, translation, caching, and interface; and it supports plug-in extensions to new translation engines and file formats.

[0104] This invention provides an automated translation method for resource files. Through technological innovations such as intelligent recognition, batch processing, caching optimization, and a user-friendly interface, it effectively solves the translation efficiency and quality issues in the software internationalization process. It is particularly suitable for multilingual support of Qt framework software, possessing significant practical value and broad application prospects.

[0105] The automated translation device for translation resource files provided by the present invention is described below. The automated translation device for translation resource files described below can be referred to in correspondence with the automated translation method for translation resource files described above.

[0106] refer to Figure 9 , Figure 9 This is a schematic diagram of a module of an automated translation device for translation resource documents provided by the present invention.

[0107] The acquisition module 901 is used to acquire the translation resource file to be translated. The translation resource file is an XML format file used by the Qt framework to store translation entries. The parsing module 902 is used to parse the translation resource file to obtain all the untranslated entries in the translation resource file, and obtain the set of untranslated entries; Translation module 903 is used to perform translation processing on each entry in the set of untranslated entries according to the target language specified by the user, and obtain the translation result; The update module 904 is used to update the translation content of the corresponding entries in the translation resource file based on the translation results, so as to obtain the translation resource file with the translation completed.

[0108] Specifically, the automated translation device for translation resource documents provided by the present invention can implement all the method steps implemented in the above-described automated translation method embodiments and achieve the same technical effect. Here, the parts that are the same as those in the method embodiments and the beneficial effects will not be described in detail.

[0109] Figure 10 This is a schematic diagram of the physical structure of the electronic device provided by the present invention, such as... Figure 10 As shown, the electronic device may include a processor 1010, a communications interface 1020, a memory 1030, and a communication bus 1040, wherein the processor 1010, the communications interface 1020, and the memory 1030 communicate with each other via the communication bus 1040. The processor 1010 can call logical instructions in the memory 1030 to execute an automated translation method for translation resource files. This method includes: acquiring a translation resource file to be translated, wherein the translation resource file is an XML format file used by the Qt framework to store translation entries; parsing the translation resource file to obtain all untranslated entries, resulting in a set of untranslated entries; performing translation processing on each entry in the set of untranslated entries according to the target language specified by the user, obtaining a translation result; and updating the translation content of the corresponding entry in the translation resource file based on the translation result, obtaining a translated resource file that has been completed.

[0110] Furthermore, the logical instructions in the aforementioned memory 1030 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0111] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the automated translation method for translation resource files provided by the above methods. The method includes: obtaining a translation resource file to be translated, wherein the translation resource file is an XML format file used by the Qt framework to store translation entries; parsing the translation resource file to obtain all untranslated entries in the translation resource file, thereby obtaining a set of untranslated entries; performing translation processing on each entry in the set of untranslated entries according to the target language specified by the user, thereby obtaining a translation result; and updating the translation content of the corresponding entry in the translation resource file based on the translation result, thereby obtaining a translated resource file that has been translated.

[0112] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements an automated translation method for translation resource files provided by the methods described above. The method includes: acquiring a translation resource file to be translated, wherein the translation resource file is an XML format file used by the Qt framework to store translation entries; parsing the translation resource file to obtain all untranslated entries in the translation resource file, thereby obtaining a set of untranslated entries; performing translation processing on each entry in the set of untranslated entries according to a target language specified by the user, thereby obtaining a translation result; and updating the translation content of the corresponding entry in the translation resource file based on the translation result, thereby obtaining a translated resource file that has been completed.

[0113] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0114] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0115] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.< / message> < / translation> < / message> < / translation>

Claims

1. A method for automated translation of translation resource documents, characterized in that, include: Obtain the translation resource file to be translated, wherein the translation resource file is an XML format file used by the Qt framework to store translation entries; The translation resource file is parsed to obtain all untranslated entries in the translation resource file, resulting in a set of untranslated entries; According to the target language specified by the user, each entry in the set of untranslated entries is translated to obtain the translation result. Based on the translation results, the translation content of the corresponding entries in the translation resource file is updated to obtain the translated resource file.

2. The automated translation method for translation resource documents according to claim 1, characterized in that, The process of performing translation processing on each entry in the set of untranslated entries according to the target language specified by the user, to obtain the translation result, includes: For each entry in the set of untranslated entries, a query key is generated based on the source text of each entry and the target language; The query is performed in a pre-established translation cache based on the query key, wherein the translation cache is used to store historical translation results categorized by source language-target language pair; If the query is successful, the historical translation results corresponding to the query key are retrieved from the translation cache and used as the translation result for the entry. If the query fails to find the target key, an external translation interface is invoked to obtain the translation result of the target key, and the correspondence between the translation result of the target key and the query key is stored in the translation cache.

3. The automated translation method for translation resource documents according to claim 2, characterized in that, The step of calling an external translation interface to obtain the translation result of the entry includes: One or more entries that did not match in the query are combined into a batch translation request, wherein the batch translation request includes: the source text of each entry and the target language; Send the batch translation request to the external translation interface; If an error response is received from the external translation interface or if a response is not received within the preset timeout period, the batch translation request will be resent according to the preset retry policy and the maximum number of retries. If the batch translation result corresponding to the batch translation request returned by the external translation interface is received, the translation result corresponding to each item in the batch translation result is extracted.

4. The automated translation method for translation resource documents according to claim 1, characterized in that, The process of parsing the translation resource file yields all untranslated entries, resulting in a set of untranslated entries, including: Parse the XML structure of the translation resource file and identify all message elements in the translation resource file; For each identified message element, determine whether the message element is an entry that has not been translated: Detect whether the message element contains an attribute indicating that the translation is incomplete; Extract the source text of the message element and detect whether the source text contains characters of a preset source language; If the message element contains the attribute indicating that the translation is incomplete and / or the source text of the message element contains characters of the preset source language, then the message element is determined to be an entry for incomplete translation; Based on all entries that have not been translated, construct a set of untranslated entries.

5. The automated translation method for translation resource documents according to claim 1, characterized in that, When performing translation processing on each entry in the set of untranslated entries according to the target language specified by the user to obtain the translation result, the method further includes: During the translation process, the status of the translated entries and the corresponding translation results are saved to the translation progress file; When the translation process is interrupted, the translation progress file is read to determine the status of the entries before the interruption. Based on the entry status, the translation process continues from the breakpoint in the set of untranslated entries, and the translation progress file is updated.

6. The automated translation method for translation resource documents according to claim 1, characterized in that, After obtaining the translation resource file to be translated, the method further includes: The system receives at least one translation parameter configured by the user through a graphical user interface. The translation parameters include the target language and the number of entries to be processed in batches.

7. An automated translation device for translation resource documents, characterized in that, include: The acquisition module is used to acquire the translation resource file to be translated, wherein the translation resource file is an XML format file used by the Qt framework to store translation entries; The parsing module is used to parse the translation resource file to obtain all the untranslated entries in the translation resource file, thus obtaining a set of untranslated entries; The translation module is used to perform translation processing on each entry in the set of untranslated entries according to the target language specified by the user, and obtain the translation result; The update module is used to update the translation content of the corresponding entries in the translation resource file based on the translation results, so as to obtain the translated resource file with the translation completed.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the automated translation method for translation resource files as described in any one of claims 1 to 6.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the automated translation method for translation resource files as described in any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the automated translation method for translation resource files as described in any one of claims 1 to 6.