Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
Fig. 1 is a schematic flow chart of an implementation of the conversion method for different languages according to the embodiment of the present invention, which is described in detail as follows.
And step S101, extracting the entry to be converted in the application software code.
The entry to be converted is the entry expressed by the first language.
At present, if the application software needs to be internationalized, when an application software code is developed, a part to be internationalized in the application software code needs to be represented by a feature code key value, and the application software code doped with the key value has poor readability and also increases the volume of the code. Moreover, the application software code is generally developed by a plurality of developers, each developer may have different key values defined for the same entry to be converted, and when all entries to be converted in the application software code are summarized, a certain entry to be converted may be left.
The embodiment may directly extract the entry to be converted in the application software code, that is, by using the method of the embodiment, if the application software needs to implement internationalization, the entry to be converted in the first language may be directly used for development when the application software code is developed, for example, for a part of the application software code that needs internationalization, the part of the application software code that needs internationalization may be directly developed in chinese, or for a user whose native language is english, the part of the application software code may be directly developed in english, and after the development is completed, the entry to be converted in the application software code that is represented by the first language is extracted. On the other hand, after the development is completed, the entry to be converted, which is expressed by the first language in the application software code, is extracted, so that omission of the entry to be converted can be avoided, and the success rate of the application software in conversion between different languages is improved.
Optionally, the entry to be converted in the application software code may be automatically extracted through a script.
And S102, automatically generating a feature code uniquely corresponding to each entry to be converted according to the entry to be converted.
The key value of the feature code is a mark of the same entry in different languages, and if the application software needs to be internationalized, that is, the entry to be converted in the application software code needs to be used for multiple languages, the feature code of the entry to be converted needs to be acquired.
Optionally, automatically generating, according to the entry to be converted, the feature code uniquely corresponding to each entry to be converted, which may include: and respectively calculating the unique corresponding feature codes of each entry to be converted by adopting an encryption algorithm according to the entries to be converted.
The encryption process is a process of processing a file which is originally in a plaintext according to a certain algorithm to make the file become an unreadable code. In the embodiment, each entry to be converted is calculated by adopting an encryption algorithm, so that an encryption code uniquely corresponding to each entry to be converted can be obtained, the encryption code uniquely corresponding to each entry to be converted is used as a feature code corresponding to each entry to be converted, different feature codes can be prevented from being generated for the same entry to be converted, the feature code uniquely corresponding to each entry to be converted is automatically generated based on the encryption algorithm, and the accuracy of conversion of different languages is improved when the feature codes are used for conversion of different languages.
Alternatively, the encryption algorithm may be the MD5 algorithm.
In this embodiment, the MD5 algorithm is used to calculate the unique feature code corresponding to each entry to be converted, and because the MD5 code of the same entry is unique, for a certain company, it can be ensured that the key values of the feature codes corresponding to the entries generated by each product in the company are uniform, so that multiple products can use the same set of translation library.
Optionally, after automatically generating a feature code uniquely corresponding to each entry to be converted according to the entry to be converted, the method may further include: and replacing the corresponding entry to be converted in the application software code by using each feature code.
In this embodiment, the entry to be converted in the application software code may be automatically extracted through the script, the feature code corresponding to each entry to be converted is calculated based on the MD3 algorithm, when compiling, each feature code may be used to replace the corresponding entry to be converted in the application software code, and based on the replaced application software code, the conversion of the application software between different languages may be implemented.
Optionally, after automatically generating a feature code uniquely corresponding to each entry to be converted according to the entry to be converted, the method may further include: and generating a first format packet based on the first language according to each entry to be converted and the unique corresponding feature code of each entry to be converted.
In this embodiment, after the entry to be converted in the application software code is extracted and the feature code uniquely corresponding to each entry to be converted is automatically generated according to the entry to be converted, the first format package based on the first language is generated according to each entry to be converted and the feature code uniquely corresponding to each entry to be converted. I.e., to generate a language package in a first language to provide for the application to convert between different languages.
Optionally, according to each entry to be converted and the feature code uniquely corresponding to each entry to be converted, a first format package based on the first language may be formed by a js script tool.
Step S103, obtaining a target entry corresponding to each entry to be converted.
The target entry is an entry expressed by a second language different from the first language.
The target entry corresponding to each entry to be converted can be obtained by translating all entries to be converted in the document in the table form by a translator through converting the first format packet based on the first language into the document in the table form.
And step S104, acquiring the unique corresponding relation between the target entry and the feature code based on each entry to be converted, and converting the entry to be converted based on the first language into the target entry based on the second language according to the feature code and the corresponding relation when receiving the front-end language conversion request.
Optionally, after obtaining the unique corresponding relationship between the target entry and the feature code based on each entry to be converted, the method may further include: and generating a second format package based on the second language, wherein the second format package comprises the target entry, the feature codes and the corresponding relation between the target entry and the feature codes.
In this embodiment, since the feature code corresponding to each entry to be converted and the target entry corresponding to each entry to be converted are obtained, the corresponding relationship between the feature code and the target entry may be obtained based on each entry to be converted. When a language conversion request which is sent by a front end and is converted from a first language to a second language is received, according to a first format packet based on the first language and a second format packet based on the second language, a feature code key value corresponding to each entry to be converted can be searched through the first format packet, according to the feature code key value, a corresponding target entry can be searched in the second format packet, and then the conversion of the application software from the first language to the second language is completed.
According to the conversion method of different languages, the entry to be converted in the application software code is extracted, the feature code uniquely corresponding to each entry to be converted is automatically generated according to the entry to be converted, the entry to be converted in the application software code can be prevented from being omitted, the success rate of conversion of the application software among different languages is improved, each entry to be converted is guaranteed to have only one uniquely corresponding feature code, and further, the unique corresponding relation between the target entry and the feature codes can be obtained on the basis of each entry to be converted, so that when a language conversion request is received, the entry to be converted expressed by the first language can be uniquely converted into the target entry expressed by the second language according to the feature codes and the corresponding relation, and the accuracy of the application software in conversion of different languages is improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
The following are embodiments of the apparatus of the invention, reference being made to the corresponding method embodiments described above for details which are not described in detail therein.
Fig. 2 shows an exemplary diagram of a conversion apparatus for different languages provided by an embodiment of the present invention, corresponding to the conversion method for different languages described in the above embodiments. As shown in fig. 2, the apparatus may include: anextraction module 21, afirst conversion module 22, anacquisition module 23 and asecond conversion module 24.
Theextraction module 21 is configured to extract an entry to be converted in an application software code, where the entry to be converted is an entry expressed in a first language;
thefirst conversion module 22 is configured to automatically generate a feature code uniquely corresponding to each entry to be converted according to the entry to be converted;
an obtainingmodule 23, configured to obtain a target entry corresponding to each entry to be converted, where the target entry is an entry represented in a second language different from the first language;
and asecond conversion module 24, configured to obtain a unique corresponding relationship between the target entry and the feature code based on each entry to be converted, so as to convert, when a front-end language conversion request is received, the entry to be converted based on the first language into the target entry based on the second language according to the feature code and the corresponding relationship.
Optionally, thefirst conversion module 22 is configured to calculate, according to the entry to be converted, a unique feature code corresponding to each entry to be converted by using an encryption algorithm.
Optionally, the encryption algorithm is an MD5 algorithm.
Optionally, thefirst conversion module 22 is further configured to replace, by using each feature code, a corresponding entry to be converted in the application software code.
Optionally, thefirst conversion module 22 is further configured to generate a first format packet based on the first language according to each entry to be converted and the feature code uniquely corresponding to each entry to be converted.
Optionally, thesecond conversion module 24 is further configured to generate a second format package based on the second language, where the second format package includes the target entry, the feature code, and a corresponding relationship between the target entry and the feature code.
According to the conversion device for different languages, the entry to be converted in the application software code is extracted, the feature code uniquely corresponding to each entry to be converted is automatically generated according to the entry to be converted, the entry to be converted in the application software code can be prevented from being omitted, the success rate of conversion of the application software between different languages is improved, each entry to be converted is guaranteed to have only one uniquely corresponding feature code, and then the unique corresponding relation between the target entry and the feature codes can be obtained based on each entry to be converted, so that when a language conversion request is received, the entry to be converted represented by the first language can be uniquely converted into the target entry represented by the second language according to the feature codes and the corresponding relation, and the accuracy of the application software during conversion between different languages is improved.
Fig. 3 is a schematic diagram of a terminal device according to an embodiment of the present invention. As shown in fig. 3, theterminal device 300 of this embodiment includes: aprocessor 301, amemory 302 and acomputer program 303 stored in saidmemory 302 and being executable on saidprocessor 301, such as a translation program for different languages. Theprocessor 301 executes thecomputer program 303 to implement the steps in the embodiment of the conversion method of different languages, such as steps S101 to 104 shown in fig. 1, and theprocessor 301 executes thecomputer program 303 to implement the functions of the modules in the embodiments of the apparatuses, such as themodules 21 to 24 shown in fig. 2.
Illustratively, thecomputer program 303 may be divided into one or more program modules that are stored in thememory 302 and executed by theprocessor 301 to implement the present invention. The one or more program modules may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of thecomputer program 303 in the conversion device of the different languages or theterminal device 300. For example, thecomputer program 303 may be divided into an extractingmodule 21, a first convertingmodule 22, an obtainingmodule 23, and a second convertingmodule 24, and specific functions of the modules are shown in fig. 2, which is not described herein again.
Theterminal device 300 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, aprocessor 301, amemory 302. Those skilled in the art will appreciate that fig. 3 is merely an example of aterminal device 300 and does not constitute a limitation ofterminal device 300 and may include more or fewer components than shown, or some components may be combined, or different components, for example, the terminal device may also include input output devices, network access devices, buses, etc.
TheProcessor 301 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Thememory 302 may be an internal storage unit of theterminal device 300, such as a hard disk or a memory of theterminal device 300. Thememory 302 may also be an external storage device of theterminal device 300, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on theterminal device 300. Further, thememory 302 may also include both an internal storage unit and an external storage device of theterminal device 300. Thememory 302 is used for storing the computer programs and other programs and data required by theterminal device 300. Thememory 302 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.