CN107402746B - Method and device for automatically generating code file - Google Patents

Method and device for automatically generating code file Download PDF

Info

Publication number
CN107402746B
CN107402746B CN201610341016.8A CN201610341016A CN107402746B CN 107402746 B CN107402746 B CN 107402746B CN 201610341016 A CN201610341016 A CN 201610341016A CN 107402746 B CN107402746 B CN 107402746B
Authority
CN
China
Prior art keywords
language
file
language text
code file
variable name
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610341016.8A
Other languages
Chinese (zh)
Other versions
CN107402746A (en
Inventor
何文俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201610341016.8A priority Critical patent/CN107402746B/en
Publication of CN107402746A publication Critical patent/CN107402746A/en
Application granted granted Critical
Publication of CN107402746B publication Critical patent/CN107402746B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/22Procedural

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Machine Translation (AREA)
  • Stored Programmes (AREA)

Abstract

The application provides a method and a device for automatically generating a code file. The method comprises the following steps: traversing the first code file, and searching a plurality of first language texts in the first code file; replacing a plurality of first language texts with variable names corresponding to the first language texts; generating a first language file based on the corresponding relation between the variable name and the first language text; translating the first language text in the first language file into a second language text to generate a second language file, wherein the second language file comprises the corresponding relation between the second language text and a variable name; and replacing the variable name in the first code file with the corresponding second language text based on the second language file to generate a second code file. The scheme for automatically generating the code file is provided for the multi-language requirements of the front end, the multi-language requirements are well stripped from development work, so that developers only need to pay attention to function implementation, the working strength of the developers is greatly reduced, and the working efficiency is improved.

Description

Method and device for automatically generating code file
Technical Field
The present application belongs to the field of information processing technologies, and in particular, to a method and an apparatus for automatically generating a code file.
Background
In the development of project files, multi-language requirements are often met, generally, developers organize the file information in advance before developing and coding, define aliases for each piece of text information, and replace all the aliases once the text information appears in the development process. However, the above solution may burden developers, for example, the developers need to define aliases for each piece of text information, and the definition and lookup of the aliases will accompany the whole development process.
Aiming at the problem of large burden of a multi-language translation scheme in traditional project file development, an effective solution is not provided at present.
Disclosure of Invention
The application aims to provide a method and a device for automatically generating a code file, so that a developer can directly fill in a single language (such as Chinese) at a character display position like developing a project of the single language without considering the problems of later-stage replacement translation and the like, the working strength of the developer is greatly reduced, and the working efficiency is improved.
The application provides a method and a device for automatically generating a code file, which are realized as follows:
a method of automatically generating a code file, the method comprising: traversing the first code file, and searching a plurality of first language texts in the first code file; replacing the plurality of first language texts with variable names corresponding to the first language texts; generating a first language file based on the corresponding relation between the variable name and the first language text; translating the first language text in the first language file into a second language text to generate a second language file, wherein the second language file comprises the corresponding relation between the second language text and the variable name; replacing the variable name in the first code file with a corresponding second language text based on the second language file to generate a second code file.
An apparatus for automatically generating a code file, the apparatus comprising: the searching unit is used for traversing the first code file and searching a plurality of first language texts in the first code file; the first replacing unit is used for replacing the plurality of first language texts with variable names corresponding to the first language texts; the file generating unit is used for generating a first language file based on the corresponding relation between the variable name and the first language text; the translation unit is used for translating the first language text in the first language file into a second language text to generate a second language file, and the second language file contains the corresponding relation between the second language text and the variable name; and the second replacing unit is used for replacing the variable name in the first code file with the corresponding second language text based on the second language file so as to generate a second code file.
The method and the device for automatically generating the code file provide a scheme for automatically extracting and translating language information in the code aiming at the multilingual requirement of a front end (a webpage end), the multilingual requirement is well stripped from development work, so that a developer only needs to pay attention to function realization, the developer can directly fill in a single language (such as Chinese) at a character display position like a project for developing the single language, and can translate the single language into a language to be translated according to second language texts of multiple language types at a later stage, the working intensity of the developer is greatly reduced, the burden of the developer is reduced, and the working efficiency is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without any creative effort.
FIG. 1 is a flow diagram of a method of one embodiment of a method for automatically generating a code file as set forth herein;
FIG. 2 is a flow diagram of a method of one embodiment of a method for automatically generating language documents as set forth herein;
FIG. 3 is a schematic diagram illustrating an embodiment of an apparatus for automatically generating a code file according to the present application;
FIG. 4 is a schematic structural diagram of an embodiment of a lookup unit according to the present application;
FIG. 5 is a schematic structural diagram of an embodiment of a variable name making unit according to the present application;
fig. 6 is a schematic structural diagram of an embodiment of a second replacement unit described in the present application.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
As used herein, the terms "first," "second," …, etc., do not denote any order or sequence, nor are they used to limit the present invention, but rather are used to distinguish one element from another or from another element or operation described in the same technical language.
The following describes a method and an apparatus for identifying a style of a product according to the present application in detail with reference to the drawings. Although the present application provides method operational steps or apparatus configurations as illustrated in the following examples or figures, more or fewer operational steps or module configurations may be included in the method or apparatus based on conventional or non-inventive efforts. In the case of steps or structures where there is no logically necessary cause-and-effect relationship, the execution order of the steps or the block structure of the apparatus is not limited to the execution order or the block structure provided in the embodiments of the present application. When the described method or module structure is implemented in an actual device or end product, it can be executed sequentially or executed in parallel (e.g., in the context of parallel processors or multi-threaded processing) according to the embodiments or the method or module structure shown in the figures. Fig. 1 is a flowchart of a method of an embodiment of a method for automatically generating a code file, as shown in fig. 1, an embodiment of the method for automatically generating a code file provided by the present application may include:
step S101, traversing a first code file, and searching a plurality of first language texts in the first code file;
step S102, replacing a plurality of first language texts with corresponding variable names;
step S103, generating a first language file based on the corresponding relation between the variable name and the first language text;
step S104, translating the first language text in the first language file into a second language text to generate a second language file, wherein the second language file comprises the corresponding relation between the second language text and the variable name;
and step S105, replacing the variable name in the first code file with the corresponding second language text based on the second language file to generate a second code file.
The method for automatically generating the code file provides a scheme for automatically extracting and translating the language text in the code aiming at the multilingual requirement of the front end (webpage end), the multilingual requirement is well stripped from the development work, so that a developer only needs to pay attention to function realization, the developer can directly fill in the single language (for example, Chinese) at a character display position like developing a single-language project, and translate the single language into the language to be translated according to the second language text of multiple language types at the later stage, the working strength of the developer is greatly reduced, the burden of the developer is reduced, and the working efficiency is improved.
In the present application, the search for several first language texts in the first code file is implemented by the following preferred embodiments: traversing codes in the first code file, and searching Chinese information except the Chinese annotations in the codes; and determining the searched Chinese information as a first language text. In the process of developing a project, since developers in chinese regions are generally chinese, developers habitually use chinese information in the development and coding stage, which is not limited in this application, and for projects developed by developers habitually using english, it is english information that is found.
Searching for a plurality of first language texts in the first code file can be realized through node js (a Java script operating environment) or through other programming languages such as Java, python, c + +, and the like. The searched first language texts can be stored in a js format, and can also be stored in data storage formats such as txt, csv, database tables and the like.
Before replacing the plurality of first language texts with the variable names corresponding to the first language texts, the variable names corresponding to the first language texts can be formulated according to preset rules. To the rule of predetermineeing in this application, can set for by oneself according to actual conditions, introduce two kinds of comparatively good usefulness, the predetermined rule of result of use preferred below, the first kind is: according to the parent-child relationship among codes, variables and applications in front of the first language text, making variable names corresponding to the first language text; secondly, a variable name corresponding to the first language text is established according to the position of the code in front of the first language text. Based on the preset rule, variable names corresponding to each first language text one to one can be formulated.
It should be noted that the second language file in the present application may be multiple files, and the language type used in each file is different, for example, the second language file may be a chinese language file, an english language file, a russian language file, or the like. The following introduces the generation process of the multilingual file by taking the example that the first language text is Chinese information: firstly, generating a Chinese language file (namely the first language file) based on the corresponding relation between the variable name and the Chinese information, wherein the corresponding relation between each variable name and the Chinese information is recorded in the Chinese language file; then, translating the Chinese language file, keeping the variable names in the Chinese language file unchanged, and translating the Chinese information corresponding to each variable name into other languages, such as English or Russian; and finally, correspondingly generating a second language file with a plurality of language types, such as an English language file or a Russian language file.
After generating a second language file with multiple language types, the first language text may be replaced according to a replacement requirement, and specifically, a language type (for example, russian) that the first language text needs to be replaced is determined according to the replacement requirement; calling a second language file (such as a Russian language file) corresponding to the language type; and replacing the variable name in the first code file with the corresponding second language text based on the second language file to generate a second code file. Based on the method, the Chinese information compiled by developers in the development and coding process can be replaced by the Russian information, the translation process is simple and efficient, the burden of the developers is reduced, and the development efficiency is improved.
In the present application, the types of the first code file include at least: js, html, jsp, php, or vm. For the html type file, the first code file cannot be directly replaced, and the html type file needs to be converted into a js type file. And then performing subsequent replacement translation operations.
It should be noted that, after the first code file is upgraded, for example, a developer develops the first code file again, or some new functions are extended, the newly added first language text needs to be searched, then a variable name corresponding to the newly added first language text is formulated according to a preset rule, and finally, the corresponding relationship between the variable name and the newly added first language text is added to the first language file. That is, the content in the first language file generated before is not overwritten, and only new content needs to be added. Therefore, the updating time of the multi-language file is shortened, and repeated work is avoided.
Two preset rules for setting variable names are described below by taking js files and html files as examples.
(one) js file
1. The first code file under the specified project folder is traversed.
2. The first language text in the first code file is retrieved.
Msg:{
NoRelaceTip: 'No variables requiring replacement'
}
3. And formulating a variable name corresponding to the first language text according to a preset rule, and then replacing the first language text with the variable name.
For example, a variable name corresponding to the first language text may be formulated according to a parent-child relationship between codes and variables and applications in front of the first language text: appName _ msg _ NoReplaceTip. The variable name represents the nodeplacetip under the variable msg under the appName, so that the future positioning is facilitated, and the subsequent replacement is facilitated. The appName and the variable msg are in a parent-child relationship, the appName is a parent, and the msg is a child; the variable msg and noReplaceTip are in a parent-child relationship, msg is the parent, and noReplaceTip is the child.
The code after replacement is as follows:
Msg:{
noReplaceTip:translate(‘appName_msg_noReplaceTip’)
}
html document (II)
1. And converting the html file into a js file.
2. And traversing the js file and calling the first language text.
< cable class for < desc-title > description </cable >
3. And formulating a variable name corresponding to the first language text according to a preset rule, and then replacing the first language text with the variable name.
For example, a variable name corresponding to the first language text may be formulated according to the position where the code in front of the first language text is located: appName _ templates _ UDFDetail _ 2. In the variable name, "2" means: the description of the first language text is a 2 nd first language text appearing in html (first code file) with a variable of UDFDetail under appName, so that the method is convenient to accurately position in the future and is beneficial to subsequent quick and accurate replacement.
The code after replacement is as follows:
<lable class=“desc-title”for=“udfComment”>
translate(‘appName_templates_UDFDetail_2’)
</lable>
by analogy, a variable name corresponding to the first language text can be formulated according to the two preset rules or other preset rules, and then a Chinese language file (namely the first language file) is established according to the corresponding relation between the variable name and the first language text.
The Chinese language document is as follows:
Figure BDA0000995165680000051
Figure BDA0000995165680000061
then, the Chinese language file is translated into a second language file of the other language types, and the second language file contains the corresponding relation between the second language text and the variable name. And replacing variable names in the codes with second code files of other language types according to actual requirements, thereby realizing international multi-language development.
When the first code file is developed again and some functions are expanded, an updated first language file can be obtained only by operating the technical scheme of the application again, a new first language text and a variable name thereof are added into the original first language file, then the second language file is generated by corresponding translation, and the previous translation result cannot be covered.
Fig. 2 is a flowchart of a method of an embodiment of the method for automatically generating a language file, and as shown in fig. 2, another embodiment of the method for automatically generating a language file provided by the present application may include:
step S201, traverse each first code file in the project folder. Of course, the traversal scope in the project folder can also be specified as desired.
Step S202, judging the file type of the first code file; if the file is a js file, step S204 is executed, and if the file is an html file, step S203 is executed.
Step S203, the html file is converted into a js file. Then, step S204 is performed.
Step S204, a plurality of first language texts in the first code file are extracted.
In step S205, a variable name corresponding to the first language text is generated.
Step S206, the first language text is replaced according to the variable name.
Step S207, judging whether the second language file exists; if yes, step S209 is performed, and if no, step S208 is performed.
Step S208, generating a first language file according to the corresponding relation between the variable name and the first language text. And translating the first language text in the first language file into a second language text to generate a second language file, wherein the second language file contains the corresponding relation between the second language text and the variable name.
Step S209, integrate and update the second language file.
Based on the scheme, developers only need to develop codes according to Chinese habits and operate the scheme before issuing each time, and international multi-language development is finished.
Based on the same inventive concept as the method for automatically generating a code file, the present application provides an apparatus for automatically generating a code file, as described in the following embodiments. Because the principle of solving the problems of the device for automatically generating the code file is similar to the method for automatically generating the code file, the implementation of the device for automatically generating the code file can refer to the implementation of the method for automatically generating the code file, and repeated parts are not repeated.
Fig. 3 is a schematic structural diagram of an embodiment of an apparatus for automatically generating a code file according to the present application, and as shown in fig. 3, the apparatus may include:
the searching unit 10 is configured to traverse the first code file and search a plurality of first language texts in the first code file; the searching unit 10 is a part for searching the first language text in the device for automatically generating the code file, and may be software, hardware or a combination of the two, for example, an input/output interface, a processing chip, or other components for performing the information searching function.
A first replacing unit 20, configured to replace the first language texts with corresponding variable names; the first replacing unit 20 is a part for replacing information in the device for automatically generating a code file, and may be software, hardware, or a combination of the two, and may be, for example, an input/output interface, a processing chip, or other components that perform an information replacing function.
A file generating unit 30 configured to generate a first language file based on a correspondence relationship between a variable name and a first language text; the file generation unit 30 is a part for generating a file in the apparatus for automatically generating a code file, and may be software, hardware, or a combination of both, and may be, for example, an input/output interface, a processing chip, or other components that perform a function of generating a file.
A translation unit 40, configured to translate the first language text in the first language file into a second language text to generate a second language file, where the second language file includes a correspondence between the second language text and the variable name; the translation unit 40 is a part for performing text translation in a device that automatically generates a code file, and may be software, hardware, or a combination of both, and may be, for example, an input/output interface, a processing chip, or other components that perform a text translation function.
And a second replacing unit 50 for replacing the variable name in the first code file with the corresponding second language text based on the second language file to generate a second code file. The second replacing unit 50 is a part for replacing information in the device for automatically generating a code file, and may be software, hardware or a combination of the two, for example, an input/output interface, a processing chip, or other components that perform the information replacing function.
The device for automatically generating the code file, which is provided by the application, provides a scheme for automatically extracting and translating the language text in the code aiming at the multilingual requirement of the front end (webpage end), and well strips the multilingual requirement from the development work, so that a developer only needs to pay attention to the function realization, the developer can directly fill in the single language (for example, Chinese) at a character display position like developing a single-language project, and translate the single language into the language to be translated according to the second language text of multiple language types at the later stage, thereby greatly reducing the working intensity of the developer, reducing the burden of the developer and improving the working efficiency.
Fig. 4 is a schematic structural diagram of an embodiment of a lookup unit according to the present application, and as shown in fig. 4, the lookup unit 10 includes: the traversing module 12 is used for traversing the codes in the first code file and searching the Chinese information except the Chinese annotations in the codes; and the determining module 14 is configured to determine the searched chinese information as the first code file. The search for the first code file can be realized through node js (a Java script operating environment), and can also be realized through other programming languages such as Java, python, c + +, and the like. The searched first code file can be stored in a js format, and can also be stored in data storage formats such as txt, csv, database tables and the like.
Fig. 5 is a schematic structural diagram of an embodiment of a variable name making unit according to the present application, and as shown in fig. 5, the apparatus further includes: a variable name making unit 60 for making a variable name corresponding to the first language text according to a parent-child relationship between codes and variables and applications in front of the first language text; or, the method is used for making a variable name corresponding to the first language text according to the position of the code in front of the first language text. Typically, only one of the preset rules is adopted.
It should be noted that the second language file in the present application may be multiple files, and the language type used in each file is different, for example, the second language file may be a chinese language file, an english language file, a russian language file, or the like. The following introduces the generation process of the multilingual file by taking the example that the first language text is Chinese information: firstly, generating a Chinese language file (namely the first language file) based on the corresponding relation between the variable name and the Chinese information, wherein the corresponding relation between each variable name and the Chinese information is recorded in the Chinese language file; then, translating the Chinese language file, keeping the variable names in the Chinese language file unchanged, and translating the Chinese information corresponding to each variable name into other languages, such as English or Russian; and finally, correspondingly generating a second language file with a plurality of language types, such as an English language file or a Russian language file.
Fig. 6 is a schematic structural diagram of an embodiment of a second replacement unit described in the present application, and as shown in fig. 6, the second replacement unit 50 includes: the language determining module 52 is used for determining the language type of the first language text to be replaced according to the replacement requirement; a file retrieving module 54, configured to retrieve a second language file corresponding to the language type; and a replacing module 56, configured to replace the variable name in the first code file with a corresponding second language text based on the second language file to generate a second code file. Thus realizing international multi-language development.
In the present application, the types of the first code file include at least: js, html, jsp, php, or vm. For the html type file, the first language text cannot be directly replaced, and the html type file needs to be converted into a js type file. And then performing subsequent replacement translation operations. Accordingly, the above apparatus further comprises: a type conversion unit for judging the type of the first code file; if the html type file is the html type file, the html type file is converted into a js type file.
It should be noted that, after the first code file is upgraded, for example, a developer develops the first code file again, or some new functions are extended, the newly added first language text needs to be searched, then a variable name corresponding to the newly added first language text is formulated according to a preset rule, and finally, the corresponding relationship between the variable name and the newly added first language text is added to the first language file. That is, the content in the previously generated language file is not overwritten, and only new content needs to be added. Based on this, the present application provides a preferred embodiment, that is, the above apparatus further comprises: the updating unit is used for searching the newly added first language text after the first code file is upgraded; formulating a variable name corresponding to the newly added first language text according to a preset rule; and supplementing the corresponding relation between the variable name and the newly added first language text into the first language file. Therefore, the updating time of the multi-language file is shortened, and repeated work is avoided.
From the above description, the scheme for automatically generating the code file is designed, so that the multi-language requirements are well stripped from the development work, and developers only need to pay attention to function implementation. The developer can directly fill in the characters on the display position by using Chinese as developing a project of a single language without considering the problems of later variable replacement and the like. And when the multi-language requirement is met, a developer does not need to change the source code, the quota burden of the developer is reduced, and the development efficiency is improved.
Although the present application provides method steps as described in an embodiment or flowchart, additional or fewer steps may be included based on conventional or non-inventive efforts. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. When an actual apparatus or client product executes, it may execute sequentially or in parallel (e.g., in the context of parallel processors or multi-threaded processing) according to the embodiments or methods shown in the figures.
The apparatuses or modules illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. For convenience of description, the above devices are described as being divided into various modules by functions, and are described separately. The functionality of the modules may be implemented in the same one or more software and/or hardware implementations of the present application. Of course, a module that implements a certain function may be implemented by a plurality of sub-modules or sub-units in combination.
The methods, apparatus or modules described herein may be implemented in computer readable program code to implement a controller in any suitable manner, e.g., the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controller and embedded microcontroller, examples of the controller including, but not limited to, ARC 625D, Atmel AT91SAM, Microchip 18F26K20 and Silicone L abs C8051F320, the memory controller may also be implemented as part of the control logic of the memory.
Some of the modules in the apparatus described herein may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, classes, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
From the above description of the embodiments, it is clear to those skilled in the art that the present application can be implemented by software plus necessary hardware. Based on such understanding, the technical solutions of the present application may be embodied in the form of software products or in the implementation process of data migration, which essentially or partially contributes to the prior art. The computer software product may be stored in a storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, mobile terminal, server, or network device, etc.) to perform the methods described in the various embodiments or portions of the embodiments of the present application.
The embodiments in the present specification are described in a progressive manner, and the same or similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. All or portions of the present application are operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, mobile communication terminals, multiprocessor systems, microprocessor-based systems, programmable electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
While the present application has been described with examples, those of ordinary skill in the art will appreciate that there are numerous variations and permutations of the present application without departing from the spirit of the application, and it is intended that the appended claims encompass such variations and permutations without departing from the spirit of the application.

