CN-122021671-A - Translation importing method, readable storage medium and electronic equipment
Abstract
The application provides a translation importing method, a readable storage medium and electronic equipment, which are applied to the technical field of software development. When the translation document is determined to be an encrypted document, calling a spreadsheet program through a COM interface to read the translation document so as to obtain a plurality of translation items contained in the translation document, when the translation document is determined to be an unencrypted document, reading the translation document through a file read-write library so as to obtain a plurality of translation items, and then importing the plurality of translation items into N character string resource files. In the method provided by the application, when the translation document is an encrypted document, the electronic form program is called through the COM interface to read the translation document to obtain a plurality of translation items, so that the process of applying for authorization can be avoided, and the convenience in the configuration process of the character string resource file can be improved.
Inventors
- LI XIN
- ZHAO LONG
- Tu Huixun
- LIU LIANGPING
- LUO HAITAO
Assignees
- 长城汽车股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260126
Claims (10)
- 1. A method of importing a translation, the method comprising: determining whether the translated document is an encrypted document; If yes, calling a spreadsheet program through a component object model interface to read the translation document so as to obtain a plurality of translation items included in the translation document; if not, reading the translation document through a file read-write library to obtain a plurality of translation items; and importing the plurality of translation entries into N character string resource files, wherein N is greater than or equal to 1.
- 2. The method of claim 1, wherein the importing the plurality of translation entries into the N string resource files comprises: For each character string resource file, reading a key name and an original character string value in each character string item from the character string resource file by using a regular expression; for each of the string entries, determining a corresponding target string value from the plurality of translation entries based on the key name; And when the original character string value is different from the target character string value, replacing the original character string value in the character string resource file with the target character string value.
- 3. The method of claim 2, wherein prior to said determining a corresponding target string value from the plurality of translation entries based on the key name, the method further comprises: Determining whether a user sets a corresponding key name prefix for the character string resource file in advance; and if the key name prefix is preset for the character string resource file, adding the key name prefix for the key name.
- 4. The method of claim 2, wherein after said replacing the original string value in the string resource file with the target string value, the method further comprises: determining whether the character string value in each character string resource file comprises an unexplained character or not; and if the unexplained character is included, the unexplained character is escaped into an escaped character.
- 5. The method of claim 2, wherein the N string resource files include a first string resource file for a reference language and at least one second string resource file for another language, and wherein after the replacing the original string value in the string resource file with the target string value, the method further comprises: the placeholder in each character string item is obtained from the first character string resource file, so that a first placeholder sequence corresponding to each character string item is obtained; For each second character string resource file, acquiring placeholders in each character string item from the second character string resource file to obtain a second placeholder sequence corresponding to each character string item; And outputting a first detection result aiming at the first placeholder sequence and the second placeholder sequence which correspond to the two character string items with the same key name respectively, wherein the first detection result represents that the placeholders in the two character string items with the same key name are inconsistent when the first placeholder sequence and the second placeholder sequence are different.
- 6. The method of claim 2, wherein the N string resource files include a first string resource file for a reference language and at least one second string resource file for another language, and wherein after the replacing the original string value in the string resource file with the target string value, the method further comprises: Determining whether a plurality of character string entries included in the first character string resource file correspond to a plurality of character string entries included in the second character string resource file one by one for each second character string resource file; If not, outputting a second detection result, wherein the second detection result comprises a character string item, which is missing in the second character string resource file compared with the first character string resource file, or a character string item, which is missing in the first character string resource file compared with the second character string resource file.
- 7. The method of claim 2, wherein after said replacing the original string value in the string resource file with the target string value, the method further comprises: determining whether a preset placeholder exists in each character string resource file; and if the preset placeholder exists, outputting a third detection result comprising the preset placeholder.
- 8. The method of any of claims 1-7, wherein the determining whether the translated document is an encrypted document comprises: if the file header of the translation document does not contain the signature, the translation document is determined to be an encrypted document; Or reading the translation document through the file read-write library, and determining that the translation document is an encrypted document under the condition of failure in reading.
- 9. A readable storage medium, characterized in that executable program code is stored in the readable storage medium, which when run on an electronic device causes the electronic device to perform the method of any one of claims 1 to 8.
- 10. An electronic device, the electronic device comprising: a memory for storing executable program code; a processor for invoking and executing the executable program code from the memory to cause the electronic device to perform the method of any of claims 1-8.
Description
Translation importing method, readable storage medium and electronic equipment Technical Field The present application relates to the field of software development technology, and more particularly, to a translation import method, a readable storage medium, and an electronic device in the field of software development technology. Background In the process of software development, in order to enable the software to be suitable for users with different languages, a plurality of character string resource files are required to be configured for the software, and each character string resource file is used for storing text content in one language visible to the user in the software. In the process of configuring the character string resource file, firstly, a translation document written by a translator needs to be acquired, and then translation items in the translation document are imported into the character string resource file to complete the configuration of the character string resource file. In general, the translation document is an encrypted document, authorization needs to be applied in the process of configuring the character string resource file, and the translation document can be opened after the authorization is obtained. The process of applying for authorization is complicated and takes a certain time, which causes great inconvenience to the configuration process of the character string resource file. Disclosure of Invention The application provides a translation import method, a readable storage medium and an electronic device, the method can improve the convenience in the configuration process of the character string resource file. A first aspect provides a translation importing method, which comprises the steps of determining whether a translation document is an encrypted document, if yes, calling a spreadsheet program to read the translation document through a component object model interface to obtain a plurality of translation items contained in the translation document, if not, reading the translation document through a file read-write library to obtain the plurality of translation items, and importing the plurality of translation items into N character string resource files, wherein N is greater than or equal to 1. In the embodiment of the application, in the translation importing process, when the translation document is determined to be an encrypted document, a spreadsheet program is called through a COM interface to read the translation document so as to obtain a plurality of translation items included in the translation document, when the translation document is determined to be an unencrypted document, the translation document is read through a file read-write library so as to obtain a plurality of translation items, and then the plurality of translation items are imported into N character string resource files. In the method, when the translation document is an encrypted document, the electronic form program is called through the COM interface to read the translation document to obtain a plurality of translation entries, so that the process of applying for authorization can be avoided, and the convenience in the configuration process of the character string resource file can be improved. The method comprises the steps of importing a plurality of translation entries into N character string resource files, wherein each character string resource file comprises a key name and an original character string value in each character string entry, each character string entry comprises a key name and an original character string value, each character string entry comprises a key name, a corresponding target character string value is determined from the plurality of translation entries based on the key name, and when the original character string value is different from the target character string value, the original character string value in the character string resource file is replaced with the target character string value. In the embodiment of the application, the key name and the original character string value are read from the character string resource file by adopting the regular expression, so that the read original character string value can be prevented from being automatically converted and formatted in the reading process. Further, when the word amounts of the target character string value and the original character string value are different, the target character string value is used for replacing the original character string value, so that modification of the character string resource file can be reduced, and the error probability in the translation importing process is reduced. Optionally, before determining the corresponding target character string value from the plurality of translation entries based on the key name, the method further comprises determining whether a corresponding key name prefix is preset for the character string resource file by a user, and adding the key n