Method, apparatus and related components for generating and checking display effects in multiple languages
By analyzing and filtering table files in multiple languages and generating and displaying the longest translated copy, the problems of complex multilingual adaptation process and incomplete copy display of software are solved, and rapid testing and efficient manpower utilization are achieved.
Patent Information
- Application Number
- CN202210087816.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-25
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2042-01-25
AI Technical Summary
The existing software is complicated when adapting to multiple languages, and cannot effectively solve the problem of excessively long and incomplete display of language copywriting, which causes testers to manually switch languages for confirmation, which consumes a lot of time and human resources.
By reading and parsing table files, converting them into copy files in a specified format, filtering out the longest translated copy for each key value, and building a copy collection for display through the interface to achieve rapid testing and problem positioning.
It effectively solves the problem of multilingual adaptation requiring more manpower and excessively long language copywriting display, reduces repeated operations and time waste for testers, and improves efficiency.
Smart Images

Figure CN114792100B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software applications, and in particular, to a method, device, and related components for generating and checking the display effects of multiple languages. Background Art
[0002] Currently, when a software needs to be adapted to multiple languages, it is necessary to process the format of the translation table file for each language in order to convert the translation table file into a string file that can be used by the program. And testers need to ensure that each piece of copywriting in each language can be completely displayed on the interface. The traditional method requires testers to manually switch each language and view each interface for confirmation, which consumes a large amount of time for repeated operations and causes inevitable waste of human resources. Summary of the Invention
[0003] The object of the present invention is to provide a method, device, and related components for generating and checking the display effects of multiple languages, aiming to solve the problem that the process of adapting existing software to multiple languages is relatively complex and the problem that long language copywriting cannot be fully displayed.
[0004] To solve the above technical problems, the object of the present invention is achieved through the following technical solutions: Provide a method for generating and checking the display effects of multiple languages, which includes:
[0005] Based on the path of the input table file, read and parse the table file to convert the table file into a copywriting file in a specified format, where the table file includes key values and corresponding translation versions, and the translation versions are composed of translation copywritings in different languages;
[0006] Read all the key values in the copywriting file, obtain the translation version corresponding to each key value, and screen all the translation copywritings in each translation version to obtain the target translation copywriting with the longest length;
[0007] Construct a copywriting set composed of the target translation copywriting and the corresponding key value, and perform directory assembly on the copywriting set and the copywriting file and export them to the target path to display each target translation copywriting through the interface.
[0008] In addition, the technical problem to be solved by the present invention is also to provide a device for generating and checking the display effects of multiple languages, which includes:
[0009] A conversion unit, configured to read and parse the table file based on the path of the input table file to convert the table file into a copywriting file in a specified format, where the table file includes key values and corresponding translation versions, and the translation versions are composed of translation copywritings in different languages;
[0010] A screening unit, configured to read all key values in the copywriting file, obtain the corresponding translation versions of each key value, and screen all the translated copywriting in each translation version to obtain a target translated copywriting with the longest length.
[0011] A display unit, configured to construct a copywriting set composed of the target translated copywriting and the corresponding key values, perform directory assembly on the copywriting set and the copywriting file, and export them to a target path, so as to display each target translated copywriting through an interface.
[0012] In addition, an embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the method for generating and checking the display effects of multiple languages described in the above first aspect is implemented.
[0013] In addition, an embodiment of the present invention further provides a computer-readable storage medium, in which the computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the processor is caused to execute the method for generating and checking the display effects of multiple languages described in the above first aspect.
[0014] An embodiment of the present invention discloses a method, device and related components for generating and checking the display effects of multiple languages. The method includes: based on the path of an input table file, reading and parsing the table file to convert the table file into a copywriting file in a specified format, where the table file includes key values and corresponding translation versions, and the translation versions are composed of translated copywriting in different languages; reading all key values in the copywriting file, obtaining the corresponding translation versions of each key value, and screening all the translated copywriting in each translation version to obtain a target translated copywriting with the longest length; constructing a copywriting set composed of the target translated copywriting and the corresponding key values, performing directory assembly on the copywriting set and the copywriting file, and exporting them to a target path, so as to display each target translated copywriting through an interface. This method can effectively solve the problems of requiring a large amount of manpower for multi-language adaptation of developed software and incomplete display of long language copywriting during software development. Description of the Drawings
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for description in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0016] Figure 1Schematic flowchart of the method for generating and checking the display effects of multiple languages provided by the embodiments of the present invention;
[0017] Figure 2 Schematic structural diagram of a class in the method for generating and checking the display effects of multiple languages provided by the embodiments of the present invention;
[0018] Figure 3 Schematic block diagram of the device for generating and checking the display effects of multiple languages provided by the embodiments of the present invention;
[0019] Figure 4 Schematic block diagram of the computer device provided by the embodiments of the present invention. Detailed implementation manners
[0020] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0021] It should be understood that when used in this specification and the appended claims, the terms "comprises" and "comprising" indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0022] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in this specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" are intended to include the plural forms.
[0023] It should be further understood that the term " / and / " used in this specification of the present invention and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0024] Please refer to Figure 1 , Figure 1 Schematic flowchart of the method for generating and checking the display effects of multiple languages provided by the embodiments of the present invention;
[0025] As Figure 1 shown, the method includes steps S101 to S103.
[0026] S101. Based on the path of the input table file, read and parse the table file to convert the table file into a copywriting file in a specified format. The table file includes key values and corresponding translation versions, and the translation versions are composed of translation copywritings in different languages.
[0027] S102. Read all the key values in the copywriting file, obtain the corresponding translation versions for each key value, and screen all the translation copywritings in each translation version to obtain the target translation copywriting with the longest length.
[0028] S103. Construct a copywriting set composed of the target translation copywriting and the corresponding key values, and perform directory assembly on the copywriting set and the copywriting file and export them to the target path to display each target translation copywriting through the interface.
[0029] For example, the key values are 1, 2, 3, 4, and the translation copywriting in Chinese is: "one, two, three, four". After being translated into English, it is: "one, two, three, four". It can be found that the interface sizes occupied by the translation copywritings translated into two different languages may be different. Similarly, after being translated into French and German, the lengths of the translation copywritings may also be different. In the traditional method, testers can only manually switch the languages of multiple countries to observe whether the translation copywritings can be completely displayed on the software interface. For example, when there are 100 languages to be adapted and there are many software interfaces, the testing workload is very large, which will cause testers to perform repeated operations, wasting time and labor costs.
[0030] In this embodiment, first input the path of the table file into the software program. The table file contains all the key values and all the translation versions. For example, each column represents a language, and each row represents all the translation versions of a key value. The content at the intersection of each row and each column is the translation copywriting in different languages. Specifically, for example, the first column is Chinese, the second column is English, and the third column is French. The key value in the second row is "good". That is to say, the content of each row is "different translation versions of the copywriting displayed in the same position". That is, the translation versions corresponding to the key value "good" in the second row include Chinese translation copywriting, English translation copywriting, French translation copywriting, and so on.
[0031] Then, based on the input path, read and parse the table file, convert the table file into a copywriting file, then read the key values in the copywriting file, and obtain all translation versions corresponding to the key values. For example, when reading a line of copywriting, obtain the key value of this line of copywriting, such as "good", and then find the Chinese, English, French, etc. expressions of "good". Then compare the lengths of the Chinese translation copywriting, English translation copywriting, French translation copywriting, etc. of "good", and find the target translation copywriting with the longest length among the translation versions. Aggregate the copywriting file and the copywriting set obtained in the previous step in a directory and export them to the target path of the user. At this time, the copywriting file can display the longest language translation version of each copywriting through the interface, achieving the purpose of rapid testing and rapid problem positioning, so as to effectively solve the problems of requiring a lot of manpower for multi-language adaptation of software development and incomplete display of long language copywriting when developing software.
[0032] In a specific embodiment, step S101 includes the following steps:
[0033] S10. Based on the path of the input table file, read the table file;
[0034] S11. Obtain the language categories of the translation versions in the table file and generate corresponding language key values;
[0035] S12. Create an object of a class, and based on the language key value, store different translation copywriting in the translation version separately;
[0036] S13. Add the object of the class to the target array, and pass the target array to the target class, so that the target class reads the translation copywriting in the elements of the target array and converts the translation copywriting into a corresponding string;
[0037] S14. Based on the language key value, classify and store the converted strings by language category to obtain a corresponding copywriting file in strings format.
[0038] In this embodiment, the first row of the table file is read to find out how many categories of languages are included in the table file, and the corresponding language key values are generated. For example, the Chinese key value is zh, the English key value is en, and so on. Then, starting from the second row of the table file, the content of each row is read sequentially, that is, each translation copywriting. Based on each row, an object of a class (rowItem) is created. Using the generated language key values as a distinction, different translation versions of "the translation copywriting displayed at the same position on the software" are stored, and then the generated object of the class is added to an array, and the generated array is returned to the target class. Here, the target class is used to specifically process the array carrying the copywriting information. This application does not make specific limitations on the target class, and the corresponding target class can be selected according to the actual situation.
[0039] The target class reads each element of the array in sequence. It should be noted that one element is equivalent to one row in the table file. The possible types of this element are the following three. The first type: annotation information, which serves as a note. The second type: translation information, that is, the translation copywriting. The third type: other information, which is required for other functions. Since the other information has no specific association with this application, it will not be described. During the process of the target class reading each element in sequence, the translation copywriting is converted into a string. Specifically, the translation copywriting is converted into the format of "key" = "copywriting", and is stored in different objects according to different languages, and is displayed on the interface in the strings format.
[0040] At this time, a copywriting table changes from the table format to an array stored in the computer. However, this application divides multiple files by language categories, that is, the format of each row of the file is "key" = "copywriting", and a semicolon is used at the end of each row to obtain a file in the strings format.
[0041] In a specific embodiment, after the step S14, the following steps are included:
[0042] S15. Use the multi-language copywriting project to convert the copywriting file into an executable file adapted to multiple languages and output it;
[0043] S16. Obtain the path string of the executable file, and splice the target path string after the path string of the executable file to query all the copywriting files in the executable file.
[0044] After step S14, the text files (strings format files) in different languages parsed in the previous step are manually imported into the project that needs to adapt to multilingual texts, so that the text files and the development project form a set. This set as a whole is a semi-finished software that can change with the system language. Here, the project refers to a collection of a series of codes and code libraries for developing software, and the project generates software through compilation; in this application, the project converts the text file into an executable file adapted to multiple languages. It should be noted that the inside of the executable file is a series of codes and resource files, which is equivalent to a package containing multilingual translation texts; input the path of the executable file into the software program to obtain the path string of the executable file, and splice the target string in the path string of the executable file. In this application, the target string is the position of the text file in the executable file, and the following strings are commonly used: %@ / Contents / Resources / %@.lproj / %@ or %@ / Resources / %@.lproj / %@, where %@ is different strings parsed for different projects; through this operation, the text file in the executable file can be found.
[0045] More specifically, each language is integrated in a multilingual text file (strings format file). In the program, it is the stringFileItem class, and each line in the text file corresponds to the stringRowItem class. Each line in the text file and the text file have an n-to-1 aggregation relationship, and the text file may contain other information lines such as comments. This application only processes the lines that meet the format requirements. The TranslationItem corresponds to the line with translation content in the file (corresponding to the line that meets the format requirements in the text file). The combination relationship between the classes is as Figure 2 shown.
[0046] In a specific embodiment, the step of reading all the key values in the text file in step S102 and obtaining the translation version corresponding to each key value includes the following steps:
[0047] S20. After querying to obtain all the text files, sequentially read the translation texts in each text file and give the translation texts to obtain the corresponding key values;
[0048] S21. Based on the key values, obtain all the corresponding translation texts.
[0049] Since the location of the multi-language copy files is located in step S16, all copy files are obtained through step S102. Each language corresponds to a copy file, and the content in each file is composed of a string in the format of {"key"="value";}. When each line of copy is read sequentially, the key value on the left side of the line of copy is obtained, and this is used as a clue to find all the translation copies of the copy. For example, when a line of content {"hello"="你好";} is read, the key value hello on the left side is taken out, and based on the key value hello, the French, Korean, etc. translation copies corresponding to hello are found.
[0050] In a specific embodiment, the step S102 of screening all the translation texts in each of the translation versions to obtain the target translation text with the longest length includes the following steps:
[0051] S22, traversing each translation copy, comparing the text length of the previous translation copy with the current translation copy, and retaining the translation copy with the longer text length;
[0052] S23, the retained translation copy is continuously compared with the next translation copy, until it is compared with the last translation copy, and the translation copy finally retained is used as the target translation copy.
[0053] By comparing two by two, the longest target translation copy among all translation copies corresponding to the same key value is found.
[0054] In a specific embodiment, the step S103 of constructing a document set consisting of the target translation document and the corresponding key value includes the following steps:
[0055] Each target translation document and the corresponding key value are aggregated in the format of "key value" = "target translation document" to obtain a corresponding document set.
[0056] After obtaining the target translation copy, it is aggregated with the corresponding key value to obtain a corrected copy file. For example, if the longest language corresponding to the key value hello is French, it is spelled as {"hello"="boujour";}; if the longest language corresponding to the key value "i love you" is Russian, it is spelled as {"i love you"="Я т е б я л ю б л ю";}. All such lines are concatenated into a copy file, which is the aggregation processing described in this application.
[0057] It is worth noting that compared to the system method that relies on developers to manually adjust the input file format, the format needs to meet certain requirements to run normally. If the format of a text table file has a line that does not meet the specifications, the corresponding generated text fixed format file cannot be displayed correctly in the program and needs to be manually modified to the standard format. The method provided in this application does not require manual input of the file format, and even if there is a problem with the specifications of one of the lines, it will not affect the display of other lines.
[0058] The embodiment of the present invention also provides a device for generating and checking display effects in multiple languages, and the device for generating and checking display effects in multiple languages is used to execute any embodiment of the method for generating and checking display effects in multiple languages. Figure 3 , Figure 3 It is a schematic block diagram of an apparatus for generating and checking display effects in multiple languages provided by an embodiment of the present invention.
[0059] As Figure 3 As shown, the device 500 for generating and checking the display effect of multiple languages includes:
[0060] The conversion unit 501 is used to read and parse the table file based on the path of the input table file to convert the table file into a text file of a specified format, wherein the table file includes key values and corresponding translation versions, and the translation versions are composed of translation texts in different languages;
[0061] A screening unit 502 is used to read all key values in the text file, obtain the translation version corresponding to each key value, and screen all the translation texts in each translation version to obtain the target translation text with the longest length;
[0062] The display unit 503 is used to construct a document set consisting of the target translation documents and the corresponding key values, and to assemble the document set and the document files into directories and export them to a target path, so as to display each target translation document through an interface.
[0063] The text files in the device can display the longest language translation version of each text through the interface, so as to achieve the purpose of rapid testing and rapid problem location, thereby effectively solving the problem of requiring more manpower for multi-language adaptation of software development and the problem of incomplete display of language texts that are too long when developing software.
[0064] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0065] The above device for generating and checking the display effects in multiple languages can be implemented in the form of a computer program, which can run on a computer device as shown in Figure 4 .
[0066] Please refer to Figure 4 . Figure 4 FIG. is a schematic block diagram of a computer device provided by an embodiment of the present invention. The computer device 1100 is a server, and the server can be an independent server or a server cluster composed of multiple servers.
[0067] Referring to Figure 4 , the computer device 1100 includes a processor 1102, a memory, and a network interface 1105 connected through a system bus 1101. Among them, the memory may include a non-volatile storage medium 1103 and an internal memory 1104.
[0068] The non-volatile storage medium 1103 can store an operating system 11031 and a computer program 11032. When the computer program 11032 is executed, the processor 1102 can be caused to execute a method for generating and checking the display effects in multiple languages.
[0069] The processor 1102 is used to provide computing and control capabilities to support the operation of the entire computer device 1100.
[0070] The internal memory 1104 provides an environment for the operation of the computer program 11032 in the non-volatile storage medium 1103. When the computer program 11032 is executed by the processor 1102, the processor 1102 can be caused to execute a method for generating and checking the display effects in multiple languages.
[0071] The network interface 1105 is used for network communication, such as providing the transmission of data information, etc. Those skilled in the art can understand that Figure 4 the structure shown in is only a block diagram of some structures related to the solution of the present invention, and does not constitute a limitation on the computer device 1100 to which the solution of the present invention is applied. The specific computer device 1100 may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0072] Those skilled in the art can understand that Figure 4 the embodiment of the computer device shown in does not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements. For example, in some embodiments, the computer device may only include a memory and a processor. In such an embodiment, the structures and functions of the memory and the processor are the same as those in Figure 4It is the same as the illustrated embodiment and will not be described herein again.
[0073] It should be understood that in the embodiment of the present invention, the processor 1102 may be a central processing unit (CPU), and the processor 1102 may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0074] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the method for generating and checking the display effects of multiple languages in the embodiment of the present invention.
[0075] The storage medium is a physical, non-transitory storage medium, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disc, etc., which are all physical storage media that can store program codes.
[0076] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the above-described devices, apparatuses, and units can refer to the corresponding processes in the foregoing method embodiments and will not be described herein again.
[0077] The above is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or substitutions within the technical scope disclosed by the present invention, and these modifications or substitutions should all be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. A method for generating and checking the display effect of multiple languages, characterized in that, Including: Based on the path of the input table file, read and parse the table file to convert the table file into a text file in a specified format, where the table file includes key values and corresponding translation versions, and the translation versions are composed of translation texts in different languages; Read all the key values in the text file, obtain the translation version corresponding to each key value, and screen all the translation texts in each translation version to obtain the target translation text with the longest length; Construct a text collection composed of the target translation text and the corresponding key value, and perform directory assembly on the text collection and the text file and export them to the target path to display each target translation text through the interface; The step of, based on the path of the input table file, reading and parsing the table file to convert the table file into a text file in a specified format includes: based on the path of the input table file, reading the table file; obtaining the language category of the translation version in the table file and generating a corresponding language key value; creating an object of a class, and based on the language key value, storing different translation texts in the translation version separately; adding the object of the class to the target array, and passing the target array to the target class, so that the target class reads the translation texts in the elements of the target array and converts the translation texts into corresponding strings; based on the language key value, storing the converted strings by language category to obtain a corresponding text file in strings format.
2. The method for generating and checking the display effect of multiple languages according to claim 1, characterized in that After the step of, based on the language key value, storing the converted strings by language category to obtain a corresponding text file in strings format, includes: Using the project of multilingual texts to convert the text file into an executable file adapted to multiple languages and output; Obtain the path string of the executable file, and splice the target path string after the path string of the executable file to query all the text files in the executable file.
3. The method for generating and checking the display effect of multiple languages according to claim 2, characterized in that, The step of, reading all the key values in the text file and obtaining the translation version corresponding to each key value, includes: After querying all the text files, sequentially read the translation texts in each text file, and given the translation texts, obtain the corresponding key values; Based on the key values, obtain all the corresponding translation texts.
4. The method for generating and checking the display effect of multiple languages according to claim 1, characterized in that The step of, screening all the translation texts in each translation version to obtain the target translation text with the longest length, includes: Traverse each translation text, compare the length of the previous translation text with the current translation text, and retain the translation text with the longer length; Continue to compare the retained translation text with the next translation text until comparing with the last translation text, and the finally retained translation text is the target translation text.
5. The method for generating and checking the display effect of multiple languages according to claim 1, wherein The step of, constructing a text collection composed of the target translation text and the corresponding key value, includes: Aggregate each of the target translation copies and the corresponding key values in the format of "key value" = "target translation copy" to obtain the corresponding copy set.
6. The method for generating and checking the display effect of multiple languages according to claim 1, wherein The elements include annotation information and translation copies.
7. An apparatus for generating and checking the display effect of multiple languages, characterized in that, Comprising: A conversion unit for reading and parsing the table file based on the path of the input table file to convert the table file into a copy file in a specified format, where the table file includes key values and corresponding translation versions, and the translation versions are composed of translation copies in different languages; A screening unit for reading all the key values in the copy file, obtaining the translation versions corresponding to each key value, and screening all the translation copies in each translation version to obtain the target translation copy with the longest length; A display unit for constructing a copy set composed of the target translation copy and the corresponding key value, and performing directory assembly on the copy set and the copy file and exporting them to a target path to display each target translation copy through an interface; The conversion unit is further configured to read the table file based on the path of the input table file; obtain the language category of the translation version in the table file and generate a corresponding language key value; create an object of a class, and based on the language key value, distinguish and store different translation copies in the translation version; add the object of the class to a target array, and pass the target array to a target class, so that the target class reads the translation copies in the elements of the target array and converts the translation copies into corresponding strings; based on the language key value, classify and store the converted strings by language category to obtain a corresponding copy file in the strings format.
8. A computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method for generating and checking the display effect of multiple languages as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor is caused to execute the method for generating and checking the display effect of multiple languages as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Software system multi-language adaptation method, device and equipment and readable storage medium
CN110554893A
WPF interface switching method and device, computer equipment and storage medium
CN113590123A