Claims (14)

1. A method of automatically generating a code file, the method comprising:
traversing the first code file, and searching a plurality of first language texts in the first code file;
replacing the plurality of first language texts with variable names corresponding to the first language texts;
generating a first language file based on the corresponding relation between the variable name and the first language text;
translating the first language text in the first language file into a second language text to generate a second language file, wherein the second language file comprises the corresponding relation between the second language text and the variable name;
replacing the variable name in the first code file with a corresponding second language text based on the second language file to generate a second code file.
2. The method of claim 1, wherein traversing the first code file for a number of first language texts in the first code file comprises:
traversing codes in the first code file, and searching Chinese information except for the Chinese annotations in the codes;
and determining the searched Chinese information as a first language text.
3. The method of claim 1, wherein before replacing the number of first language texts with their corresponding variable names, further comprising:
according to the parent-child relationship among codes, variables and applications in front of the first language text, formulating variable names corresponding to the first language text; alternatively, the first and second electrodes may be,
and formulating a variable name corresponding to the first language text according to the position of the code in front of the first language text.
4. The method of claim 1, wherein replacing the variable name in the first code file with corresponding second language text based on the second language file to generate a second code file comprises:
determining the language type of the first language text to be replaced according to the replacement requirement;
calling a second language file corresponding to the language type;
replacing the variable name in the first code file with a corresponding second language text based on the second language file to generate a second code file.
5. The method of claim 1, further comprising:
judging the type of the first code file;
and if the html type file is the html type file, converting the html type file into a js type file.
6. The method of claim 5, wherein the type of the first code file comprises: js, html, jsp, php, or vm.
7. The method of claim 1, further comprising:
after the first code file is upgraded, a newly added first language text is searched;
formulating a variable name corresponding to the newly added first language text according to a preset rule;
and supplementing the corresponding relation between the variable name and the newly added first language text into the first language file.
8. An apparatus for automatically generating a code file, the apparatus comprising:
the searching unit is used for traversing the first code file and searching a plurality of first language texts in the first code file;
the first replacing unit is used for replacing the plurality of first language texts with variable names corresponding to the first language texts;
the file generating unit is used for generating a first language file based on the corresponding relation between the variable name and the first language text;
the translation unit is used for translating the first language text in the first language file into a second language text to generate a second language file, and the second language file contains the corresponding relation between the second language text and the variable name;
and the second replacing unit is used for replacing the variable name in the first code file with the corresponding second language text based on the second language file so as to generate a second code file.
9. The apparatus of claim 8, wherein the lookup unit comprises:
the traversing module is used for traversing the codes in the first code file and searching Chinese information except the Chinese annotations in the codes;
and the determining module is used for determining the searched Chinese information as a first language text.
10. The apparatus of claim 8, further comprising:
the variable name making unit is used for making a variable name corresponding to the first language text according to the parent-child relationship among codes, variables and applications in front of the first language text; or, the variable name corresponding to the first language text is formulated according to the position of the code in front of the first language text.
11. The apparatus of claim 8, wherein the second replacement unit comprises:
the language determination module is used for determining the language type of the first language text to be replaced according to the replacement requirement;
the file calling module is used for calling a second language file corresponding to the language type;
and the replacing module is used for replacing the variable name in the first code file with a corresponding second language text based on the second language file so as to generate a second code file.
12. The apparatus of claim 8, further comprising:
the type conversion unit is used for judging the type of the first code file; and if the html type file is the html type file, converting the html type file into a js type file.
13. The apparatus of claim 12, wherein the type of the first code file comprises: js, html, jsp, php, or vm.
14. The apparatus of claim 8, further comprising:
the updating unit is used for searching a newly added first language text after the first code file is upgraded; formulating a variable name corresponding to the newly added first language text according to a preset rule; and supplementing the corresponding relation between the variable name and the newly added first language text into the first language file.
CN201610341016.8A 2016-05-20 2016-05-20 Method and device for automatically generating code file Active CN107402746B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610341016.8A CN107402746B (en) 2016-05-20 2016-05-20 Method and device for automatically generating code file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610341016.8A CN107402746B (en) 2016-05-20 2016-05-20 Method and device for automatically generating code file

