File processing method, device, computer equipment and storage medium
In the development of application desktop languages, the spliced content is generated according to the path differences of yaml files and written to the target file, which solves the problem of high error rate in desktop language conversion, and achieves more efficient file processing and format accuracy.
Patent Information
- Application Number
- CN201910934796.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-29
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2039-09-29
AI Technical Summary
In the process of desktop language development of application applications, the existing technology leads to high error rates during desktop language conversion, especially when processing yaml files, the adjustment and translation process of file formats are complicated, resulting in waste of manpower and time.
By obtaining multiple records in the record file, each record contains parameter paths and key-value pairs, forming splicing content according to the path differences, adjusting the format using hierarchical feature characters, and writing the content to the target file to ensure the correct hierarchical relationship between the key-value pairs .
It reduces the error rate during the application desktop language development process, simplifies the processing process of yaml files, and improves the accuracy and efficiency of file formats.
Smart Images

Figure CN112579079B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of file processing technology, and in particular to a file processing method, device, computer equipment and storage medium. Background Art
[0002] With the popularity of mobile terminals, client applications running on mobile terminals are becoming more and more abundant. Among them, client applications need to provide a desktop for interacting with users on the one hand, and a background program for interacting with the service area on the other hand. Compared with ini files and conf files, yaml files are more concise and easier to operate. At the same time, they can store different types of data without changing the original data type. All data types will be output as they are when read. Therefore, yaml files are often used as configuration files in the development process of application desktops.
[0003] Furthermore, the inventors found that during the development of the application desktop, when it is necessary to convert the desktop language, for example, converting the Chinese desktop of a client application into an English desktop, errors often occur. In this regard, the inventors further studied and found that when converting the desktop language, the relevant information in the configuration file needs to be converted from the original text to the translated text. The existing implementation method is that the developer delivers the Chinese yaml file to the product personnel (possibly dozens or hundreds of files), and the product personnel cannot adjust the spaces in the file at will (the yaml file uses spaces to represent hierarchical relationships). The product personnel then translates the corresponding Chinese into the translated text. After the translation is completed, the developer manually adds each yaml file to the corresponding folder. The process is relatively complicated and has strict requirements on the format of the yaml file for product translation, which leads to errors in the format of the translated yaml file, and then causes errors in the desktop language conversion.
[0004] In addition, when the YAML file needs to add several or more new data, the above flow process needs to be repeated; when desktops in multiple languages need to be provided, the above flow process also needs to be repeated separately, which greatly wastes manpower and time.
[0005] Therefore, providing a file processing method, apparatus, computer equipment and storage medium to reduce the error rate in the application desktop language development process has become a technical problem that urgently needs to be solved in this field. Summary of the invention
[0006] The purpose of the present invention is to provide a file processing method, device, computer equipment and storage medium, which are used to solve the technical problem of high error rate in the application desktop language development process in the prior art.
[0007] On the one hand, to achieve the above-mentioned purpose, the present invention provides a method for processing a file.
[0008] The processing method of the file includes: obtaining a record file, wherein the record file includes multiple records, the record includes a path and a key-value pair of a parameter, and the key-value pair includes the parameter and the value of the parameter; judging whether the Nth path in the Nth record is the same as the N-1th path in the N-1th record, wherein the Nth record is any record in the record file, and the N-1th record is the previous record adjacent to the Nth record; if the Nth path is the same as the N-1th path, splicing the key-value pairs in the Nth record after a first number of hierarchical feature characters to generate spliced content, wherein the first number is the product of the number of preset unit hierarchical feature characters and the number of levels of the Nth path, and when the Nth path is empty, the number of levels of the Nth path is 0; if the Nth path is different from the N-1th path, determine whether the Nth path is empty; if the Nth path is empty, use the key-value pair as the splicing content; if the Nth path is not empty, determine the different levels in the Nth path and the N-1th path, and splice each different level in the order from small to large in the following manner: splice curPath[i] after the second number of level feature characters, and wrap after splicing curPath[i], and splice the key-value pairs after splicing each different level to generate splicing content, where the second number is the product of the preset unit level feature character number and i, and curPath[i] is the i-th level of the Nth path; write the splicing content into the target file.
[0009] Furthermore, the record also includes file information of different target files corresponding to the parameters; and the step of writing the spliced content into the target file includes: writing the spliced content into the target file according to the file information in the Nth record.
[0010] Further, when N=1, all contents in the N-1th record are empty; the file information includes the storage path of the target file, and the step of writing the spliced content into the target file according to the file information in the Nth record includes: when N=1, creating a new target file at the location indicated by the storage path in the Nth record, and writing the spliced content into the target file; when N>1, searching for the target file at the location indicated by the storage path in the Nth record, and writing the spliced content into the target file.
[0011] Furthermore, before the step of determining whether the Nth path is the same as the N-1th path, the file processing method further includes: recording records having the same file information and path into the same object; the step of determining whether the Nth path is the same as the N-1th path includes: determining whether the Nth record and the N-1th record belong to the same object, wherein, when the Nth record and the N-1th record belong to the same object, the Nth path is the same as the N-1th path, and when the Nth record and the N-1th record do not belong to the same object, the Nth path is different from the N-1th path.
[0012] Furthermore, before the step of determining whether the Nth path is the same as the N-1th path, after recording the records with the same file information and path into the same object, the file processing method also includes: sorting the objects including the same file information in alphabetical order of the path; and when executing the step of determining whether the Nth path is the same as the N-1th path, sequentially obtaining the records in the sorted object for determination.
[0013] Furthermore, before the step of determining whether the Nth path is the same as the N-1th path, the file processing method also includes: determining whether the file information and parameters in the Nth record are empty; when the file information and / or parameters in the Nth record are empty, discarding the Nth record; when the file information and parameters in the Nth record are not empty, executing the step of determining whether the Nth path is the same as the N-1th path.
[0014] Further, the file information of the target file includes the storage path and file name of the source file corresponding to the target file, and the storage path of the target file is the same as the storage path of the source file; the first column of the record includes the storage path and file name of the source file where the parameter is located, the second column of the record includes the path of the parameter in the source file, the third column of the record is the parameter, the fourth column of the record is the original text corresponding to the parameter in the source file, the fifth column of the record is the translation text corresponding to the original text, and the translation text is the value of the parameter; when the value of the parameter in the Nth record is empty, the original text is used as the value of the parameter; the step of creating a new target file at the location indicated by the storage path in the Nth record includes: creating a new empty file with a first name as the target file at the location indicated by the storage path in the Nth record, wherein the first name includes the file name of the source file and additional characters identifying the language type of the translation text.
[0015] On the other hand, to achieve the above objective, the present invention provides a file processing device.
[0016] The processing device of the file includes: an acquisition module, which is used to acquire a record file, wherein the record file includes multiple records, the record includes a path and a key-value pair of a parameter, and the key-value pair includes the parameter and the value of the parameter; a first judgment module, which is used to judge whether the Nth path in the Nth record is the same as the N-1th path in the N-1th record, wherein the Nth record is any record in the record file, and the N-1th record is the previous record adjacent to the Nth record; a first splicing module, which is used to splice the key-value pairs in the Nth record after a first number of hierarchical feature characters to generate splicing content when the Nth path is the same as the N-1th path, wherein the first number is the product of the number of preset unit hierarchical feature characters and the number of levels of the Nth path, and when the Nth path is empty, the number of levels of the Nth path is 0; a second judgment module, which is used to judge whether the Nth path in the Nth record is the same as the N-1th path, and the N-1th record is the previous record adjacent to the Nth record; a first splicing module, which is used to splice the key-value pairs in the Nth record after a first number of hierarchical feature characters to generate splicing content when the Nth path is the same as the N-1th path, and the Nth path is empty. a disconnection module, for judging whether the Nth path is empty when the Nth path is different from the N-1th path; a second splicing module, for using the key-value pair as the splicing content when the Nth path is empty; a third splicing module, for determining the different levels in the Nth path and the N-1th path when the Nth path is not empty, and splicing each different level in the order from small to large in the following manner: splicing curPath[i] after the second number of level feature characters, and wrapping after splicing curPath[i], and splicing the key-value pairs after splicing each different level to generate splicing content, wherein the second number is the product of the preset unit level feature character number and i, and curPath[i] is the i-th level of the Nth path; and a writing module, for writing the splicing content into a target file.
[0017] On the other hand, to achieve the above purpose, the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the above method when executing the computer program.
[0018] On the other hand, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned method are implemented.
[0019] The file processing method, device, computer equipment and storage medium provided by the present invention first obtain a record file, set multiple records in the record file, each record corresponds to a parameter, each record includes the path of the parameter and a key-value pair, the key-value pair includes the parameter and the value of the parameter, and then for each record, a spliced content is formed according to the difference between its path and the path of the previous record adjacent to it, the spliced content includes hierarchical feature characters and key-value pairs, and the position and number of the hierarchical feature characters are related to the path of the parameter, and then the spliced content is written into the target file, so that the format of the key-value pairs in the target file can correctly reflect the hierarchical relationship between the key-value pairs, so that when the desktop of the application is generated based on the target file, it is only necessary to load the target file. Compared with manually forming the target file, the error rate in the application desktop language development process can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A flowchart of the steps of the method for processing a file provided in the first embodiment of the present invention;
[0021] Figure 2 A flowchart of the steps of the method for processing a file provided in Embodiment 2 of the present invention;
[0022] Figure 3 A flowchart of the steps of the method for processing a file provided in Embodiment 3 of the present invention;
[0023] Figure 4 A block diagram of a file processing device provided in Embodiment 5 of the present invention;
[0024] Figure 5 This is a hardware structure diagram of a computer device provided in Example 6 of the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical scheme and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0026] It should be noted that in the present invention, hierarchical characteristic characters are used to represent hierarchical relationships in the target file. For example, in a YAML file, a space is used to represent a hierarchical relationship, and the space is the hierarchical characteristic character in the YAML file. Alternatively, other characters can be used as hierarchical characteristic characters, which can be set according to the format requirements of the target file, and the present application does not limit this.
[0027] This application is described using the desktop development scenario of an application as an example, but the protection scope of the claims of this application is not limited to the desktop development scenario of the application. The target file can also be used in other scenarios, and this application does not limit the usage scenario of the target file.
[0028] The present invention provides a method, device, computer equipment and storage medium for processing a file. In the method for processing a file provided by the present invention, a record file is first obtained, wherein a record in the record file can be constructed corresponding to each parameter in the source file, each record includes a path and a key-value pair of the parameter, the key-value pair includes the parameter and the value of the parameter, and a record file includes multiple records. Processing is performed for each record, specifically forming a splicing content according to a record, and then writing the splicing content into a target file until the splicing contents formed by all records corresponding to the same target file are all written into the target file.
[0029] The Nth record is a record in the record file, the N-1th record is a previous record adjacent to the Nth record, and the specific steps of forming the splicing content according to the Nth record and then writing the splicing content into the target file include:
[0030] Determine whether the Nth path in the Nth record is the same as the N-1th path in the N-1th record.
[0031] If the two paths are the same, that is, the key-value pairs in the two records have the same level in the target file, then the key-value pairs in the Nth record are spliced after the first number of level feature characters to generate the spliced content, and then written into the target file, where the first number is the product of the number of level feature characters of the preset unit and the number of levels of the Nth path. After the spliced content corresponding to the Nth record is written into the target file, the key-value pairs in the Nth record are indented by the same number of level feature characters as the key-value pairs in the N-1th record, that is, the two records are aligned, and the format meets the format requirement that the key-value pairs in the two records have the same level in the target file. Among them, when the Nth path is empty, the level number of the Nth path is 0, that is, the first number is 0. After the spliced content corresponding to the Nth record is written into the target file, it is equivalent to that the key-value pairs in the Nth record do not need to add level feature characters, and the format meets the format requirement that the level number of the path in the Nth record is 0.
[0032] If the Nth path is different from the N-1th path, it is necessary to further determine whether the Nth path is empty. If the Nth path is empty, the key-value pair is used as the concatenated content and directly written into the target file. After the concatenated content corresponding to the Nth record is written into the target file, it is equivalent to the key-value pair in the Nth record not needing to add hierarchical characteristic characters, and the format meets the format requirement that the number of levels of the path in the Nth record is 0.
[0033] If the Nth path is not empty, it is necessary to determine several different levels in the Nth path and the N-1 path, and then concatenate each different level in ascending order in the following manner: concatenate curPath[i] after the second number of level feature characters, and wrap after concatenating curPath[i], until all different levels are concatenated, and then concatenate the key-value pairs to generate concatenated content, and write the concatenated content into the target file, where the second number is the product of the preset unit level feature character number and i, and curPath[i] is the i-th level of the Nth path, which is equivalent to the path of the Nth record being reflected before the key-value pair in the Nth record.
[0034] To sum up, after the spliced contents formed by all records corresponding to the same target file are written into the target file according to the above process, the application can load the target file when providing the desktop of the language corresponding to the target file. Compared with manually forming the target file, it can reduce the error rate in the application desktop language development process.
[0035] Specific embodiments of the file processing method, apparatus, computer device and storage medium provided by the present invention will be described in detail below.
[0036] Embodiment 1
[0037] The embodiment of the present invention provides a method for processing a file, which can be processed into an executable script. In the development process of an application desktop, when it is necessary to configure a yaml file (or a file in another format) of the desktop, especially when it is necessary to convert the desktop language, a record file corresponding to the translation is first constructed. After the record file is processed by the script, the record file can be formed into a target file and stored in a specific folder. The display program of the application desktop reads the target file in the specific folder, and the display of the application desktop corresponding to the target file is realized. Through this method, the error rate in the language development process of the application desktop can be reduced. Specifically, Figure 1 The following is a flowchart of the method for processing a file provided in the first embodiment of the present invention. Figure 1 As shown, the file processing method provided by this embodiment includes the following steps S101 to S109.
[0038] Step S101: Obtain a record file.
[0039] The record file includes multiple records, each record includes a path and a key-value pair of a parameter, and the key-value pair includes a parameter and a value of the parameter.
[0040] Optionally, the format of the record file may be in Excel format, or may be in other formats, which is not limited in the present application.
[0041] Optionally, when it is necessary to configure the yaml file of the desktop, first construct a record file corresponding to the yaml file; or, when it is necessary to configure the yaml file of the new language desktop according to the yaml file of the existing language desktop, first construct a record file according to the yaml file of the existing language desktop, for example, construct a record in the record file corresponding to each parameter in the yaml file of the existing language desktop, the path of the parameter is the path of the parameter in the yaml file of the existing language desktop, and the value of the parameter in the key-value pair is the new language translation corresponding to the text of the parameter in the yaml file of the existing language desktop.
[0042] Step S102: Determine whether the Nth path in the Nth record is the same as the N-1th path in the N-1th record.
[0043] Optionally, the initial value of N is 1. After the record file is obtained, step S102 is executed starting from the first record, wherein when N=1, the N-1th path is empty.
[0044] If the Nth path is the same as the N-1th path, step S103 is executed; if the Nth path is different from the N-1th path, step S104 is executed.
[0045] Step S103: concatenate the key-value pairs in the Nth record after the first number of hierarchical characteristic characters to generate concatenated content.
[0046] Among them, the first number is the product of the number of preset unit level feature characters and the number of levels of the Nth path. The number of preset unit level feature characters can be set according to the format requirements of the target file. For example, for a yaml file, the level feature character is a space, and the number of preset unit level feature characters is set to 2.
[0047] When the Nth path is empty, the number of levels of the Nth path is 0. For example, when the Nth path is aaa / bbb / cccs, " / " is the level separator of the path, and the number of levels of the Nth path is 3. Alternatively, different levels of the path can also be identified by other separators, such as "-", etc. This application does not limit this.
[0048] Optionally, when the Nth path is the same as the N-1th path, the first number is calculated first, and then the spliced content is generated according to the first number.
[0049] Optionally, when the Nth path is the same as the N-1th path, first determine whether the Nth path is empty. If the Nth path is empty, no hierarchical feature character is required before the key-value pair, and the key-value pair is directly used as the splicing content; if the Nth path is not empty, calculate the first quantity, and then generate the splicing content according to the first quantity.
[0050] Regardless of the method, after the spliced content is generated, step S108 is executed.
[0051] Through step S103, the generated concatenated content is written in the target file. When the Nth path is the same as the N-1th path, that is, when the levels of the paths of the parameters in the two records are the same, it can be ensured that the key-value pairs of the two records in the target file have the same number of hierarchical characteristic characters in front, that is, the key-value pairs of the two records in the target file are aligned.
[0052] Step S104: Determine whether the Nth path is empty.
[0053] If the Nth path is empty, step S105 is executed; if the Nth path is not empty, step S106 is executed.
[0054] Step S105: taking the key-value pair as the concatenated content.
[0055] If the Nth path is empty, there is no need to add hierarchical characteristic characters before the key-value pair. In step S105, the key-value pair is directly used as the concatenated content. After the concatenated content is generated, step S108 is executed.
[0056] Through step S105, the generated concatenated content is written in the target file. When the Nth path is empty, that is, when the level of the path of the parameter in the Nth record is 0, it can be ensured that no level characteristic character is added before the key-value pair of the record in the target file.
[0057] Step S106: Determine the different levels in the Nth path and the N-1th path, and concatenate the different levels in ascending order in the following manner: concatenate curPath[i] after the second number of level feature characters, and wrap after concatenating curPath[i].
[0058] When the Nth path is different from the N-1th path and the Nth path is not empty, step S106 needs to be executed. Wherein, curPath[i] is the different level between the Nth path and the N-1th path and is the i-th level of the Nth path, and the second number is the product of the number of characteristic characters of the preset unit level and i.
[0059] For example, if the target file is a yaml file, and the 2nd to 4th levels in the Nth path are different levels from those in the Nth path and the N-1 path, then: concatenate the 2nd level curPath[2] of the Nth path after 2*2 spaces, and wrap after concatenating curPath[2]. Then concatenate the 3rd level curPath[3] of the Nth path after 2*3 spaces, and wrap after concatenating curPath[3]. Then concatenate the 4th level curPath[4] of the Nth path after 2*4 spaces, and wrap after concatenating curPath[4].
[0060] Optionally, the Nth path and the N-1th path are respectively divided into arrays, the array after the Nth path is divided is curPath, and the array after the N-1th path is divided is prePath. The step S106 specifically includes the following steps:
[0061] Step S1061: Determine whether curPath[i] is the same as prePath[i], wherein if curPath[i] is different from prePath[i], execute step S1062; if curPath[i] is the same as prePath[i], execute step S1063;
[0062] Step S1062: splicing a second number of hierarchical characteristic characters at the current splicing position of the middle splicing content, then splicing curPath[i], and wrapping after splicing curPath[i], and executing step S1063 after wrapping, wherein the middle splicing content is initially empty;
[0063] Step S1063: Determine whether i is less than the number of levels sum1 of the Nth path, where when i is less than sum1, i=i+1, and return to step S1061. When i is equal to sum1, it ends. At this time, the intermediate splicing content is the result of splicing all different levels.
[0064] Step S107: splicing the key-value pairs at different levels to generate spliced content.
[0065] After the spliced content is generated, step S108 is executed.
[0066] Through step S106 and step S107, the generated concatenated content is written in the target file, which can ensure that the path of the Nth record is correctly reflected before the key-value pair of the record in the target file.
[0067] Step S108: writing the spliced content into the target file.
[0068] Step S109: Determine whether N is less than the number of records in the record file.
[0069] When N is less than the total number of records, N=N+1, and the process returns to step S102, and ends when N is equal to the number of records. Optionally, when all records in the record file need to be written into the same target file, the number of records in step S109 is the total number of records in the record file, and when all records in the record file need to be written into different target files, the number of records is the number of records in the record file that need to be written into the same target file, and when N is equal to the number of records, the writing of one target file ends, and steps S102 to S109 can be repeatedly executed to process the records in the record file that need to be written into another target file to realize the writing of another target file, until all records in the record file are written into the corresponding target file.
[0070] The file processing method provided by this embodiment first obtains a record file, sets multiple records in the record file, each record corresponds to a parameter, each record includes a path and a key-value pair of the parameter, the key-value pair includes the parameter and the value of the parameter, and then for each record, a spliced content is formed according to the difference between its path and the path of the previous record adjacent to it, the spliced content includes hierarchical feature characters and key-value pairs, and the position and number of the hierarchical feature characters are related to the path of the parameter, and then the spliced content is written into the target file, so that the format of the key-value pairs in the target file can correctly reflect the hierarchical relationship between the key-value pairs, so that when generating the desktop of the application based on the target file, it is only necessary to load the target file. Compared with manually forming the target file, the error rate in the application desktop language development process can be reduced.
[0071] Optionally, in an embodiment, the record further includes file information of different target files corresponding to the parameters; and the step of writing the spliced content into the target file includes: writing the spliced content into the target file according to the file information in the Nth record.
[0072] Specifically, if the record file includes records that need to be written into different target files, the record correspondingly includes file information corresponding to different target files, that is, when the file information in the record is different, the spliced content formed by the record needs to be written into different target files. Based on this, when writing the spliced content into the target file, the spliced content belonging to the same target file is processed according to the file information in the record corresponding to the spliced content, so that the spliced content belonging to the same target file is written into the same target file, and the spliced content belonging to different target files is written into different target files.
[0073] By adopting the file processing method provided by this embodiment, when the desktop of an application requires multiple configuration files, especially when tens of thousands of configuration files need to be configured, the parameters in different configuration files can be reflected in the same record file. After processing the record file, the generated target files, i.e., the configuration files, can reduce the processing steps compared to setting up a record file for each configuration file and processing them separately. The file processing method provided by this embodiment can generate multiple configuration files at one time.
[0074] Optionally, in one embodiment, when N=1, all contents in the N-1th record are empty; the file information includes the storage path of the target file, and the step of writing the spliced content into the target file according to the file information in the Nth record includes: when N=1, creating a new target file at the location indicated by the storage path in the Nth record, and writing the spliced content into the target file; when N>1, searching for the target file at the location indicated by the storage path in the Nth record, and writing the spliced content into the target file.
[0075] Specifically, when the target file needs to be placed in a predetermined storage path, the storage path of the target file is added to the record, so that when the spliced content formed according to the first record is written into the target file, a new target file can be automatically created and written at the location indicated by the storage path in the record; when the spliced content formed according to the second record and subsequent records is written into the target file, the newly created target file can be found and written at the location indicated by the storage path in the record.
[0076] By adopting the file processing method provided in this embodiment, when writing a target file, a new target file can be automatically created in a predetermined storage path, and an already stored target file can be automatically searched in a predetermined storage path, thereby further improving the convenience of file processing.
[0077] Optionally, in one embodiment, before the step of determining whether the Nth path is the same as the N-1th path, the file processing method further includes: recording records with the same file information and path into the same object; the step of determining whether the Nth path is the same as the N-1th path includes: determining whether the Nth record and the N-1th record belong to the same object, wherein, when the Nth record and the N-1th record belong to the same object, the Nth path is the same as the N-1th path, and when the Nth record and the N-1th record do not belong to the same object, the Nth path is different from the N-1th path.
[0078] Specifically, when determining whether the paths in two adjacent records are the same, first aggregate the records according to the file information and path, and record the records corresponding to the same target file and the same path into the same object. Thus, when determining whether the paths in two records are the same, it is only necessary to determine whether the two records belong to the same object.
[0079] Using the file processing method provided in this embodiment, for records corresponding to the same target file, records with the same path are first recorded in the same object. When determining whether the paths in two records are the same, it is only necessary to determine whether the two records are in the same object.
[0080] Optionally, in one embodiment, before the step of determining whether the Nth path is the same as the N-1th path, after recording the records with the same file information and path into the same object, the file processing method further includes: sorting the objects including the same file information in alphabetical order of the path; and when executing the step of determining whether the Nth path is the same as the N-1th path, sequentially obtaining the records in the sorted object for determination.
[0081] Specifically, for objects corresponding to the same target file, they are first sorted in alphabetical order of the path, for example, in the order of letters a to z, or in the order of z to a, or in other orders, which are not limited in this application. Then, when executing the step of determining whether the Nth path is the same as the N-1th path, the records in the sorted objects are sequentially obtained for determination, that is, the first path is the path in the first record of the first-ranked object. If the first-ranked object also includes other records, the second path, the third path, etc. are the paths in other records of the first-ranked object, until all records in the first-ranked object are processed, and then the records in the second-ranked object are processed, and so on.
[0082] By using the file processing method provided by this embodiment, when the order of records in the record file is not set according to the path hierarchy, before obtaining the path judgment in the record, the various objects corresponding to the same target file are first sorted according to the path, which can ensure that when performing the path judgment, the adjacent records are sorted according to the path hierarchy. Further, when it is necessary to add parameters and the values corresponding to the parameters in the target file, it is only necessary to add records to the record file, and the added records can be directly written to the end of the record file. Since the record file will be sorted according to the path during the process of processing the record file into the target file, there is no need to pay attention to the hierarchy of the path of the parameter in the record, which simplifies the modification process of the target file.
[0083] Optionally, in one embodiment, before the step of determining whether the Nth path is the same as the N-1th path, the file processing method further includes: determining whether the file information and parameters in the Nth record are empty; when the file information and / or parameters in the Nth record are empty, discarding the Nth record; when the file information and parameters in the Nth record are not empty, executing the step of determining whether the Nth path is the same as the N-1th path.
[0084] Specifically, before determining whether the Nth path is the same as the N-1th path, we must first determine whether the Nth record is normal. When the file information and / or parameters in the Nth record are empty, the Nth record is discarded and not processed. When the file information and parameters in the Nth record are not empty, they are processed.
[0085] By adopting the file processing method provided in this embodiment, abnormal records in the record file are discarded to avoid affecting the execution of the file processing method when the abnormal records exist in the record file.
[0086] Optionally, in one embodiment, the file information of the target file includes the storage path and file name of the source file corresponding to the target file, and the storage path of the target file is the same as the storage path of the source file; the first column of the record includes the storage path and file name of the source file where the parameter is located, the second column of the record includes the path of the parameter in the source file, the third column of the record is the parameter, the fourth column of the record is the original text corresponding to the parameter in the source file, the fifth column of the record is the translation text corresponding to the original text, and the translation text is the value of the parameter; when the value of the parameter in the Nth record is empty, the original text is used as the value of the parameter; the step of creating a new target file at the location indicated by the storage path in the Nth record includes: creating a new empty file with a first name as the target file at the location indicated by the storage path in the Nth record, wherein the first name includes the file name of the source file and additional characters identifying the language type of the translation text.
[0087] Specifically, the desktop language of the application is language A, and the text in its configuration file is correspondingly in language A. When a desktop in language B is required, the original text in the configuration file of language A needs to be translated into the translated text in language B, that is, a configuration file in language B is provided. The configuration file of language A is defined as a source file, and the target file is a configuration file of language B. In the process of obtaining the target file from the source file, a record file is constructed according to the source file.
[0088] In the record file, the storage path of the source file is used as the storage path of the target file, that is, the configuration files of different languages are set in the same storage location, which reduces the parameter modification of the application desktop display program and facilitates the unified management of the configuration files.
[0089] In addition, the file information of the target file includes not only the storage path of the source file, but also the file name of the source file. Therefore, when a new target file is created, the target file is named according to the file name of the source file, so that the file name of the target file includes the file name of the source file and additional characters that identify the language type of the translated text. On the one hand, the file name can reflect the correlation between configuration files of different languages on the same application desktop. On the other hand, by adding additional characters that identify the language type of the translated text to the file name, the language type of the configuration file can be reflected.
[0090] In a record, the first column includes the storage path and file name of the source file where the parameter is located, the second column includes the path of the parameter in the source file, the third column is the parameter, the fourth column is the original text corresponding to the parameter in the source file, and the fifth column is the translation text corresponding to the original text. Optionally, the record may include multiple key-value pairs, the key of each key-value pair is a parameter, and the value in each key-value pair is a translation text of the original text. For example, the original text is Chinese text, and the record includes three key-value pairs. The value in the first key-value pair is the English text corresponding to the Chinese text, the value in the second key-value pair is the Japanese text corresponding to the Chinese text, and the value in the third key-value pair is the Korean text corresponding to the Chinese text. Correspondingly, in the record, the fifth column is the English text, the sixth column is the Japanese text, and the seventh column is the Korean text. Therefore, when it is necessary to provide desktops in multiple languages, you only need to add a column of text in the corresponding language to the record of the record file to obtain the desktop configuration file of the corresponding language.
[0091] Among them, when the value of a parameter in a record is empty, that is, when the value in a key-value pair is empty, the original text is used as the value of the parameter, which does not affect the normal execution of the file processing method. Moreover, when the desktop is formed, the corresponding original text will be displayed where the translation is displayed, and the program developer will locate the error location through the display results.
[0092] Embodiment 2
[0093] Embodiment 2 of the present invention provides an optimal file processing method, some features and corresponding technical effects of which are the same as those of the above embodiment 1, and reference may be made to the above embodiment 1, which will not be repeated here. In this embodiment, the record file includes records corresponding to parameters of different source files. Through this method, records corresponding to the same source file can be written into the same target file, and records corresponding to different source files can be written into different target files. Specifically, Figure 2 The flowchart of the steps of the file processing method provided in the second embodiment of the present invention is as follows: Figure 2 As shown, the file processing method provided by this embodiment includes the following steps S201 to S209.
[0094] Step S201: Obtain a record file.
[0095] Among them, the record file includes multiple records, the record includes the path of the parameter, the key-value pair and the file information of different target files corresponding to the parameter, the key-value pair includes the parameter and the value of the parameter, and the file information includes the storage path of the target file, wherein the storage path of the target file is the same as the storage path of the source file, that is, the file information of the target file includes the storage path and file name of the source file corresponding to the target file.
[0096] The first column of the record includes the storage path and file name of the source file where the parameter is located, the second column of the record includes the path of the parameter in the source file, the third column of the record is the parameter, the fourth column of the record is the original text corresponding to the parameter in the source file, and the fifth column of the record is the translation text corresponding to the original text, and the translation text is the value of the parameter.
[0097] Step S202: Determine whether the Nth path in the Nth record is the same as the N-1th path in the N-1th record.
[0098] The Nth record is a record in the record file, and the N-1th record is the previous record adjacent to the Nth record. When N=1, all contents in the N-1th record are empty, and the N-1th path is empty.
[0099] If the Nth path is the same as the N-1th path, step S203 is executed; if the Nth path is different from the N-1th path, step S204 is executed.
[0100] Step S203: concatenate the key-value pairs in the Nth record after the first number of hierarchical characteristic characters to generate concatenated content.
[0101] The first number is the product of the number of preset unit-level characteristic characters and the number of levels of the Nth path. When the Nth path is empty, the number of levels of the Nth path is 0.
[0102] After the spliced content is generated, step S208 is executed.
[0103] Step S204: Determine whether the Nth path is empty.
[0104] If the Nth path is empty, step S205 is executed; if the Nth path is not empty, step S206 is executed.
[0105] Step S205: Use the key-value pair as the concatenated content.
[0106] After the spliced content is generated, step S208 is executed.
[0107] Step S206: Determine the different levels in the Nth path and the N-1th path, and concatenate the different levels in ascending order in the following manner: concatenate curPath[i] after the second number of level feature characters, and wrap after concatenating curPath[i].
[0108] Step S207: splicing the key-value pairs at different levels to generate spliced content.
[0109] After the spliced content is generated, step S208 is executed.
[0110] Step S208: When N=1, create a new target file at the location indicated by the path stored in the Nth record, and write the spliced content into the target file; when N>1, search for the target file at the location indicated by the path stored in the Nth record, and write the spliced content into the target file.
[0111] When creating a new target file, an empty file with a first name is created as the target file. The first name includes the file name of the source file and additional characters that identify the language type of the target text.
[0112] Step S209: Determine whether N is less than the number of records in the record file.
[0113] When N is less than the total number of records, N=N+1, and the process returns to step S202, and ends when N is equal to the number of records.
[0114] Embodiment 3
[0115] Embodiment 3 of the present invention provides an optimal method for processing files, some features and corresponding technical effects of which are the same as those of the above embodiment 1, and reference may be made to the above embodiment 1, which will not be repeated here. In this embodiment, the record file includes records corresponding to parameters of different source files. Through this method, the file processing speed can be improved, and it is also helpful to add configurations in the configuration file. Specifically, Figure 3 The flowchart of the steps of the file processing method provided in the third embodiment of the present invention is as follows: Figure 3 As shown, the file processing method provided by this embodiment includes the following steps S301 to S313.
[0116] Step S301: Obtain a record file.
[0117] The record file includes multiple records, each record includes a path of a parameter, a key-value pair, and file information of different target files corresponding to the parameter, and the key-value pair includes a parameter and a value of the parameter.
[0118] Step S302: Records with the same file information and path are recorded in the same object.
[0119] Step S303: sort the objects including the same file information in alphabetical order of the paths.
[0120] Step S304: sequentially obtain the records in the sorted object, and determine whether the file information and parameters in the Nth record are empty.
[0121] When the file information and / or parameters in the Nth record are empty, step S305 is executed; when the file information and parameters in the Nth record are not empty, step S306 is executed.
[0122] Step S305: discard the Nth record.
[0123] After the Nth record is discarded, step S313 is executed.
[0124] Step S306: Determine whether the Nth record and the N-1th record belong to the same object.
[0125] The Nth record is a record in the record file, and the N-1th record is the previous record adjacent to the Nth record. When N=1, all contents in the N-1th record are empty, and the N-1th path is empty.
[0126] When the Nth record and the N-1th record belong to the same object, the Nth path is the same as the N-1th path; when the Nth record and the N-1th record do not belong to the same object, the Nth path is different from the N-1th path.
[0127] If the Nth path is the same as the N-1th path, step S307 is executed; if the Nth path is different from the N-1th path, step S308 is executed.
[0128] Step S307: concatenate the key-value pairs in the Nth record after the first number of hierarchical characteristic characters to generate concatenated content.
[0129] The first number is the product of the number of preset unit-level characteristic characters and the number of levels of the Nth path. When the Nth path is empty, the number of levels of the Nth path is 0.
[0130] After the spliced content is generated, step S312 is executed.
[0131] Step S308: Determine whether the Nth path is empty.
[0132] If the Nth path is empty, step S309 is executed; if the Nth path is not empty, step S310 is executed.
[0133] Step S309: Use the key-value pair as the concatenated content.
[0134] After the spliced content is generated, step S312 is executed.
[0135] Step S310: Determine the different levels in the Nth path and the N-1th path, and concatenate the different levels in ascending order in the following manner: concatenate curPath[i] after the second number of level feature characters, and wrap after concatenating curPath[i].
[0136] Step S311: splicing key-value pairs at different levels to generate spliced content.
[0137] After the spliced content is generated, step S312 is executed.
[0138] Step S312: Write the spliced content into the target file according to the file information in the Nth record.
[0139] Step S313: Determine whether N is less than the number of records in the record file.
[0140] When N is less than the total number of records, N=N+1, and the process returns to step S304, and ends when N is equal to the number of records.
[0141] Embodiment 4
[0142] Embodiment 4 of the present invention provides an optimal method for processing files, some features and corresponding technical effects of which are the same as those of the above embodiment 1, and reference may be made to the above embodiment 1, which will not be repeated here. Specifically, the method for processing files provided in this embodiment includes the following steps:
[0143] Step S1: Construct an excel file with the relevant parameters, Chinese original text, and English translation in the desktop file.
[0144] The excel file is the record file. For example, in one embodiment, the yaml Chinese file format is: (studiesManager.yaml fragment)
[0145] save-succ: The parameters and display of the indicator have been saved.
[0146] Setting:
[0147] leave-tips: You have unsaved settings changes on the current page. Are you sure you want to leave?
[0148] error:
[0149] int-error: Parameter specification: integer: 1-1000.
[0150] sar-error: Parameter specification: (0, 1), precision is two decimal places.
[0151] rsi_err: parameter specification: integer, 0-100
[0152] The resulting Excel file is shown in the following table:
[0153]
[0154] The above excel file contains 5 columns, which are:
[0155] File Name: Contains the path to the file.
[0156] Path: used to identify the level of the copy. When the path is empty, the level is zero. When there are multiple levels, the levels in the path are divided by \.
[0157] Key: custom key, that is, parameter.
[0158] Chinese copy: The Chinese copy corresponding to the parameter.
[0159] English copy: The English copy corresponding to the Chinese copy, the key-value pair is (key: English copy).
[0160] Step S2: read the excel source file, and organize each item (that is, each record) in the excel source file into an object according to the file name.
[0161] Among them, when reading the excel source file, you can use the node-xlsx plug-in to read the excel source file
[0162] const sheet=xlsx.parse('src / convert / convert-en.xlsx')
[0163] Get the format
[0164]
[0165] Each item includes the five fields mentioned above.
[0166] Further, traverse all items and organize each file into object form
[0167]
[0168] Step S3: traverse each file, organize the items in the file into objects according to the hierarchy, and sort them in ascending order of the hierarchy.
[0169] Specifically, traverse each file, organize the hierarchical relationship of the file into an object form, and set the path without hierarchy to the string 'undefined' (for example: studiesManger.yaml file fragment)
[0170]
[0171]
[0172] Step S4: Determine whether the current path is equal to subName.
[0173] In the initial state, subName is empty. If they are equal, execute the following step S5; if they are not equal, execute the following step S6.
[0174] Step S5: Determine whether the current path is empty. If so, do not indent spaces and concatenate the contents. Otherwise, concatenate the contents and update subName to the current path for the next read.
[0175] Step S6: Determine whether the current path is empty. If so, do not indent spaces. Otherwise, compare the differences between the current path and the comparison path to generate intermediate concatenated content.
[0176] Step S7: Update subName to the current path and generate concatenated content.
[0177] Step S8: Execute file writing and determine whether the file name is in the XXXX\XXXX.yaml format. If so, write it to the src / views / xxxx / locales\xxxx.yaml file. If not, write it to the src / views / xxxx / lcales\en.yaml file. After the reading and writing is successful, if reading and writing are still required, return to step S4.
[0178] The final target file is:
[0179]
[0180] In yaml format, the contents of the same level only need to be left-aligned. The above snippet clearly shows the hierarchical relationship.
[0181] Embodiment 5
[0182] Corresponding to the above-mentioned embodiment 1, embodiment 5 of the present invention provides a file processing device, Figure 4 A block diagram of a file processing device provided in Embodiment 2 of the present invention, such as Figure 4As shown, the device includes: an acquisition module 501, a first judgment module 502, a first splicing module 503, a second judgment module 504, a second splicing module 505, a third splicing module 506 and a writing module 507.
[0183] The acquisition module 501 is used to acquire a record file, wherein the record file includes multiple records, the record includes a path and a key-value pair of a parameter, and the key-value pair includes a parameter and a value of the parameter; the first judgment module 502 is used to judge whether the Nth path in the Nth record is the same as the N-1th path in the N-1th record, wherein the Nth record is any record in the record file, and the N-1th record is the previous record adjacent to the Nth record; the first splicing module 503 is used to splice the key-value pair in the Nth record after a first number of hierarchical feature characters when the Nth path is the same as the N-1th path to generate splicing content, wherein the first number is the product of the number of preset unit hierarchical feature characters and the number of levels of the Nth path, and when the Nth path is empty, the number of levels of the Nth path is 0; the second judgment module 50 4 is used to determine whether the Nth path is empty when the Nth path is different from the N-1th path; the second splicing module 505 is used to use the key-value pair as the splicing content when the Nth path is empty; the third splicing module 506 is used to determine the different levels in the Nth path and the N-1th path when the Nth path is not empty, and splice each different level in the order from small to large in the following manner: splice curPath[i] after the second number of level feature characters, and wrap after splicing curPath[i], and splice the key-value pairs after splicing each different level to generate splicing content, wherein the second number is the product of the preset unit level feature character number and i, and curPath[i] is the i-th level of the Nth path; the writing module 507 is used to write the splicing content into the target file.
[0184] Optionally, in an embodiment, the record further includes file information of different target files corresponding to the parameters; the writing module 507 is further configured to write the spliced content into the target file according to the file information in the Nth record.
[0185] Optionally, in one embodiment, when N=1, all contents in the N-1th record are empty; the file information includes the storage path of the target file, and when the writing module 507 writes the spliced content into the target file according to the file information in the Nth record, the specific execution steps include: when N=1, creating a new target file at the location indicated by the storage path in the Nth record, and writing the spliced content into the target file; when N>1, searching for the target file at the location indicated by the storage path in the Nth record, and writing the spliced content into the target file.
[0186] Optionally, in one embodiment, the file processing device also includes: an aggregation module, which is used to record the records with the same file information and path into the same object before the first judgment module determines whether the Nth path is the same as the N-1th path; wherein the first judgment module 502 includes the step of determining whether the Nth path is the same as the N-1th path: determining whether the Nth record and the N-1th record belong to the same object, wherein when the Nth record and the N-1th record belong to the same object, the Nth path is the same as the N-1th path, and when the Nth record and the N-1th record do not belong to the same object, the Nth path is different from the N-1th path.
[0187] Furthermore, the file processing device also includes: a sorting module, which is used to sort the objects including the same file information in alphabetical order of the path after the aggregation module records the records with the same file information and path into the same object before the first judgment module 502 judges whether the Nth path is the same as the N-1th path; wherein, when the first judgment module 502 executes the step of judging whether the Nth path is the same as the N-1th path, it sequentially obtains the records in the sorted object for judgment.
[0188] Furthermore, the file processing device also includes: a third judgment module, used to judge whether the file information and parameters in the Nth record are empty before the first judgment module 502 judges whether the Nth path is the same as the N-1th path; wherein, when the file information and / or parameters in the Nth record are empty, the Nth record is discarded; when the file information and parameters in the Nth record are not empty, the first judgment module 502 judges whether the Nth path is the same as the N-1th path.
[0189] Further, the file information of the target file includes the storage path and file name of the source file corresponding to the target file, and the storage path of the target file is the same as the storage path of the source file; the first column of the record includes the storage path and file name of the source file where the parameter is located, the second column of the record includes the path of the parameter in the source file, the third column of the record is the parameter, the fourth column of the record is the original text corresponding to the parameter in the source file, the fifth column of the record is the translation text corresponding to the original text, and the translation text is the value of the parameter; when the value of the parameter in the Nth record is empty, the original text is used as the value of the parameter; when the writing module 507 creates a new target file at the location indicated by the storage path in the Nth record, the specific steps executed include: creating a new empty file with a first name as the target file at the location indicated by the storage path in the Nth record, wherein the first name includes the file name of the source file and additional characters identifying the language type of the translation text.
[0190] Embodiment 6
[0191] This embodiment also provides a computer device, such as a smart phone, tablet computer, laptop computer, desktop computer, rack server, blade server, tower server or cabinet server (including an independent server or a server cluster composed of multiple servers) that can execute programs. Figure 5 As shown, the computer device 01 of this embodiment includes at least but is not limited to: a memory 011 and a processor 012 which can be interconnected through a system bus. Figure 5 It should be pointed out that Figure 5 Only a computer device 01 having components memory 011 and processor 012 is shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0192] In this embodiment, the memory 011 (i.e., readable storage medium) includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 011 can be an internal storage unit of the computer device 01, such as a hard disk or memory of the computer device 01. In other embodiments, the memory 011 can also be an external storage device of the computer device 01, such as a plug-in hard disk equipped on the computer device 01, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 011 can also include both the internal storage unit of the computer device 01 and its external storage device. In this embodiment, the memory 011 is generally used to store the operating system and various application software installed on the computer device 01, such as the program code of the file processing device of the fifth embodiment. In addition, the memory 011 can also be used to temporarily store various types of data that have been output or are to be output.
[0193] In some embodiments, the processor 012 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 012 is generally used to control the overall operation of the computer device 01. In this embodiment, the processor 012 is used to run the program code stored in the memory 011 or process data, such as a file processing method.
[0194] Embodiment 7
[0195] This embodiment also provides a computer-readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a disk, an optical disk, a server, an App application store, etc., on which a computer program is stored, and the program realizes the corresponding function when executed by the processor. The computer-readable storage medium of this embodiment is used for storing a file processing device, and when executed by the processor, the file processing method of embodiment 1 is realized.
[0196] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0197] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0198] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.
[0199] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for processing a file, characterized in that: include: Obtaining a record file, wherein when desktop language conversion is required, a record in the record file is constructed corresponding to each parameter in the source file, the record file includes a plurality of records, the record includes a path and a key-value pair of the parameter, and the key-value pair includes the parameter and the value of the parameter; Determine whether the Nth path in the Nth record is the same as the N-1th path in the N-1th record, wherein the Nth record is any record in the record file, and the N-1th record is the previous record adjacent to the Nth record; If the Nth path is the same as the N-1th path, concatenate the key-value pairs in the Nth record after a first number of hierarchical characteristic characters to generate concatenated content, wherein the first number is the product of the number of preset unit hierarchical characteristic characters and the number of levels of the Nth path, and when the Nth path is empty, the number of levels of the Nth path is 0; If the Nth path is different from the N-1th path, determining whether the Nth path is empty; If the Nth path is empty, the key-value pair is used as the concatenated content; If the Nth path is not empty, determine the different levels in the Nth path and the N-1 path, and splice each of the different levels in ascending order in the following manner: splice curPath[i] after the second number of level feature characters, and wrap after splicing curPath[i], and splice the key-value pairs after splicing each of the different levels to generate the spliced content, wherein the second number is the product of the number of the preset unit level feature characters and i, and curPath[i] is the i-th level of the Nth path; The spliced content is written into a target file, wherein the hierarchical relationship in the target file is represented by the hierarchical characteristic characters.
2. The method for processing a file according to claim 1, characterized in that: The record also includes file information of different target files corresponding to the parameters; as well as The step of writing the spliced content into a target file includes: writing the spliced content into the target file according to the file information in the Nth record.
3. The method for processing a file according to claim 2, characterized in that: When N=1, all contents in the N-1th record are empty; The file information includes the storage path of the target file, and the step of writing the spliced content into the target file according to the file information in the Nth record includes: When N=1, the target file is newly created at the location indicated by the storage path in the Nth record, and the spliced content is written into the target file; When N>1, the target file is searched at the location indicated by the storage path in the Nth record, and the spliced content is written into the target file.
4. The method for processing a file according to claim 2, characterized in that: Before the step of determining whether the Nth path is the same as the N-1th path, the file processing method further includes: recording the records having the same file information and path into the same object; The step of determining whether the Nth path is the same as the N-1th path includes: determining whether the Nth record and the N-1th record belong to the same object, wherein, when the Nth record and the N-1th record belong to the same object, the Nth path is the same as the N-1th path, and when the Nth record and the N-1th record do not belong to the same object, the Nth path is different from the N-1th path.
5. The method for processing a file according to claim 4, characterized in that: Before the step of determining whether the Nth path is the same as the N-1th path, after recording the records having the same file information and the same path into the same object, the file processing method further comprises: sorting the objects including the same file information in alphabetical order of the paths; When executing the step of determining whether the Nth path is the same as the N-1th path, records in the sorted object are sequentially obtained for determination.
6. The method for processing a file according to claim 2, characterized in that: Before the step of determining whether the Nth path is the same as the N-1th path, the file processing method further includes: Determine whether the file information and the parameters in the Nth record are empty; When the file information and / or the parameter in the Nth record is empty, discarding the Nth record; When the file information and the parameters in the Nth record are not empty, a step of determining whether the Nth path is the same as the N-1th path is performed.
7. The method for processing a file according to claim 3, characterized in that: The file information of the target file includes the storage path and file name of the source file corresponding to the target file, and the storage path of the target file is the same as the storage path of the source file; The first column of the record includes the storage path and file name of the source file where the parameter is located, the second column of the record includes the path of the parameter in the source file, the third column of the record is the parameter, the fourth column of the record is the original text corresponding to the parameter in the source file, the fifth column of the record is the translation text corresponding to the original text, and the translation text is the value of the parameter; When the value of the parameter in the Nth record is empty, the original text is used as the value of the parameter; The step of creating the target file at the location indicated by the storage path in the Nth record includes: creating an empty file with a first name as the target file at the location indicated by the storage path in the Nth record, wherein the first name includes the file name of the source file and additional characters that identify the language type of the target text.
8. A file processing device, characterized in that: include: An acquisition module, used for acquiring a record file, wherein when desktop language conversion is required, a record in the record file is constructed corresponding to each parameter in the source file, the record file includes a plurality of the records, the record includes a path and a key-value pair of the parameter, the key-value pair includes the parameter and the value of the parameter; A first judgment module is used to judge whether the Nth path in the Nth record is the same as the N-1th path in the N-1th record, wherein the Nth record is any record in the record file, and the N-1th record is the previous record adjacent to the Nth record; A first concatenation module is configured to, when the Nth path is the same as the N-1th path, concatenate the key-value pairs in the Nth record after a first number of hierarchical characteristic characters to generate concatenated content, wherein the first number is the product of the number of preset unit hierarchical characteristic characters and the number of levels of the Nth path, and when the Nth path is empty, the number of levels of the Nth path is 0; A second judgment module, configured to judge whether the Nth path is empty when the Nth path is different from the N-1th path; A second splicing module, used for taking the key-value pair as the splicing content when the Nth path is empty; A third splicing module is used for, when the Nth path is not empty, determining different levels in the Nth path and the N-1 path, and splicing each of the different levels in ascending order in the following manner: splicing curPath[i] after a second number of level feature characters, wrapping after splicing curPath[i], and splicing the key-value pairs after splicing each of the different levels to generate the splicing content, wherein the second number is the product of the number of the preset unit level feature characters and i, and curPath[i] is the i-th level of the Nth path; The writing module is used to write the spliced content into a target file, wherein the hierarchical relationship in the target file is represented by the hierarchical characteristic characters.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
