Embodiment
In order that those skilled in the art more fully understand the technical scheme in the application, it is real below in conjunction with the application
The accompanying drawing in example is applied, the technical scheme in the embodiment of the present application is clearly and completely described, it is clear that described implementation
Example only some embodiments of the present application, rather than whole embodiments.It is common based on the embodiment in the application, this area
The every other embodiment that technical staff is obtained under the premise of creative work is not made, it should all belong to the application protection
Scope.
On " first " used herein, " second " ... etc., not especially censure the meaning of order or cis-position,
Be not used to limit the present invention, its only for distinguish with constructed term description element or operation.
The style recognition methods of commodity described herein and device are described in detail below in conjunction with the accompanying drawings.Although
This application provides such as following embodiments or method operating procedure shown in the drawings or apparatus structure, but based on conventional or need not
Performing creative labour can include more or less operating procedure or modular structure in methods described or device.In logic
In the step of necessary causality is not present in property or structure, the execution sequence of these steps or the modular structure of device are not limited to
The execution sequence or modular structure that the embodiment of the present application provides.The device in practice of described method or modular structure or end
, can either method or modular structure shown in the drawings connect carry out order execution or simultaneously according to embodiment when holding the product to perform
Row performs (such as environment of parallel processor or multiple threads).Fig. 1 is the automatic code generating file that the application proposes
The method flow diagram of a kind of embodiment of method, as shown in figure 1, the one kind for the automatic code generating document method that the application provides
Embodiment can include:
Step S101, first code file is traveled through, searches some first language texts in the first code file;
Step S102, some first language texts are replaced with into corresponding variable name;
Step S103, the corresponding relation based on above-mentioned variable name Yu above-mentioned first language text, generate first language file;
Step S104, the first language text in first language file is translated into second language text, to generate second
Language file, the second language file include the corresponding relation of second language text and variable name;
Step S105, based on second language file, the variable name in first code file is replaced with into corresponding second language
Text is sayed to generate second code file.
The method for the automatic code generating file that the application provides, is provided for the multilingual requirements of front end (page end)
One automatically extracts language text in code and the scheme translated, and multilingual requirements well have been peeled off from development
Come so that developer need to only pay close attention to function realization, and developer can be as developing monolingual project, in text
The word place of showing directly is filled in using single language (such as Chinese), and the later stage will be upper according to the second language text of multilingual type
The language that single language translation is translated into needs is stated, greatly reduces the working strength of developer, reduces the burden of developer,
Improve operating efficiency.
In this application, some first language texts searched in first code file are real by following preferred embodiment
It is existing:The code in first code file is traveled through, searches the Chinese information in addition to Chinese annotation in code;The Chinese that will be found
Information is defined as first language text.In project development process, because the developer of CHINESE REGION is usually Chinese, because
This, developer uses Chinese information in exploitation coding stage habituation, and certain the application is limited not to this, for practising
The project that the used developer using English is developed, what is found is then english information.
Some first language texts searched in first code file can be by a node js (Java script fortune
Row environment) realize, it can also be realized by other programming languages such as java, python, c++ etc..Some first languages found
Speech text can be stored with js forms, can also be stored with data memory formats such as txt, csv, database tables.
Before some first language texts are replaced with into corresponding variable name, can according to preset rules formulate with
Variable name corresponding to first language text.For the preset rules in the application, can according to actual conditions sets itself, below
Two kinds of more handy, preferable preset rules of using effect are introduced, the first is:According to the code before first language text with
Variable, the set membership between, formulate variable name corresponding with first language text;It is for second, according to first language
The location of code before text, formulate variable name corresponding with first language text., can based on above-mentioned preset rules
Formulate and each one-to-one variable name of first language text.
It should be noted that the second language file in the application, can be more parts of files, used in per text document
Language form is different, such as can be Chinese language file, english language file, Russian language file etc..Below with the first language
Exemplified by speech text is Chinese information, the generating process of multilingual file is introduced:First, based on variable name and Chinese information
Corresponding relation, generation Chinese language file (i.e. above-mentioned first language file), described in the Chinese language file is each
The corresponding relation of individual variable name and Chinese information;Then, Chinese language file is translated, by the change in Chinese language file
It is constant to measure name reservation, Chinese information corresponding with each variable name is translated as other language, such as English or Russian etc.;
Finally, the second language file of corresponding generation multilingual type, such as english language file or Russian language file.
After the second language file of generation multilingual type, first language text can be entered according to replacement demand
Row is replaced, and specifically, determines that first language text needs the language form (such as Russian) replaced according to replacement demand;Transfer with
Second language file corresponding to the language form (such as Russian language file);Based on second language file, by first code text
Variable name in part replaces with corresponding second language text to generate second code file., can be by developer based on this
The Chinese information write in cataloged procedure is developed replaces with Russian information, and translation process is simply efficient, while reduces exploit person
The burden of member, improve development efficiency.
In this application, the type of first code file comprises at least:Js, html, jsp, php or vm.For html
For type file, it is impossible to directly carry out the replacement of first code file, it is necessary to which html type files first are converted into js types
File.Follow-up replacement translating operation is performed again.
It should be noted that after first code document upgrading, such as developer develops again to first code file,
Or extend some New functions, then the first language text newly increased is required to look up, then according to preset rules formulation and newly
Variable name corresponding to increased first language text, finally by the variable name and the corresponding pass of the first language text newly increased
System, fills into first language file.That is, the content in the first language file generated before will not be capped, it is only necessary to will be new
Content cover.So as to reduce the renewal duration of multilingual file, repeated work is avoided.
Separately below by taking js files and html files as an example, two kinds of preset rules for formulating variable name are introduced.
(1) js files
1st, the first code file under technical routine file is traveled through.
2nd, the first language text in first code file is transferred.
Msg:{
noReplaceTip:' not needing the variable replaced '
}
3rd, variable name corresponding with the first language text is formulated according to preset rules, then replaces the first language text
It is changed to variable name.
For example, it can be formulated and the according to the code before first language text and variable, the set membership between
Variable name corresponding to one language text:appName_msg_noReplaceTip.The variable name represents to apply the change under appName
The noReplaceTip under msg is measured, it is convenient to position in the future, in favor of follow-up replacement.Wherein, using appName and variable msg
It is set membership, appName is father, and msg is son;Variable msg and noReplaceTip is set membership, and msg is father,
NoReplaceTip is son.
Code after replacement is as follows:
Msg:{
noReplaceTip:translate(‘appName_msg_noReplaceTip’)
}
(2) html files
1st, html files are converted into js files.
2nd, js files are traveled through, transfer first language text.
<Lable class=" desc-title " for=" udfComment ">Description</lable>
3rd, variable name corresponding with the first language text is formulated according to preset rules, then replaces the first language text
It is changed to variable name.
For example, it can be formulated corresponding with first language text according to the location of code before first language text
Variable name:appName_templates_UDFDetail_2.In the variable name, " 2 " represent:Above-mentioned first language text " is retouched
State " it is the 2nd first language occurred in the html (first code file) for applying the variable under appName to be UDFDetail
Text, it is convenient to be accurately positioned in the future, beneficial to follow-up quick and precisely replacement.
Code after replacement is as follows:
<Lable class=" desc-title " for=" udfComment ">
translate(‘appName_templates_UDFDetail_2’)
</lable>
By that analogy, can be formulated and first language text according to above two preset rules or other preset rules
Corresponding variable name, then according to the corresponding relation of variable name and first language text, establish Chinese language file (i.e. above-mentioned the
One language file).
Chinese language file is as follows:
Then, Chinese language file is translated, the second language file of remaining language form can be translated as, this
Corresponding relation comprising second language text and variable name in two language files.The variable name in code is replaced according to the actual requirements
The second code file of other language forms is changed to, so as to realize international multilingual exploitation.
When first code file is developed again, extends some functions, as long as running the technology of the application again
Scheme, just it can obtain the first language file after a renewal, new first language text and its variable name can be added to former the
In one language file, translation generation second language file is then corresponded to, translation achievement before will not be capped.
Fig. 2 is a kind of method flow diagram for the embodiment for automatically generating language file method that the application proposes, such as Fig. 2 institutes
Show, another embodiment for automatically generating language file method of the application offer can include:
Step S201, travel through each first code file in project folder.It is of course also possible to technical routine is literary on demand
Traversal scope in part folder.
Step S202, judge the file type of first code file;If js files, then step S204 is performed, if
It is html files, then performs step S203.
Step S203, html files are converted into js files.Then step S204 is performed.
Step S204, extract some first language texts in first code file.
Step S205, generate variable name corresponding with first language text.
Step S206, first language text is replaced according to variable name.
Step S207, judge whether second language file is existing;If it is, step S209 is performed, if it is not, then holding
Row step S208.
Step S208, according to variable name and the corresponding relation of first language text, generate first language file.By the first language
First language text in speech file translates into second language text, to generate second language file, the second language file bag
The corresponding relation of text containing second language and variable name.
Step S209, integrate renewal second language file.
Based on such scheme, developer only needs to be accustomed to carrying out code development according to Chinese, is run before each issue
Such scheme, that is, complete the multilingual exploitation of internationalization.
Based on the method identical inventive concept with above-mentioned automatic code generating file, the application provides one kind and automatically generated
The device of code file, as described in example below.Due to the automatic code generating file device solve problem principle with
The method of automatic code generating file is similar, therefore the implementation of the device of the automatic code generating file may refer to automatically generate
The implementation of the method for code file, repeat part and repeat no more.
Fig. 3 is a kind of structural representation of embodiment of device of herein described automatic code generating file, such as Fig. 3 institutes
Show, described device can include:
Searching unit 10, for traveling through first code file, search some first languages text in the first code file
This;Searching unit 10 is automatically generated the part that first language text is searched in the device of code file, can be software, hardware
Or the combination of the two, such as can complete the components such as input/output interface, the process chip of information searching function.
First replacement unit 20, for some first language texts to be replaced with into corresponding variable name;First replaces
Unit 20 is automatically generated the part that information in the device of code file is replaced, and can be software, hardware or the combination of the two, example
Such as can be input/output interface, the process chip component for completing information replacement function.
File generating unit 30, for the corresponding relation based on variable name Yu first language text, generation first language text
Part;File generating unit 30 is automatically generated the part that file is generated in the device of code file, can be software, hardware or two
The combination of person, such as can complete the components such as input/output interface, the process chip of file generated function.
Translation unit 40, for the first language text in first language file to be translated into second language text, with life
Into second language file, the second language file includes the corresponding relation of second language text and the variable name;Translation unit
40 are automatically generated the part that text translation is carried out in the device of code file, can be software, hardware or the combination of the two, example
Such as can be input/output interface, the process chip component for completing text interpretative function.
Second replacement unit 50, for based on second language file, the variable name in first code file is replaced with pair
The second language text answered is to generate second code file.Second replacement unit 50, which is automatically generated in the device of code file, to be believed
The part replaced is ceased, can be software, hardware or the combination of the two, such as can be the input and output for completing information replacement function
The components such as interface, process chip.
The device for the automatic code generating file that the application provides, is provided for the multilingual requirements of front end (page end)
One automatically extracts language text in code and the scheme translated, and multilingual requirements well have been peeled off from development
Come so that developer need to only pay close attention to function realization, and developer can be as developing monolingual project, in text
The word place of showing directly is filled in using single language (such as Chinese), and the later stage will be upper according to the second language text of multilingual type
The language that single language translation is translated into needs is stated, greatly reduces the working strength of developer, reduces the burden of developer,
Improve operating efficiency.
Fig. 4 is a kind of structural representation of embodiment of herein described searching unit, as shown in figure 4, above-mentioned searching unit
10 include:Spider module 12, for traveling through the code in first code file, search in above-mentioned code in addition to Chinese annotation
Chinese information;Determining module 14, for the above-mentioned Chinese information found to be defined as into first code file.Search first code
File can be realized by node js (a Java script running environment), can also be by other programming languages such as
Java, python, c++ etc. are realized.The first code file found can be stored with js forms, can also be with txt, csv, number
Stored according to data memory formats such as storehouse tables.
Fig. 5 is that herein described variable name formulates a kind of structural representation of embodiment of unit, as shown in figure 5, above-mentioned dress
Putting also includes:Variable name formulate unit 60, for according to the code before above-mentioned first language text and variable, between
Set membership, formulate variable name corresponding with above-mentioned first language text;Or for before according to above-mentioned first language text
The location of code, formulate variable name corresponding with above-mentioned first language text.Generally, one of which is only taken
Preset rules.
It should be noted that the second language file in the application, can be more parts of files, used in per text document
Language form is different, such as can be Chinese language file, english language file, Russian language file etc..Below with the first language
Exemplified by speech text is Chinese information, the generating process of multilingual file is introduced:First, based on variable name and Chinese information
Corresponding relation, generation Chinese language file (i.e. above-mentioned first language file), described in the Chinese language file is each
The corresponding relation of individual variable name and Chinese information;Then, Chinese language file is translated, by the change in Chinese language file
It is constant to measure name reservation, Chinese information corresponding with each variable name is translated as other language, such as English or Russian etc.;
Finally, the second language file of corresponding generation multilingual type, such as english language file or Russian language file.
Fig. 6 is a kind of structural representation of embodiment of herein described second replacement unit, as shown in fig. 6, above-mentioned second
Replacement unit 50 includes:Language determining module 52, for determining that first language text needs the language replaced according to replacement demand
Type;File transfers module 54, for transferring second language file corresponding with above-mentioned language form;Replacement module 56, is used for
Based on second language file, the variable name in first code file is replaced with into corresponding second language text to generate the second generation
Code file.So as to realize the multilingual exploitation of internationalization.
In this application, the type of first code file comprises at least:Js, html, jsp, php or vm.For html
For type file, it is impossible to directly carry out the replacement of first language text, it is necessary to which html type files first are converted into js types
File.Follow-up replacement translating operation is performed again.Therefore, said apparatus also includes:Type conversion unit, for judging above-mentioned
The type of one code file;If html type files, then above-mentioned html type files are converted into js type files.
It should be noted that after first code document upgrading, such as developer develops again to first code file,
Or extend some New functions, then the first language text newly increased is required to look up, then according to preset rules formulation and newly
Variable name corresponding to increased first language text, finally by the variable name and the corresponding pass of the first language text newly increased
System, fills into first language file.That is, the content in the language file generated before will not be capped, it is only necessary in new
Appearance covers.Based on this, this application provides a kind of preferred embodiment, i.e. said apparatus also includes:Updating block, use
In after first code document upgrading, searching the first language text that newly increases;According to preset rules formulate with newly increase the
Variable name corresponding to one language text;By variable name and the corresponding relation of the first language text newly increased, first language is filled into
File.So as to reduce the renewal duration of multilingual file, repeated work is avoided.
It was found from description more than, the application devises a kind of scheme from automatic code generating file, will be multilingual
Demand has been peeled off out well from development so that developer need to only pay close attention to function realization.Developer can
So that as developing monolingual project, the word place of showing directly is filled in using Chinese, it is not necessary to considers later stage variable replacement etc.
Problem.Source code is modified without developer in multilingual requirements, reduces the volume burden of developer, improves
Development efficiency.
Although this application provides the method operating procedure as described in embodiment or flow chart, based on conventional or noninvasive
The work for the property made can include more or less operating procedures.The step of being enumerated in embodiment order is only numerous steps
A kind of mode in execution sequence, does not represent unique execution sequence., can when device or client production in practice performs
So that according to embodiment, either method shown in the drawings order is performed or parallel performed (such as at parallel processor or multithreading
The environment of reason).
The device or module that above-described embodiment illustrates, can specifically be realized by computer chip or entity, or by with
The product of certain function is realized.For convenience of description, it is divided into various modules during description apparatus above with function to describe respectively.
The function of each module can be realized in same or multiple softwares and/or hardware when implementing the application.It is of course also possible to
The module for realizing certain function is combined into realization by multiple submodule or subelement.
Method, apparatus described herein or module can be realized in a manner of computer readable program code controller by
Any appropriate mode is realized, for example, controller can take such as microprocessor or processor and storage can be by (micro-)
The computer-readable medium of the computer readable program code (such as software or firmware) of computing device, gate, switch, specially
With integrated circuit (Application Specific Integrated Circuit, ASIC), programmable logic controller (PLC) and embedding
Enter the form of microcontroller, the example of controller includes but is not limited to following microcontroller:ARC 625D、Atmel AT91SAM、
Microchip PIC18F26K20 and Silicone Labs C8051F320, Memory Controller are also implemented as depositing
A part for the control logic of reservoir.It is also known in the art that except real in a manner of pure computer readable program code
, completely can be by the way that method and step be carried out into programming in logic come controller with gate, switch, special beyond existing controller
The form of integrated circuit, programmable logic controller (PLC) and embedded microcontroller etc. realizes identical function.Therefore this controller
A kind of hardware component is considered, and what its inside was included is used to realize that the device of various functions can also to be considered as hardware
Structure in part.Or even, can by for realize the device of various functions be considered as both can be implementation method software
Module can be the structure in hardware component again.
Part of module in herein described device can be in the general of computer executable instructions
Described in context, such as program module.Usually, program module includes performing particular task or realizes specific abstract data class
The routine of type, program, object, component, data structure, class etc..The application can also be put into practice in a distributed computing environment,
In these DCEs, by performing task by communication network and connected remote processing devices.In distribution
In computing environment, program module can be located in the local and remote computer-readable storage medium including storage device.
As seen through the above description of the embodiments, those skilled in the art can be understood that the application can
Realized by the mode of software plus required hardware.Based on such understanding, the technical scheme of the application is substantially in other words
The part to be contributed to prior art can be embodied in the form of software product, can also pass through the implementation of Data Migration
During embody.The computer software product can be stored in storage medium, such as ROM/RAM, magnetic disc, CD, bag
Some instructions are included to so that a computer equipment (can be that personal computer, mobile terminal, server, or network are set
It is standby etc.) perform method described in some parts of each embodiment of the application or embodiment.
Each embodiment in this specification is described by the way of progressive, same or analogous portion between each embodiment
Divide mutually referring to what each embodiment stressed is the difference with other embodiment.The whole of the application or
Person part can be used in numerous general or special purpose computing system environments or configuration.Such as:Personal computer, server calculate
Machine, handheld device or portable set, laptop device, mobile communication terminal, multicomputer system, based on microprocessor it is
System, programmable electronic equipment, network PC, minicom, mainframe computer include the distribution of any of the above system or equipment
Formula computing environment etc..
Although depicting the application by embodiment, it will be appreciated by the skilled addressee that the application have it is many deformation and
Change is without departing from spirit herein, it is desirable to which appended claim includes these deformations and changed without departing from the application's
Spirit.