Publications (2)

Publication Number Publication Date
CN107402746A CN107402746A (en) 2017-11-28
CN107402746B true CN107402746B (en) 2020-08-04

Family

ID=60389553

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610341016.8A Active CN107402746B (en) 2016-05-20 2016-05-20 Method and device for automatically generating code file

Country Status (1)

Country Link
CN (1) CN107402746B (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109200581B (en) * 2018-07-25 2021-05-25 深圳点猫科技有限公司 Method and electronic device for controlling game role through python code
CN109684096A (en) * 2018-12-29 2019-04-26 北京超图软件股份有限公司 A kind of software program recycling processing method and device
CN109918166B (en) * 2019-03-12 2022-04-01 天津字节跳动科技有限公司 Applet processing method and device and electronic equipment
CN110134401A (en) * 2019-04-12 2019-08-16 深圳壹账通智能科技有限公司 Code snippet localization method, device, computer equipment and storage medium
CN110018876A (en) * 2019-04-16 2019-07-16 成都四方伟业软件股份有限公司 The international method, apparatus of software application and electronic equipment
CN110413574B (en) * 2019-07-30 2023-04-07 深圳市携众通科技有限公司 Method for automatically generating code internationalized resources
CN110704154B (en) * 2019-10-12 2023-05-12 杭州行至云起科技有限公司 Multi-language template release method and system
CN111813474A (en) * 2020-06-28 2020-10-23 深圳市元征科技股份有限公司 Multi-language display method and device and electronic equipment
CN111966584A (en) * 2020-07-30 2020-11-20 上海泛微网络科技股份有限公司 Automatic detection method and device for jsp code language specification
CN112199962A (en) * 2020-09-30 2021-01-08 京东数字科技控股股份有限公司 Code processing method and device, computer equipment and storage medium
CN112286557B (en) * 2020-11-05 2024-03-22 苏州帝博信息技术有限公司 Method and device for updating code content in non-coverage mode
CN113011201A (en) * 2021-03-19 2021-06-22 北京沃东天骏信息技术有限公司 Code file processing method and device
CN113312057B (en) * 2021-06-17 2023-10-03 上海小熊星教育科技有限公司 Code processing method, programming auxiliary method, medium and electronic equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102637168A (en) * 2012-03-19 2012-08-15 深圳市共进电子股份有限公司 Method for realizing automatic language translation in graphical user interface
CN104915204A (en) * 2015-06-08 2015-09-16 小米科技有限责任公司 Web processing method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8533691B2 (en) * 2011-02-09 2013-09-10 Beek Fund B.V. L.L.C. Managing non-common features for program code translation
US9727350B2 (en) * 2012-07-26 2017-08-08 Entit Software Llc Localizing computer program code

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102637168A (en) * 2012-03-19 2012-08-15 深圳市共进电子股份有限公司 Method for realizing automatic language translation in graphical user interface
CN104915204A (en) * 2015-06-08 2015-09-16 小米科技有限责任公司 Web processing method and device

Also Published As

Publication number Publication date
CN107402746A (en) 2017-11-28

Similar Documents

Publication Publication Date Title
CN107402746B (en) Method and device for automatically generating code file
US11461111B2 (en) Method for running applets, and electronic device
CN111026470B (en) System and method for verification and conversion of input data
CN111736840A (en) Compiling method and running method of applet, storage medium and electronic equipment
CN110502520B (en) Method, system and equipment for data warehousing and computer readable storage medium
CN114153459A (en) Interface document generation method and device
CN114036443A (en) Page generation method and device
CN111026404A (en) Method and device for generating parameter configuration code, electronic product and storage medium
CN113760276A (en) Method and device for generating page code
CN112130830A (en) Interface generation method and device and electronic equipment
US8701086B2 (en) Simplifying analysis of software code used in software systems
CN110308907B (en) Data conversion method and device, storage medium and electronic equipment
CN113760266B (en) Method and device for creating function module file and electronic equipment
CN116028028A (en) Request function generation method, device, equipment and storage medium
CN111459537A (en) Redundant code removing method, device, equipment and computer readable storage medium
CN109828759B (en) Code compiling method, device, computer device and storage medium
CN115543440A (en) Method for migrating android project to android-like system, electronic equipment and storage medium
CN114327492A (en) Code translation method, device and equipment
US20220284371A1 (en) Method, device and medium for a business function page
CN110764768A (en) Method and device for mutual conversion between model object and JSON object
EP3825897A2 (en) Method, apparatus, device, storage medium and program for outputting information
CN114625373A (en) Application conversion method and device, electronic equipment and storage medium
CN111880785A (en) Program code conversion method and device and electronic equipment
CN112181429A (en) Information processing method and device and electronic equipment
CN112882698A (en) Development environment generation method and device, computer storage medium and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20201014

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20201014

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Advanced innovation technology Co.,Ltd.

Address before: Greater Cayman, British Cayman Islands

Patentee before: Alibaba Group Holding Ltd.

TR01 Transfer of patent right