File conversion method and device
By detecting and matching file validity, the system achieves efficient conversion of multilingual localization list files, solving the problems of large translation workload and high error rate in existing technologies, and improving the readability of file conversion and translation efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI QINGGAN INTELLIGENT TECH CO LTD
- Filing Date
- 2024-10-30
- Publication Date
- 2026-05-01
AI Technical Summary
The translation of text files containing multilingual localization list files in existing software development tools suffers from poor readability, high workload, and susceptibility to human error, increasing the difficulty of translation and development.
A file conversion method and apparatus are provided, which detects the validity of text files and list files, matches the source text content, and assigns the translated content to the list file or text file, supporting multilingual translation and file format conversion.
It improves the readability and accuracy of file conversion, reduces human error, simplifies the translation and development process, and enhances translation efficiency and file management convenience.
Smart Images

Figure CN121958191A_ABST
Abstract
Description
File conversion method and apparatus Technical Field
[0001] The embodiments disclosed herein relate to the field of computer technology, and more specifically to file conversion methods and apparatus. Background Technology
[0002] During development, it was discovered that the localization list used to display multilingual content in software development tools could only be exported as a text file (e.g., a .po file). This could be opened with an editor and given to translators to translate the text into the native language. However, direct translation of text files resulted in poor readability, and entries did not match functional requirements, necessitating manual correction. If a project had multiple themes and projects, this led to a massive workload for developers and was prone to human error, such as copying errors, omissions, and misalignment. Not only was the initial development workload heavy, but the later review and testing workload was also enormous. This posed significant challenges to both translation and development. Summary of the Invention
[0003] Embodiments of this disclosure present a file conversion method and apparatus.
[0004] In a first aspect, embodiments of this disclosure provide a file conversion method, comprising: in response to receiving a request to convert a text file into a list file, detecting the validity of the text file and the list file; in response to detecting that both the text file and the list file are valid, detecting whether the original text content of the original text column of the list file is empty; in response to detecting that the original text content in the original text column of the list file is not empty, matching the original text content of the original text column of the list file with the original text content of the original text item of the text file; and in response to successful matching, assigning the translated content of the translated item corresponding to the original text content of the original text item of the text file to the blank translated column of the current row where the original text content of the original text column of the list file is located.
[0005] In some embodiments, the method further includes: in response to detecting that the original text content in the original text column of the list file is empty, assigning the original text content of the original text item in the text file and the translation content of the corresponding translation item to the original text column and the translation column of the list file, respectively.
[0006] In some embodiments, the method further includes: in response to the fact that the content in the original text column of the list file is not empty and no original text content matching the original text item of the text file is detected in the original text column of the list file, outputting a file conversion failure prompt message.
[0007] In some embodiments, detecting the validity of the text file and the list file includes: detecting whether a text file is selected; in response to detecting that a text file is not selected, determining that the text file is invalid and outputting a prompt message indicating that the text file is empty; in response to detecting that a text file is selected, detecting whether the selected text file is empty; in response to detecting that the selected text file is empty, determining that the text file is invalid and outputting a prompt message indicating that the text file is empty; in response to detecting that the selected text file is not empty, determining that the text file is valid.
[0008] In some embodiments, detecting the validity of the text file and the list file includes: detecting whether a list file is selected; opening the selected list file in response to detecting that a list file is selected; and determining that the list file is valid in response to successful opening.
[0009] In some embodiments, detecting the validity of the text file and the list file includes: detecting whether a list file is selected; in response to detecting that a list file is not selected, creating a list file and opening the created list file; and in response to successful opening, determining that the list file is valid.
[0010] In some embodiments, matching the original content of the original text column of the list file with the original content of the original text item of the text file includes: traversing the original content of the original text column of the list file and the original content of the original text item of the text file row by row, and if the original content is the same, the match is successful.
[0011] Secondly, embodiments of this disclosure provide a file conversion method, comprising: in response to receiving a request to convert a list file into a text file, detecting the validity of the text file and the list file; in response to detecting that both the text file and the list file are valid, parsing the target language from the filename of the text file and determining the corresponding translation column of the list file; matching the original content of the original column of the list file with the original content of the original item of the text file; and in response to a successful match, assigning the translation content of the translation column of the list file to the translation item of the text file.
[0012] In some embodiments, matching the original content of the original text column of the list file and the original content of the original text item of the text file includes: traversing the original content of the original text column of the list file and the original content of the original text item of the text file row by row, and if the original content is the same, the match is successful.
[0013] In some embodiments, the method further includes: in response to the absence of a translation column corresponding to the translation language in the list file, outputting a conversion failure message.
[0014] In some embodiments, detecting the validity of the text file and the list file includes: detecting whether a list file is selected; in response to detecting that a list file is not selected, determining that the list file is invalid and outputting a prompt message indicating that the list file is empty; in response to detecting that a list file is selected, determining that the list file is valid and detecting whether a text file is selected; in response to detecting that a text file is not selected, determining that the text file is invalid and outputting a prompt message indicating that the text file is empty.
[0015] Thirdly, embodiments of this disclosure provide a file conversion apparatus, comprising: a file detection unit configured to detect the validity of a text file and a list file in response to receiving a request to convert a text file into a list file; a content detection unit configured to detect whether the original content of the original text item in the text file and the original content of the original text column in the list file are empty in response to detecting that both the text file and the list file are valid; a matching unit configured to match the original content of the original text column in the list file and the original content of the original text item in the text file in response to detecting that the original content is not empty; an assignment unit configured to assign the translated content of the translated item in the text file to the translated column of the current row containing the original content of the original text column in the list file in response to successful matching; or, configured to assign the translated content of the translated column in the list file to the translated item in the text file in response to successful matching; and a parsing unit configured to parse the target language from the filename of the text file in response to detecting that both the text file and the list file are valid.
[0016] In some embodiments, the assignment unit is further configured to: in response to detecting that the content in the original text column of the list file is empty, extract the original text content of the original text item of the text file and the translation content of the corresponding translation item and assign them to the original text column and the translation column of the list file respectively.
[0017] In some embodiments, the apparatus further includes a prompting unit configured to: output a file conversion failure prompt message in response to the fact that the content in the original text column of the list file is not empty and no original text content matching the original text item of the text file is detected in the original text column of the list file.
[0018] In some embodiments, the file detection unit is further configured to: detect whether a text file is selected; in response to detecting that a text file is selected, determine that the text file is invalid and output a prompt message indicating that the text file is empty; in response to detecting that a text file is selected, detect whether the selected text file is empty; in response to detecting that the selected text file is empty, determine that the text file is invalid and output a prompt message indicating that the text file is empty; in response to detecting that the selected text file is not empty, determine that the text file is valid.
[0019] In some embodiments, the file detection unit is further configured to: detect whether a list file is selected; open the selected list file in response to detecting that a list file is selected; and determine that the list file is valid in response to successful opening.
[0020] In some embodiments, the file detection unit is further configured to: detect whether a list file is selected; in response to detecting that no list file is selected, create a list file and open the created list file; in response to successful opening, determine that the list file is valid.
[0021] In some embodiments, the matching unit is further configured to: traverse the original text content of the original text column of the list file and the original text content of the original text item of the text file row by row, and if the original text content is consistent, the match is successful.
[0022] In some embodiments, the matching unit is further configured to: traverse the original text content of the original text column of the list file and the original text content of the original text item of the text file row by row, and if the original text content is consistent, the match is successful.
[0023] In some embodiments, the apparatus further includes a prompting unit configured to output a prompt message indicating conversion failure in response to the absence of a translation column corresponding to the translation language in the list file.
[0024] In some embodiments, the file detection unit is further configured to: detect whether a list file is selected; in response to detecting that no list file is selected, determine that the list file is invalid and output a prompt message indicating that the list file is empty; in response to detecting that a list file is selected, determine that the list file is valid and detect whether a text file is selected; in response to detecting that a text file is selected, determine that the text file is invalid and output a prompt message indicating that the text file is empty.
[0025] Fourthly, embodiments of this disclosure provide an electronic device, including: one or more processors; and a storage device having one or more computer programs stored thereon, which, when executed by the one or more processors, cause the one or more processors to perform the method as described in any one of the first or second aspects.
[0026] Fifthly, embodiments of this disclosure provide a computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method as described in any one of the first or second aspects.
[0027] In a sixth aspect, embodiments of this disclosure provide a computer program product including a computer program that, when executed by a processor, implements the method as described in any one of the first or second aspects.
[0028] The file conversion method and apparatus provided in this disclosure convert text files into list files for editing. The converted list files have clearer line and column data, resulting in higher readability. The content of the list files can be paginated, which is beneficial for project summarization and statistics. Converting list files back to text files has a low error rate and avoids issues such as copying errors. Previously, developers manually copied and pasted languages, and according to conventional work methods, importing and testing a single language took approximately 5-7 working days. Using the method of this application, only the corresponding file needs to be selected, and language import can be completed in seconds. The operation is simple and convenient, and subsequent checking and testing will also save a lot of workload due to the reduced error rate. Furthermore, the original text of the list file can be translated into any language, improving translation efficiency. This method integrates multiple text files into a single list file through tool conversion, making it easier to organize and access translated content and facilitating file transfer and sharing.
[0029] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0030] Other features, objects, and advantages of this disclosure will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0031] Figure 1 is an exemplary system architecture diagram in which an embodiment of this disclosure can be applied;
[0032] Figure 2 is a flowchart of an embodiment of the file conversion method according to the present disclosure;
[0033] Figures 3a-3b are schematic diagrams illustrating application scenarios of the file conversion method according to this disclosure;
[0034] Figure 4 is a flowchart of yet another embodiment of the file conversion method according to the present disclosure;
[0035] Figure 5 is a schematic diagram of a structure of a file conversion apparatus according to an embodiment of the present disclosure;
[0036] Figure 6 is a schematic diagram of the structure of a computer system suitable for implementing embodiments of the present disclosure. Detailed Implementation
[0037] The present disclosure will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.
[0038] It should be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.
[0039] Figure 1 illustrates an exemplary system architecture 100 to which embodiments of the file conversion method or file conversion apparatus of this disclosure may be applied.
[0040] As shown in Figure 1, the system architecture 100 may include a vehicle 101, a network 102, and a terminal device 103. The network 102 serves as the medium for providing a communication link between the vehicle 101 and the terminal device 103. The network 102 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0041] Vehicle 101 is equipped with a vehicle-mounted infotainment system capable of displaying interfaces in different languages. The text displayed on the infotainment system interface can be exported as a .po file using tools such as Kanzi. This .po file is then sent to terminal device 103 via network 102. Terminal device 103 converts the text-format .po file into a list-format Excel file. A translator then translates the text into various languages, and the list-format Excel file is converted back into a text-format .po file in the specified language. This .po file is then imported into the infotainment system using tools such as Kanzi, allowing the system to display the interface in the specified language.
[0042] Vehicle 101 can also be replaced with other devices that display multiple languages.
[0043] It should be noted that the file conversion method provided in the embodiments of this disclosure is generally executed by the terminal device 103, and correspondingly, the file conversion device is generally disposed in the terminal device 103.
[0044] It should be understood that the number of terminal devices, networks, and vehicles in Figure 1 is merely illustrative. Any number of terminal devices, networks, and vehicles can be used depending on implementation needs.
[0045] Referring again to Figure 2, a flow 200 of an embodiment of the file conversion method according to this disclosure is shown. The file conversion method includes the following steps:
[0046] Step 201: In response to receiving a request to convert a text file into a list file, check the validity of the text file and the list file.
[0047] In this embodiment, the entity executing the file conversion method (e.g., the terminal device shown in Figure 1) can provide a file conversion interface, where the user selects the text file to be converted and the list file to be converted. After the user clicks the convert button, the system checks the validity of the text file and the list file. First, the validity of the text file is checked; if the text file is valid, then the validity of the list file is checked. If the text file is invalid, the file conversion cannot be performed.
[0048] In some optional implementations of this embodiment, the following steps are taken: 1) Detecting whether a text file is selected; 2) In response to detecting that a text file is selected, determining that the text file is invalid and outputting a message indicating that the text file is empty; 3) In response to detecting that a text file is selected, detecting whether the selected text file is empty; 4) In response to detecting that the selected text file is empty, determining that the text file is invalid and outputting a message indicating that the text file is empty; 5) In response to detecting that the selected text file is not empty, determining that the text file is valid.
[0049] If no text file is selected, or if the selected text file is empty, a message indicating that the text file is empty will be output. After confirming the text file is valid, the validity of the list file will be checked.
[0050] In some optional implementations of this embodiment, the process involves detecting whether a list file is selected; in response to detecting that a list file is selected, opening the selected list file; and in response to successful opening, determining that the list file is valid. For example, an Excel file can be opened using the openpyxl library.
[0051] In some optional implementations of this embodiment, if no selectable list file exists, a new list file is created. The process involves detecting whether a list file is selected; in response to detecting that no list file is selected, a list file is created and opened; and in response to successful opening, the list file is determined to be valid.
[0052] Step 202: In response to the detection that both the text file and the list file are valid, check whether the original content of the original column in the list file is empty.
[0053] In this embodiment, the list file includes a source text column and at least one translation column. The source text column is used to place the content to be translated. Each translation column corresponds to a translation in one language. This application supports adding translations in other languages to existing translated texts, that is, adding new translation columns. If the source text content in the source text column of the list file is not empty, it means that the list file is not newly created and has been used before; if the source text content in the source text column of the list file is empty, it means that the list file is newly created.
[0054] Step 203: In response to detecting that the original text content of the original text column of the list file is not empty, match the original text content of the original text column of the list file with the original text content of the original text item of the text file.
[0055] In this embodiment, if the original text content of the original text column in the list file already exists, then the same original text items are matched one by one from the text file.
[0056] In some optional implementations of this embodiment, matching the original content of the original columns of the list file and the original content of the original items of the text file includes: traversing the original content of the original columns of the list file and the original content of the original items of the text file row by row; if the original content matches, the match is successful. Matching by row-by-row avoids duplication or omission.
[0057] Step 204: In response to a successful match, the translated content of the translated item corresponding to the original content of the original text item in the text file is assigned to the translated column of the current row where the original content of the original text column in the list file is located.
[0058] In this embodiment, if a match is successful, the translation from the text file can be extracted and placed in the translation column of the current row of the original text in the list file. The translation content of the translation item corresponding to the original text content in the text file can be empty. This embodiment filters out content in the text file that is irrelevant to the original text and displays the original text in a list format, making it convenient for translators to translate.
[0059] In some optional implementations of this embodiment, the method further includes: in response to detecting that the original text content of the original text column of the list file is empty, assigning the original text content of the original text item and the translated content of the corresponding translated item to the original text column and the translated text column of the list file, respectively. When the original text column of the list file is blank, directly filling the corresponding original text column and translated text column of the list file with the original text content extracted from the text file and the translated content of the corresponding translated item, so that the original text content and the translated content of the corresponding translated item are displayed on the same line.
[0060] In some optional implementations of this embodiment, the method further includes: responding to the fact that the original text content of the original text column of the list file is not empty, and no original text content matching the original text item of the text file is detected in the original text column of the list file, outputting a file conversion failure prompt message. If the content of the list file does not match the text file, then a new list file is selected or a new list file is created.
[0061] If the translation column in the list file is blank, the translation content of the text file's translation items can be directly assigned to the list file's translation column. If the list file's translation column is not blank, the translation content of the text file's translation items will replace the translation content of the list file's translation column. During the replacement process, if it is detected that the number of original text items in the text file is greater than the number of rows in the list file's original text column, the additional original text items and translation items from the text file will also be added to the list file, thus ensuring that the list file covers all the content of the text file.
[0062] The method provided in the above embodiments of this disclosure converts text files into list files for editing. The converted list files have clearer data with row and column breaks, resulting in higher readability and operability, and making translation more convenient. The content of the list files can be paginated and categorized, facilitating project summarization and statistics. Previously, developers manually copied and pasted languages, and according to conventional work methods, importing and testing a single language took approximately 5-7 working days. Using the method of this application, only the corresponding file needs to be selected, and language import can be completed in seconds. The operation is simple and convenient, and subsequent checking and testing will save a lot of workload due to the reduced error rate. Furthermore, the original text of the list file can be translated into multiple languages, improving translation efficiency. By using the conversion tool to integrate multiple text files into a single list file, the translated content can be more easily organized and accessed, facilitating file transfer and sharing.
[0063] In some optional embodiments, in response to receiving a request to convert a text file into a list file, the validity of the text file is checked. If the text file is valid, there is no need to check the validity of the list file; the list file is automatically created, including blank original text columns and blank translation columns. The original text content of the original text items in the text file and the translation content of the corresponding translation items are assigned to the original text columns and the translation columns of the list file, respectively. As shown in Figure 3a, when a valid PO file is detected, an Excel file including original text columns and translation columns is automatically created. If the translation content of the translation items in the PO file is also detected to be in English, the translation column in the Excel file can be named "Translation Column_English".
[0064] Referring again to Figure 3a, which is a schematic diagram of an application scenario of the file conversion method according to this embodiment, a text file is converted into a list file. Taking a .po file as an example, the original text items are represented by msgtxt, and the translated text items by msgstr. If the original text columns of the Excel file are not empty, the original text "System Error" and "System Warning" in the .po file are matched with the original text columns of the Excel file respectively, locating "System Error" in the first row and "System Warning" in the second row. Then, the translated text "System Error" corresponding to "System Error" is filled into the first row of the translated text column, and the translated text "System Warning" corresponding to "System Warning" is filled into the second row of the translated text column. Finally, the original text and translated text from the .po file are exported to a list file, filtering out other content, which facilitates users to check translation problems and perform translations into other languages.
[0065] Referring further to Figure 4, a flow 400 of another embodiment of the file conversion method is illustrated. Flow 400 of the file conversion method includes the following steps:
[0066] Step 401: In response to receiving a request to convert the list file into a text file, check the validity of the text file and the list file.
[0067] In this embodiment, the entity executing the file conversion method (e.g., the terminal device shown in Figure 1) can provide a file conversion interface, where the user selects the list file to be converted and the text file to be converted. After the user clicks the convert button, the validity of the text file and the list file needs to be checked. The validity of the list file is checked first; if the list file is valid, then the validity of the text file is checked. If either the list file or the text file is invalid, the file conversion cannot be achieved.
[0068] In some optional implementations of this embodiment, the following steps are taken: First, it is detected whether a list file is selected. If a list file is not selected, it is determined that the list file is invalid, and a message indicating that the list file is empty is output. If a list file is selected, it is determined that the list file is valid, and then it is detected whether a text file is selected. If a text file is selected, it is determined that the text file is invalid, and a message indicating that the text file is empty is output. In this embodiment, both the list file and the text file must be valid for file conversion to be achieved. The text file cannot be generated; its original text items are the initial information, and the translated items of the text file and the content of the converted list file both originate from the initial information.
[0069] Step 402: In response to the detection that both the text file and the list file are valid, the target language to be exported is parsed from the filename of the text file, and the corresponding translation column of the list file is determined.
[0070] In this embodiment, the method of this application supports list files in multiple languages. While the text file of this application is unique, there can be multiple list files in different languages. During the conversion process, the list file can be determined based on the target language. Since the original and target text items are extracted from the text file for translation during the conversion to a list file, while other information remains in the text file, a separate text file cannot be directly generated for each language during the subsequent conversion of the list file to a text file. Instead, target text items can only be replaced or updated within the existing text file.
[0071] Step 403: Match the original text content in the original text column of the list file with the original text content in the original text item of the text file.
[0072] In this embodiment, if the translation content of a text file translation item is not empty, it means that the text file originally contained a translation, which needs to be replaced. If the translation content of a text file translation item is empty, the translation content is directly imported.
[0073] Step 404: In response to a successful match, the translation content of the translation column in the list file is assigned to the translation item in the text file.
[0074] In this embodiment, the original text with the same content is found in the list file, and then the content of the translation item in the text file is replaced with the translation in the specified language in the list file.
[0075] The method provided in the above embodiments of this disclosure converts list files back to text files with a low error rate and avoids issues such as copying errors. Previously, developers manually copied and pasted languages, and according to conventional work methods, importing and testing a single language took approximately 5-7 working days. Using the method of this application, only the corresponding file needs to be selected, and language import can be completed in seconds, making the operation simple and convenient. Subsequent checking and testing will also save a lot of workload due to the reduced error rate. Furthermore, the original list file can be translated into any language, improving translation efficiency. This method, through tool conversion, integrates multiple text files into a single list file, making it easier to organize and access translated content, and facilitating file transfer and sharing.
[0076] In some optional implementations of this embodiment, the method further includes: in response to detecting that the translated content of a translated item in the text file is empty, matching the original content of the original column in the list file with the original content of the original item in the text file; in response to a successful match, assigning the translated content of the translated column corresponding to the original content of the original column in the list file to the translated item corresponding to the original content of the original item in the text file. If the translated content of the text file is empty, directly filling the blank translation space corresponding to the original text in the list file with the same original text.
[0077] In some optional implementations of this embodiment, matching the original content of the original columns of the list file and the original content of the original items of the text file includes: traversing the original content of the original columns of the list file and the original content of the original items of the text file row by row for matching. Matching by row avoids duplication or omission.
[0078] In some optional implementations of this embodiment, the method further includes: outputting a conversion failure message in response to the absence of a translation column for the target language in the list file. If the required translation column for the target language does not exist in the list file, the file conversion cannot be completed, and a message needs to be output.
[0079] In some alternative implementations, each language corresponds to a separate text file, so the language is distinguished by the filename. For example, if the text filename includes "en", the translation is English; if the filename includes "fr", the translation is French. Both French and English .po files can correspond to a single list file, using the same source text column, but with separate translation columns.
[0080] Referring again to Figure 3b, which is another schematic diagram of the application scenario of the file conversion method according to this embodiment, the list file is converted into a text file. Taking a .po file as an example, the original text items are represented by msgtxt, and the translated text items by msgstr. Based on the name of the .po file, the required translation is identified as "fr," representing French, and the translation is searched in "Translation Column_French." The original texts "System Failure" and "System Alarm" in the Excel file are matched with the original text item msgtxt in the .po file. Then, the French translation "système défaillance" corresponding to "System Failure" is filled into the corresponding translation item msgstr, and the French translation "système d'alerte" corresponding to "System Alarm" is filled into the corresponding translation item msgstr. Finally, the French translations of the list file are imported into the .po file, which improves accuracy and reduces the workload for users.
[0081] Referring further to FIG5, as an implementation of the methods shown in the above figures, this disclosure provides an embodiment of a file conversion device, which corresponds to the method embodiment shown in FIG2, and the device can be specifically applied to various electronic devices.
[0082] As shown in Figure 5, the file conversion device 500 of this embodiment includes: a file detection unit 501, a content detection unit 502, a matching unit 503, an assignment unit 504, and a parsing unit 505. The document detection unit 501 is configured to detect the validity of the text file and the list file in response to receiving a request to convert a text file into a list file; the content detection unit 502 is configured to detect whether the original content of the original text item in the text file and the original content of the original text column in the list file are empty in response to detecting that both the text file and the list file are valid; the matching unit 503 is configured to match the original content of the original text column in the list file and the original content of the original text item in the text file in response to detecting that the original content is not empty; the assignment unit 504 is configured to assign the translated content of the translated item in the text file to the translated column of the current row where the original content of the original text column in the list file is located in response to successful matching; or, it is configured to assign the translated content of the translated column in the list file to the translated item in the text file in response to successful matching; and the parsing unit 505 is configured to parse the target language from the filename of the text file in response to detecting that both the text file and the list file are valid.
[0083] In some optional implementations of this embodiment, the assignment unit 504 is further configured to: in response to detecting that the original text content of the original text column of the list file is empty, assign the original text content of the original text item of the text file and the translation content of the corresponding translation item to the original text column and the translation column of the list file, respectively.
[0084] In some optional implementations of this embodiment, the device 500 further includes a prompting unit (not shown in the figures), configured to: in response to the original text content of the original text column of the list file being non-empty, and no original text content matching the original text item of the text file being detected in the original text column of the list file, output a file conversion failure prompt message.
[0085] In some optional implementations of this embodiment, the file detection unit 501 is further configured to: detect whether a text file is selected; in response to detecting that a text file is selected, determine that the text file is invalid and output a prompt message indicating that the text file is empty; in response to detecting that a text file is selected, detect whether the selected text file is empty; in response to detecting that the selected text file is empty, determine that the text file is invalid and output a prompt message indicating that the text file is empty; in response to detecting that the selected text file is not empty, determine that the text file is valid.
[0086] In some optional implementations of this embodiment, the file detection unit 501 is further configured to: detect whether a list file is selected; in response to detecting that a list file is selected, open the selected list file; and in response to successful opening, determine that the list file is valid.
[0087] In some optional implementations of this embodiment, the file detection unit 501 is further configured to: detect whether a list file is selected; in response to detecting that no list file is selected, create a list file and open the created list file; in response to successful opening, determine that the list file is valid.
[0088] In some optional implementations of this embodiment, the matching unit 503 is further configured to: traverse the original text content of the original text column of the list file and the original text content of the original text item of the text file row by row, and if the original text content is consistent, the match is successful.
[0089] The file detection unit 501 is further configured to detect the validity of the text file and the list file in response to a request to convert the list file into a text file; the matching unit 503 is further configured to match the original text content of the original text column of the list file with the original text content of the original text item of the text file; the replacement unit 604 is configured to assign the translated content of the translated text column of the list file to the translated text item of the text file in response to a successful match. In some optional implementations of this embodiment, the matching unit 503 is further configured to: traverse the original text content of the original text column of the list file and the original text content of the original text item of the text file row by row, and the match is successful if the original text content is consistent.
[0090] In some optional implementations of this embodiment, the device 500 further includes a prompting unit (not shown in the figures), configured to output a prompt message indicating conversion failure in response to the absence of a translation column for the translation language in the list file.
[0091] In some optional implementations of this embodiment, the file detection unit 501 is further configured to: detect whether a list file is selected; in response to detecting that no list file is selected, determine that the list file is invalid and output a prompt message that the list file is empty; in response to detecting that a list file is selected, determine that the list file is valid and detect whether a text file is selected; in response to detecting that a text file is selected, determine that the text file is invalid and output a prompt message that the text file is empty.
[0092] It should be noted that the collection, gathering, updating, analysis, processing, use, transmission, and storage of user personal information involved in this disclosed technical solution all comply with relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken to prevent unauthorized access to user personal information data and to safeguard user personal information security, network security, and national security.
[0093] According to embodiments of this disclosure, this disclosure also provides an electronic device and a readable storage medium.
[0094] An electronic device includes: one or more processors; and a storage device having one or more computer programs stored thereon, which, when executed by the one or more processors, cause the one or more processors to implement the method described in process 200 or 400.
[0095] A computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described in process 200 or 400.
[0096] Figure 6 illustrates a schematic block diagram of an example electronic device 500 that can be used to implement embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0097] As shown in Figure 6, device 500 includes a computing unit 601, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 602 or a computer program loaded from storage unit 608 into random access memory (RAM) 503. RAM 503 can also store various programs and data required for the operation of device 500. The computing unit 601, ROM 602, and RAM 503 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0098] Multiple components in device 500 are connected to I / O interface 605, including: input unit 606, such as keyboard, mouse, etc.; output unit 607, such as various types of monitors, speakers, etc.; storage unit 608, such as disk, optical disk, etc.; and communication unit 609, such as network card, modem, wireless transceiver, etc. Communication unit 609 allows device 500 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0099] The computing unit 601 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as road planning methods. For example, in some embodiments, the road planning method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on device 500 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 503 and executed by the computing unit 601, one or more steps of the road planning method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the road planning method by any other suitable means (e.g., by means of firmware).
[0100] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0101] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0102] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0103] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0104] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0105] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be servers in distributed systems or servers incorporating blockchain technology. Servers can also be cloud servers, or intelligent cloud computing servers or intelligent cloud hosts with artificial intelligence technology.
[0106] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0107] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A file conversion method, comprising: In response to a request to convert a text file into a list file, the validity of the text file and the list file is checked. In response to the detection that both the text file and the list file are valid, it is checked whether the original text content of the original text column of the list file is empty; in response to the detection that the original text content of the original text column of the list file is not empty, the original text content of the original text column of the list file and the original text content of the original text item of the text file are matched; in response to the successful matching, the translated content of the translated item corresponding to the original text content of the original text item of the text file is assigned to the translated column of the current row where the original text content of the original text column of the list file is located.
2. The method according to claim 1, wherein, The method further includes: in response to detecting that the original text content of the original text column of the list file is empty, assigning the original text content of the original text item and the translation content of the corresponding translation item of the text file to the original text column and the translation column of the list file, respectively.
3. The method according to claim 1, wherein, The method further includes: in response to the fact that the original text content of the original text column of the list file is not empty, and no original text content matching the original text item of the text file is detected in the original text column of the list file, outputting a file conversion failure prompt message.
4. The method according to claim 1, wherein, The method for detecting the validity of text files and list files includes: detecting whether a text file is selected; in response to detecting that a text file is not selected, determining that the text file is invalid and outputting a prompt message indicating that the text file is empty; in response to detecting that a text file is selected, detecting whether the selected text file is empty; in response to detecting that the selected text file is empty, determining that the text file is invalid and outputting a prompt message indicating that the text file is empty; and in response to detecting that the selected text file is not empty, determining that the text file is valid.
5. The method according to claim 1, wherein, The method for detecting the validity of text files and list files includes: detecting whether a list file is selected; opening the selected list file in response to detecting that a list file is selected; and determining that the list file is valid in response to successful opening.
6. The method according to claim 1, wherein, The method for detecting the validity of text files and list files includes: detecting whether a list file is selected; in response to detecting that a list file is not selected, creating a list file and opening the created list file; and in response to successful opening, determining that the list file is valid.
7. The method according to claim 1, wherein, The matching of the original text content of the original text column of the list file and the original text content of the original text item of the text file includes: traversing the original text content of the original text column of the list file and the original text content of the original text item of the text file row by row, and the matching is successful if the original text content is the same.
8. A file conversion method, comprising: In response to a request to convert a list file into a text file, the validity of both the text file and the list file is checked. In response to the detection that both the text file and the list file are valid, the target language to be exported is parsed from the filename of the text file, and the corresponding translation column of the list file is determined; the original text content of the original text column of the list file is matched with the original text content of the original text item of the text file; In response to a successful match, the translated content of the translation column in the list file is assigned to the translation item in the text file.
9. The method according to claim 8, wherein, The matching of the original text content of the original text column of the list file and the original text content of the original text item of the text file includes: traversing the original text content of the original text column of the list file and the original text content of the original text item of the text file row by row, and the matching is successful if the original text content is the same.
10. The method according to claim 8, wherein, The method further includes: in response to the absence of a translation column corresponding to the translation language in the list file, outputting a prompt message indicating conversion failure.
11. The method according to claim 8, wherein, The method for detecting the validity of text files and list files includes: detecting whether a list file is selected; in response to detecting that a list file is not selected, determining that the list file is invalid and outputting a prompt message indicating that the list file is empty; in response to detecting that a list file is selected, determining that the list file is valid and detecting whether a text file is selected; in response to detecting that a text file is not selected, determining that the text file is invalid and outputting a prompt message indicating that the text file is empty.
12. A file conversion apparatus, comprising: The document detection unit is configured to detect the validity of the text file and the list file in response to a request to convert a text file into a list file. The content detection unit is configured to detect whether the original content of the original items in the text file and the original content of the original columns in the list file are empty in response to detecting that both the text file and the list file are valid; the matching unit is configured to match the original content of the original columns in the list file and the original content of the original items in the text file in response to detecting that the original content is not empty. The assignment unit is configured to, in response to a successful match, assign the translated content of the translated item in the text file to the translated column of the current row containing the original content of the original column in the list file; Alternatively, it may be configured to, in response to a successful match, assign the translation content of the translation column in the list file to the translation item in the text file; the parsing unit may be configured to, in response to detecting that both the text file and the list file are valid, parse the translation language to be exported from the filename of the text file.
13. An electronic device, comprising: One or more processors; A storage device having stored one or more computer programs thereon, which, when executed by the one or more processors, cause the one or more processors to implement the method as described in any one of claims 1-11.
14. A computer-readable medium having a computer program stored thereon, wherein, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-11.