CN106844192A - A kind of detection method of program's source code, device and electronic equipment - Google Patents
A kind of detection method of program's source code, device and electronic equipment Download PDFInfo
- Publication number
- CN106844192A CN106844192A CN201610990856.7A CN201610990856A CN106844192A CN 106844192 A CN106844192 A CN 106844192A CN 201610990856 A CN201610990856 A CN 201610990856A CN 106844192 A CN106844192 A CN 106844192A
- Authority
- CN
- China
- Prior art keywords
- code file
- program
- sound code
- file
- rule
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/362—Software debugging
- G06F11/3624—Software debugging by performing operations on the source code, e.g. via a compiler
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/40—Processing or translation of natural language
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/72—Code refactoring
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Quality & Reliability (AREA)
- Computer Hardware Design (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Machine Translation (AREA)
Abstract
The invention discloses a kind of detection method of program's source code, device and electronic equipment, wherein methods described includes:Obtain sound code file to be detected;Judge that the sound code file to be detected is not to specify area code rule with the presence or absence of second language coding rule, the second language coding rule is the coding rule in addition to English coding rule;When the second language coding rule of the sound code file is not when specifying area code rule, then to judge that the sound code file needs translation.By the invention it is possible to find out for realize a certain systemic-function whole sound code files in all need translation word, consequently facilitating programming personnel modification sound code file the content of display interface is the word that designated area personnel understand.
Description
Technical field
The present invention relates to program test technical field, and in particular to a kind of detection method of program's source code, device and electronics
Equipment.
Background technology
Many services of people's various terminals used in everyday (such as smart mobile phone, cloud TV etc.) are by cloud platform system
The service of offer.When service is runed in the world, by the language that every country is used is different, thus at each
Country can arrange professional with specific reference to the local cloud platform system of the Service Source operation and management of oneself country.
When debugging is researched and developed, display interface or output result generally use specific language to cloud platform system.For example pass through
During the operation interface of web displaying backstage, the programmer of China can write all Chinese of word that source code makes in the page.In this
Interface is runed when India uses in the backstage of text, and the local backstage operation personnel of India can not skilled basis because be ignorant of Chinese
Local service resource is local terminal service using the cloud platform system.
The presentation at backstage operation interface is that, by running what the program's source code of cloud platform system was realized, its display language is more
Changing should also change in the program's source code of cloud platform system.For example, controlled output " hello " in program's source code, then operation program source
Backstage operation system interface just shows " hello " of Chinese after code.But Chinese display interface can not be by the backstage of other countries
Operation personnel is understood, it is therefore desirable to " hello " of Chinese is translated into local country backstage operation personnel it will be appreciated that
Language.This is accomplished by being found in program's source code the position of shown " hello " in the operation system of backstage, by " hello " translation
Into local language.
The existing position that can find known untranslated " hello " in program's source code by debugging acid.However,
The method can not find out other words for not yet translating into target country's language, i.e., can not find in program's source code also
Having which word needs what is translated but not yet translate.
The content of the invention
In view of this, a kind of detection method of program's source code, device and electronic equipment are the embodiment of the invention provides, to solve
Certainly existing method can not find out in program's source code translation in need but the word not yet translated problem.
According in a first aspect, the embodiment of the invention provides a kind of detection method of program's source code, it is adaptable to treatment
The electronic equipment of device, including:Obtain sound code file to be detected;Judge that the sound code file to be detected whether there is the second language
Speech coding rule is not to specify area code rule, and the second language coding rule is the coding in addition to English coding rule
Rule;When the second language coding rule of the sound code file to be detected is not when specifying area code rule, then to judge institute
Stating sound code file to be detected needs translation.
Alternatively, it is described to judge that the sound code file to be detected is not to specify ground with the presence or absence of second language coding rule
The step of area's coding rule, includes:Judge the number of species of the speech encoding rule employed in the sound code file to be detected
Whether more than default number of species;When the number of species of speech encoding rule is more than default number of species, judge described
It is not to specify area code rule that sound code file to be detected has second language coding rule.
Alternatively, it is described to judge that the sound code file to be detected is not to specify ground with the presence or absence of second language coding rule
The step of area's coding rule, includes:Judge employed in the sound code file to be detected speech encoding rule species whether
It is two kinds;When the number of species of speech encoding rule is two kinds, and second language coding rule is not that designated area is compiled
During code rule, then it is not to specify area code rule to judge that the sound code file to be detected has second language coding rule.
Alternatively, it is described to include the step of obtain sound code file to be detected:Obtain program source code file;Determining program source
Whether code file is default file type;When program source code file is the default file type, the sound code file is made
It is sound code file to be detected.
Alternatively, described program source code is stored using root form;It is described the step of obtain sound code file to be detected
Including:Obtain program source code file;Whether determining program sound code file belongs to default file catalogue;When program source code file belongs to
During default file catalogue, using the sound code file as sound code file to be detected.
Alternatively, it is described when the second language coding rule of the sound code file to be detected is not to specify area code rule
When then, then judge after the step of sound code file to be detected needs translation, also include:Progressive scan needs the source of translation
Code file;The row of translation is needed in the sound code file for determining the needs translation;Output it is described need translation sound code file and
It needs the row of translation.
Alternatively, the step of progressive scan needs the sound code file of translation, including:Judge the source for needing and translating
Whether contain annotation symbol in the row of code file;When in the row of the sound code file for needing and translating containing annotation symbol, jump
The content in this journey after annotation symbol is crossed to start to scan next line.
Alternatively, the step of progressive scan needs the sound code file of translation, including:Judge the source for needing and translating
Whether the initial character of the row of code file is preset characters;When the initial character of the row of the sound code file for needing and translating is predetermined word
Fu Shi, skips this journey and starts to scan next line.
According to second aspect, a kind of detection means of program's source code is the embodiment of the invention provides, it is adaptable to treatment
The electronic equipment of device, including:Acquiring unit, for obtaining sound code file to be detected;Judging unit, it is described to be checked for judging
The sound code file of survey is not to specify area code rule, the second language coding rule with the presence or absence of second language coding rule
It is the coding rule in addition to English coding rule;Identifying unit, for when the second language of the sound code file to be detected
Coding rule is not when specifying area code rule, then to judge that the sound code file to be detected needs translation.
Alternatively, the judging unit includes:First judgment sub-unit, for judging the sound code file to be detected in
Whether the number of species of the speech encoding rule for being used is more than default number of species;First judges subelement, for when described
When the number of species of speech encoding rule is more than default number of species, judge that the sound code file to be detected has second language
Coding rule is not to specify area code rule.
Alternatively, the judging unit includes:Second judgment sub-unit, for judging the sound code file to be detected in
Whether the species of the speech encoding rule for being used is two kinds;Second judges subelement, for when speech encoding rule
Number of species is two kinds, and second language coding rule is not when specifying area code rule, then to judge described to be detected
It is not to specify area code rule that sound code file has second language coding rule.
Alternatively, the acquiring unit includes:First obtains subelement, for obtaining program source code file;3rd judges
Whether subelement, be default file type for determining program sound code file;First determination subelement, for when program's source code text
When part is the default file type, using the sound code file as sound code file to be detected.
Alternatively, described program source code is stored using root form;The acquiring unit includes:Second obtains son list
Unit, for obtaining program source code file;Whether the 4th judgment sub-unit, default file mesh is belonged to for determining program sound code file
Record;Second determination subelement, for when program source code file belongs to default file catalogue, using the sound code file as to be checked
The sound code file of survey.
Alternatively, the detection means of described program source code also includes:Scanning element, for it is determined that needing the source code of translation
After file, progressive scan needs the sound code file of translation;Determining unit, in the sound code file for determining the needs translation
Need the row of translation;Output unit, for exporting the sound code file for needing translation and its row for needing translation.
Alternatively, the scanning element includes:5th judgment sub-unit, for judging the sound code file for needing and translating
Row in whether contain annotation symbol;First skips subelement, for containing when in the row of the sound code file for needing and translating
During annotation symbol, skip the content in this journey after annotation symbol and start to scan next line.
Alternatively, the scanning element includes:6th judgment sub-unit, for judging the sound code file for needing and translating
The initial character of row whether be preset characters;Second skips subelement, for the row when the sound code file for needing and translating
When initial character is preset characters, skips this journey and start to scan next line.
According to the third aspect, a kind of electronic equipment is the embodiment of the invention provides, including:At least one processor;And
The memory being connected with least one processor communication;Wherein, have can be by one processor for the memory storage
The instruction of execution, the instruction by least one computing device so that at least one computing device first party
The detection method of the program's source code described in the optional mode of any one of face or first aspect.
According to fourth aspect, a kind of non-transient computer readable storage medium storing program for executing is the embodiment of the invention provides, it is described non-temporary
State computer-readable recording medium storage computer instruction, the computer instruction is used to make the computer perform first aspect
Or the detection method of the program's source code described in any one optional mode of first aspect.
According to the 5th aspect, a kind of computer program product, the computer program product are the embodiment of the invention provides
Including storing the calculation procedure on non-transient computer readable storage medium storing program for executing, the computer program includes programmed instruction, when
Described program instruction is when being computer-executed, make the computer perform first aspect or first aspect any one is optional
The detection method of the program's source code described in mode.
The detection method of the program's source code that the embodiment of the present invention is provided, device and electronic equipment, obtain source to be detected
After code file, judge the coding rule in sound code file in addition to English coding rule whether be designated area coding rule,
If it is not, then judging that the sound code file needs translation.Because program's source code is often to connect organic assembling each other to realize that one is
Display function interface when system function, operation, therefore after the method obtains sound code file to be detected, when in the sound code file
Second language coding rule (coding rule i.e. in addition to English coding rule) be not specify area code rule when, then may be used
With judge sound code file need translation, it is possible thereby to find out for realize a certain systemic-function whole sound code files in all need
The word to be translated, consequently facilitating programming personnel's modification sound code file the content of display interface is designated area personnel can be with
The word understood.
The detection method of program's source code, device and electronic equipment that the present embodiment is provided, if employed in sound code file
The number of species of speech encoding rule is more than default number of species, then can be determined that sound code file has second language coding rule
It is not to specify area code rule, thus when the number of species of the speech encoding rule that sound code file is used is more, without
Judge whether used second language coding rule is designated area coding rule, such that it is able to quickly provide result of determination,
Improve the efficiency for judging;When the species of the voice coding rule employed in sound code file is two kinds, only the second language need to be judged
Whether speech coding rule is designated area coding rule, it is also possible to improve the efficiency for judging.
Brief description of the drawings
The features and advantages of the present invention can be more clearly understood from by reference to accompanying drawing, accompanying drawing is schematical without that should manage
Solution is to carry out any limitation to the present invention, in the accompanying drawings:
Fig. 1 shows the flow chart of the detection method of program's source code according to embodiments of the present invention;
Fig. 2A shows the flow chart of the detection method of program's source code according to another embodiment of the present invention;
Fig. 2 B show the flow chart of the detection method of the program's source code according to further embodiment of this invention;
Fig. 2 C show the flow chart of the detection method of the program's source code according to further embodiment of this invention;
Fig. 3 A show the flow chart of the detection method of the program's source code according to further embodiment of this invention;
Fig. 3 B show root storage form;
Fig. 3 C show the flow chart of the detection method of the program's source code according to further embodiment of this invention;
Fig. 3 D show the flow chart of the detection method of the program's source code according to further embodiment of this invention;
Fig. 4 shows the flow chart of the detection method of the program's source code according to further embodiment of this invention;
Fig. 5 shows the flow chart of the detection method of the program's source code according to further embodiment of this invention;
Fig. 6 shows the schematic diagram of the detection means of program's source code according to embodiments of the present invention;
Fig. 7 shows the schematic diagram of the detection means of program's source code according to another embodiment of the present invention;
Fig. 8 is that the hardware configuration of the electronic equipment of the detection method of configuration processor source code provided in an embodiment of the present invention is illustrated
Figure.
Specific embodiment
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention
In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
A part of embodiment of the present invention, rather than whole embodiments.Based on the embodiment in the present invention, those skilled in the art are not having
There is the every other embodiment made and being obtained under the premise of creative work, belong to the scope of protection of the invention.
Fig. 1 shows the flow chart of the detection method of program's source code according to embodiments of the present invention, and the method can be applicable
In the electronic equipment with processor such as computer.According to Fig. 1 illustrated embodiments, the detection method of program's source code is including as follows
Step:
S101:Obtain sound code file to be detected.Sound code file to be detected can be for realizing a certain systemic-function
All sound code files, or by the part in all sound code files after screening.
S102:Judge that sound code file to be detected is not to specify area code rule with the presence or absence of second language coding rule
Then, the second language coding rule is the coding rule in addition to English coding rule.If in the presence of execution step S103;It is no
Then, then judge that the sound code file to be detected need not be translated.
Speech encoding rule determines how word content shows when being run for source code program.For example, in html classes
The sound code file of type<head>Below can followed by such code:“<Meta http-equiv=" Content-
Type " content=" text/html;Charset=gb2312 "/>”.
" charset=gb2312 " represents the speech encoding rule of the sound code file, and it tells that browser this document is used
Simplified form of Chinese Character coding rule.For example in sound code file browser is controlled to show " hello " by program source code, browser passes through
" charset=gb2312 " learns to be needed for " hello " in sound code file to be shown as simplified form of Chinese Character.Usual sound code file is informed
The speech encoding rule that browser is used is corresponding with the word in sound code file, and otherwise browser can be by sound code file
In text importing be mess code.
Similar voice coding rule also has Chinese-traditional coding (charset=big5), Korean coding (charset=
Euc_kr), Japanese coding (charset=shift_jis or euc_jp), Russian coding (charset=koi8-r/
Windows-1251), ISO coding (including Dutch, English, French, German, Italian, Norwegian, Portugal
18 kinds of language such as language, Swiss) (charset=iso-8859-1), Central European family of languages coding (charset=iso-8859-2)
Encoded (charset=iso-8859-5) etc. with the Slav family of languages.
Second language coding rule is the coding rule in addition to English coding rule, and English coding rule here includes
Can be used for the coding of English display, such as unicode codings (charset=uft-8).The English coding rule can be used for
Display English alphabet, numeral etc., usual every country and area can recognize English alphabet and numeral, therefore judge speech encoding
Rule whether can be designated the personnel in area when understanding without the concern for English alphabet and numeral, i.e. second language coding rule not
Including English coding rule.
It should be added that, the above-mentioned sound code file that simply show html types is used to indicate language coding rule
Form.Sound code file is not limited to the sound code file of html types during actual implementation this method, can also include other classes
The sound code file of type, such as sound code file of python, php, js, jsp, java type, use in the sound code file of these types
In indicate language coding rule sentence with specific reference to its programming rule.
S103:Judge that the sound code file to be detected needs translation.Employed in the sound code file to be detected specified
The language that the personnel in area can not understand is, it is necessary to the language that the language translation can be understood into them.
The detection method of the program's source code that the present embodiment is provided, after obtaining sound code file to be detected, judges to be detected
Whether the coding rule in sound code file in addition to English coding rule is the coding rule of designated area, if it is not, then judging
The sound code file to be detected needs translation.Because program's source code is often to connect organic assembling each other to realize a system work(
Display function interface when can, run, therefore after the method obtains sound code file to be detected, when the source code to be detected
Second language coding rule (coding rule i.e. in addition to English coding rule) in file is not to specify area code rule
When, then can be determined that sound code file to be detected needs translation, it is possible thereby to find out the whole for realizing a certain systemic-function
The word of translation is all needed in sound code file, consequently facilitating programming personnel's modification sound code file is the content of display interface
The word that designated area personnel can understand.
Fig. 2A shows the flow chart of the detection method of program's source code according to another embodiment of the present invention, and the method can be with
Suitable for the electronic equipment with processor such as computer.According to Fig. 2A illustrated embodiments, the detection method bag of program's source code
Include following steps:
Step S201:Obtain sound code file to be detected.The step is similar with step S101 shown in Fig. 1, no longer goes to live in the household of one's in-laws on getting married herein
State.
S202:Judge whether the number of species of the speech encoding rule employed in sound code file to be detected is more than to preset
Number of species.If so, then performing step S203;Otherwise perform other operations.
S203:It is not to specify area code rule to judge that sound code file to be detected has second language coding rule.
If for example, the personnel in somewhere can recognize three kinds of language in addition to English, can be determined that if the second language
Say that the number of species of coding rule is more than 4, then the sound code file necessarily needs translation, the i.e. sound code file to there is second language volume
Code rule is not to specify area code rule.
S204:Judge that the sound code file to be detected needs translation.The step is similar with step S103 shown in Fig. 1, herein
Repeat no more.
Fig. 2 B show the flow chart of the detection method of the program's source code according to further embodiment of this invention, and the method can be with
Suitable for the electronic equipment with processor such as computer.According to Fig. 2 B illustrated embodiments, the detection method bag of program's source code
Include following steps:
Step S205:Obtain sound code file to be detected.The step is similar with step S101 shown in Fig. 1, no longer goes to live in the household of one's in-laws on getting married herein
State.
S206:Whether the species for judging the speech encoding rule employed in sound code file to be detected is two kinds.If so,
Then perform step S207;Otherwise, other operations are performed.
S207:Judge that second language coding rule is designated area coding rule, if it is not, then performing step
S208;Otherwise, it is determined that sound code file to be detected is not to specify area code rule in the absence of second language coding rule, then
Can be determined that sound code file to be detected need not be translated.
S208:It is not to specify area code rule to judge that sound code file to be detected has second language coding rule.
S209:Judge that the sound code file to be detected needs translation.The step is similar with step S103 shown in Fig. 1, herein
Repeat no more.
When the coding rule of designated area only has a kind of in addition to English, two kinds of implementation methods shown in Fig. 2A and 2B can be with
With reference to.Fig. 2 C show the flow chart of the detection method of the program's source code according to further embodiment of this invention, and the method can be fitted
For the electronic equipment with processor such as computer.According to Fig. 2 C illustrated embodiments, the detection method of program's source code includes
Following steps:
Step S210:Obtain sound code file to be detected.The step is similar with step S101 shown in Fig. 1, no longer goes to live in the household of one's in-laws on getting married herein
State.
S211:Judge whether the number of species of the speech encoding rule employed in sound code file to be detected is more than 3 kinds.
If so, then performing step S214;Otherwise, step S212 is performed.
S212:Whether the species for judging the speech encoding rule employed in sound code file to be detected is two kinds.If so,
Then perform step S213;Otherwise, it is determined that sound code file to be detected is not that designated area is compiled in the absence of second language coding rule
Code rule.
S213:Judge that second language coding rule is designated area coding rule, if so, then judging source to be detected
Code file is not to specify area code rule in the absence of second language coding rule;Otherwise, step S214 is performed.
S214:It is not to specify area code rule to judge that sound code file to be detected has second language coding rule.
S215:Judge that the sound code file to be detected needs translation.The step is similar with step S103 shown in Fig. 1, herein
Repeat no more.
The detection method of the program's source code that the present embodiment is provided, if the speech encoding employed in sound code file to be detected
The number of species of rule is more than default number of species, then can be determined that sound code file to be detected has second language coding rule
It is not to specify area code rule, the number of species of the speech encoding rule for thus being used when sound code file to be detected is more
When, without judging whether used second language coding rule is designated area coding rule, sentence such that it is able to quick being given
Determine result, improve the efficiency for judging;When the species of the voice coding rule employed in sound code file to be detected is two kinds,
Only need to judge whether second language coding rule is designated area coding rule, it is also possible to improve the efficiency for judging.
Fig. 3 A show the flow chart of the detection method of the program's source code according to further embodiment of this invention, and the method can be with
Suitable for the electronic equipment with processor such as computer.According to Fig. 3 A illustrated embodiments, the detection method bag of program's source code
Include following steps:
S301:Obtain program source code file.
S302:Whether determining program sound code file is default file type.If so, then performing step S303;Otherwise, it is determined that
The program source code file is not sound code file to be detected, then can be determined that sound code file to be detected need not be translated.It is logical
It is usually used in control display interface and shows that the program's source code of which content exists only in some specific file types in what manner
In, these specific file types (i.e. default file type) are the file that possible include the speech encoding rule in addition to English
Type, for example, python, php, js, jsp, java type.
S303:Using sound code file as sound code file to be detected.
S304:Judge that sound code file to be detected is not to specify area code rule with the presence or absence of second language coding rule
Then, the second language coding rule is the coding rule in addition to English coding rule.If in the presence of execution step S305;It is no
Then, then judge that the sound code file to be detected need not be translated.
S305:Judge that the sound code file to be detected needs translation.
As shown in Figure 3 B, program source code file includes B, C, D file, B generally using the storage of root form under A files
Include b1, b2 and b3 file under file again, include d1, d2 and d3 file under D files again, then the catalogue of file b1 is A/B/b1,
The file directory of alternative document can accordingly be obtained.Fig. 3 C show the detection method of the program's source code according to further embodiment of this invention
Flow chart, the method goes for the electronic equipment with processor such as computer.According to Fig. 3 C illustrated embodiments, journey
The detection method of sequence source code comprises the following steps:
S306:Obtain program source code file.
S307:Whether determining program sound code file belongs to default file catalogue.If belonging to, step S308 is performed;Otherwise,
Judge that the program source code file is not sound code file to be detected, then can be determined that the sound code file need not be translated.
S308:Using sound code file as sound code file to be detected.Sound code file conduct that will be under default file catalogue
Sound code file to be detected.
Under normal circumstances, file type identical file can be organized under identical file catalogue, for example, file b1, b2 and
The file that b3 is under js files, i.e. file directory A/B is js files, then in detection, the file under this document catalogue is equal
It is file to be detected.
S309:Judge that sound code file to be detected is not to specify area code rule with the presence or absence of second language coding rule
Then, the second language coding rule is the coding rule in addition to English coding rule.If in the presence of execution step S310;It is no
Then, then judge that the sound code file to be detected need not be translated.
S310:Judge that the sound code file to be detected needs translation.
When program source code file is generally stored using root form, two kinds of implementation methods can be tied shown in Fig. 3 A and 3C
Close.Fig. 3 D show the flow chart of the detection method of the program's source code according to further embodiment of this invention, and the method can be applicable
In the electronic equipment with processor such as computer.According to Fig. 3 D illustrated embodiments, the detection method of program's source code is included such as
Lower step:
S311:Obtain program source code file.
S312:Whether determining program sound code file belongs to default file catalogue.If belonging to, step S313 is performed;Otherwise,
Judge that the program source code file is not sound code file to be detected, then can be determined that the sound code file need not be translated.
S313:Whether determining program sound code file is default file type.If so, then performing step S312;Otherwise, it is determined that
The program source code file is not sound code file to be detected, then can be determined that the sound code file need not be translated.
S314:Using sound code file as sound code file to be detected.
S315:Judge that sound code file to be detected is not to specify area code rule with the presence or absence of second language coding rule
Then, the second language coding rule is the coding rule in addition to English coding rule.If in the presence of execution step S316;It is no
Then, then judge that the sound code file to be detected need not be translated.
S316:Judge that the sound code file to be detected needs translation.
The detection method of the program's source code that the present embodiment is provided, by the sound code file of default file type and/or belongs to pre-
If the sound code file of file directory is used as file to be detected, it is possible to reduce need the quantity of documents of detection, detection efficiency is improved.
Fig. 4 shows the flow chart of the detection method of the program's source code according to further embodiment of this invention, and the method can be with
Suitable for the electronic equipment with processor such as computer.According to Fig. 4 illustrated embodiments, the detection method of program's source code includes
Following steps:
S401:Obtain sound code file to be detected.
S402:Judge that sound code file to be detected is not to specify area code rule with the presence or absence of second language coding rule
Then, the second language coding rule is the coding rule in addition to English coding rule.If in the presence of execution step S403;It is no
Then, then judge that the sound code file to be detected need not be translated.
S403:Judge that the sound code file to be detected needs translation.
S404:Progressive scan needs the sound code file of translation.
S405:It is determined that needing the row of translation in needing the sound code file translated.
S406:Output needs the sound code file of translation and its needs the row of translation.
When output needs the sound code file of translation, the title of sound code file can be exported, it is also possible to export sound code file
File directory and file name.
Alternatively, the regular and its shared ratio of speech encoding employed in the sound code file for needing translation can also be exported
Example.
It is alternatively possible to will need the content for exporting with file (such as txt file) or compressed package (such as including all need
The sound code file to be translated, or need translation word content and its position) form output, it is also possible to will need translation
Sound code file (including file content and/file directory) and its need translation row (including capable position, i.e. which row, and/
Or the row content) exported in the form of html files.
The detection method of the program's source code that the present embodiment is provided, progressive scan needs the sound code file of translation, it is determined that needing
After the row of translation is needed in the sound code file of translation, it would be desirable to the sound code file of translation and its row output of needs translation, programming
Personnel can be quickly found out according to output file needs content and the position of translation, improves the efficiency of modification program code.
Fig. 5 shows the flow chart of the detection method of the program's source code according to further embodiment of this invention, and the method can be with
Suitable for the electronic equipment with processor such as computer.According to Fig. 5 illustrated embodiments, the detection method of program's source code includes
Following steps:
S501:Obtain sound code file to be detected.
S502:Judge that sound code file to be detected is not to specify area code rule with the presence or absence of second language coding rule
Then, the second language coding rule is the coding rule in addition to English coding rule.If in the presence of execution step S503;It is no
Then, then judge that the sound code file to be detected need not be translated.
S503:Judge that the sound code file to be detected needs translation.
S504:Whether the initial character for judging the row of the sound code file for needing translation is preset characters.If so, then performing step
S505;Otherwise continue to scan on.
Symbol for multirow annotation generally includes a pair of symbols, referred to herein as preceding annotation symbol, rear annotation symbol, in annotation
It is placed between this pair of symbol, preceding annotation symbol and rear annotation symbol can be spaced multirow, and the content between them is notes content,
Any function can not be realized, only aided programming personnel understand program.It is with multirow annotation symbol "/* multirows annotate */"
Example, general comment custom is as follows:
I.e. when notes content is accorded with and rear annotation symbol between but accorded with not in same a line with forward and backward annotation in preceding annotation, change one's profession
Can be started with " * ", behind write notes content again, it is generally the case that in order to keep neat, should also have space before " * ".
S505:This journey is skipped to start to scan next line.Use the example above, it is clear that the second row, the third line, the 4th of annotation word
Row falls within annotation word, when not having annotation symbol in the row, therefore, it can the custom according to annotation, if the head in the row
Character is " * ", then can be determined that the behavior annotates word, for annotation word, can skip and not scan.
S506:Whether contain annotation symbol in the row for judging the sound code file for needing translation.If it does, then performing step
S507;Otherwise continue to scan on.
The annotation symbol is different according to the different meetings of programming rule of different file types, specifically can be according to program's source code
Concrete condition depending on.For example, the annotation rule of java language includes:" // single file annotation ", "/* multirows annotate */";Css generations
The annotation rule of code includes:"/* multirows annotate */";The annotation rule of html codes includes:“<!-- annotation -->”;Python languages
The annotation rule of speech includes:" #coding=utf-8 " ... is it can thus be seen that annotation symbol includes " // ", " # ", "/* is more
Row annotation */",<!-- annotation -->”.
S507:The content in this journey after annotation symbol is skipped to start to scan next line.
S508:It is determined that needing the row of translation in needing the sound code file translated.
S509:Output needs the sound code file of translation and its needs the row of translation.
The detection method of the program's source code that the present embodiment is provided, does not scan when progressive scan needs the sound code file of translation
Annotation word, the content after skipping annotation symbol when single file annotation symbol is run into continues to scan on next line, is running into multirow note
The content that the multirow comment statement block is skipped when releasing symbol continues to scan on next line, such that it is able to improve the efficiency of detection.
The embodiment of the invention provides a kind of detection means of program's source code, it is adaptable to the electricity with processor such as computer
Sub- equipment, is realized by the electronic equipment.The detection method of the program's source code of the present embodiment can be used for the embodiment of the present invention
The detection means of program's source code, the detection means of the program's source code can be used for performing the journey described in the above embodiment of the present invention
The detection method of sequence source code.
Fig. 6 shows the schematic diagram of the detection means of program's source code according to embodiments of the present invention, the inspection of the program's source code
Survey device and be applied to the electronic equipments with processor such as computer.According to Fig. 6 illustrated embodiments, the detection of program's source code is filled
Put including acquiring unit 10, judging unit 20 and identifying unit 30.
The acquiring unit 10, for obtaining sound code file to be detected.
The judging unit 20, for judging that sound code file to be detected is not specified with the presence or absence of second language coding rule
Area code rule, the second language coding rule is the coding rule in addition to English coding rule.
The identifying unit 30, for when sound code file second language coding rule be not specify area code rule when,
Then judge that sound code file needs translation.
Optionally, judging unit 20 includes that the first judgment sub-unit 21 and first judges subelement 22.
First judgment sub-unit 21, for judge employed in sound code file speech encoding rule number of species be
It is no more than default number of species.
The first judgement subelement 22, for when the number of species of speech encoding rule is more than default number of species, sentencing
Determine sound code file to have second language coding rule is not to specify area code rule.
Optionally, judging unit 20 includes that the second judgment sub-unit 23 and second judges subelement 24.
Second judgment sub-unit 23, for judge employed in sound code file speech encoding rule species whether be
Two kinds.
The second judgement subelement 24, for being two kinds when the number of species of speech encoding rule, and second language is compiled
Code rule is not that when specifying area code rule, then it is not that designated area is compiled to judge that sound code file has second language coding rule
Code rule.
Optionally, acquiring unit 10 includes that first obtains subelement 11, the 3rd judgment sub-unit 12 and the first determination son list
Unit 13.
The first acquisition subelement 11, for obtaining program source code file.
Whether the 3rd judgment sub-unit 12, be default file type for determining program sound code file.
First determination subelement 13, for when program source code file is default file type, using sound code file as
Sound code file to be detected.
Optionally, when program's source code using root form store when, acquiring unit 10 include second obtain subelement 14,
4th judgment sub-unit 15 and the second determination subelement 16.
The second acquisition subelement 14, for obtaining program source code file.
Whether the 4th judgment sub-unit 15, default file catalogue is belonged to for determining program sound code file.
Second determination subelement 16, for when program source code file belongs to default file catalogue, sound code file being made
It is sound code file to be detected.
The detection means of the program's source code that the present embodiment is provided, after obtaining sound code file to be detected, judges sound code file
In coding rule in addition to English coding rule whether be the coding rule of designated area, if it is not, then judging source code text
Part needs translation.Because program's source code is often to connect display function when organic assembling realizes a systemic-function, operation each other
Interface, therefore after the method obtains sound code file to be detected, when the second language coding rule in the sound code file (i.e.
Coding rule in addition to English coding rule) it is not that when specifying area code rule, then can be determined that sound code file needs to turn over
Translate, it is possible thereby to find out for realize a certain systemic-function whole sound code files in all need translation word so that just
The content of display interface is set to be the word that designated area personnel understand in programming personnel's modification sound code file.
Fig. 7 shows the schematic diagram of the detection means of program's source code according to another embodiment of the present invention, the program's source code
Detection means be applied to the electronic equipment with processor such as computer.According to Fig. 7 illustrated embodiments, the inspection of program's source code
Surveying device includes acquiring unit 10, judging unit 20 and identifying unit 30, scanning element 40, determining unit 50 and output unit
60。
The acquiring unit 10, for obtaining sound code file to be detected.
The judging unit 20, for judging that sound code file to be detected is not specified with the presence or absence of second language coding rule
Area code rule, the second language coding rule is the coding rule in addition to English coding rule.
The identifying unit 30, for when sound code file second language coding rule be not specify area code rule when,
Then judge that sound code file needs translation.
The scanning element 40, the sound code file of translation is needed for progressively scanning.
The determining unit 50, the row for needing translation in the sound code file for determining to need translation.
The output unit 60, the sound code file that translation is needed for exporting and its row for needing translation.
Optionally, scanning element 40 skips subelement 42 including the 5th judgment sub-unit 41 and first.
5th judgment sub-unit 41, for whether containing annotation symbol in the row of the sound code file for judging to need translation.
This first skips subelement 42, for when in needing the row of sound code file of translation containing annotation symbol, skipping
Content in this journey after annotation symbol starts to scan next line.
Optionally, scanning element 40 skips subelement 44 including the 6th judgment sub-unit 43 and second.
6th judgment sub-unit 43, whether the initial character for the row of the sound code file for judging to need translation is predetermined word
Symbol.
This second skips subelement 44, for when the initial character for needing the row of sound code file of translation is preset characters,
This journey is skipped to start to scan next line.
Fig. 8 is that the hardware configuration of the electronic equipment of the detection method of configuration processor source code provided in an embodiment of the present invention is illustrated
Figure, as shown in figure 8, the equipment includes one or more processors 810 and memory 820.Memory 820 is stored with and can be located
The instruction that reason device is performed, the instruction is performed by least one processor 810, so that at least one computing device present invention is above-mentioned
The detection method of the program's source code of embodiment, and realize the above embodiment of the present invention program's source code detection means in each list
The function of unit.
In Fig. 8 by taking a processor 810 as an example.
The equipment of the detection method of configuration processor source code can also include:Input unit 830 and output device 840.
Processor 810, memory 820, input unit 830 and output device 840 can be by bus or other modes
Connection, in Fig. 8 as a example by being connected by bus.
Processor 810 can be central processing unit (Central Processing Unit, CPU).Processor 810 may be used also
Think other general processors, digital signal processor (Digital Signal Processor, DSP), application specific integrated circuit
(Application Specific Integrated Circuit, ASIC), field programmable gate array (Field-
Programmable Gate Array, FPGA) or other PLDs, discrete gate or transistor logic,
The chips such as discrete hardware components, or above-mentioned all kinds of chips combination.General processor can be microprocessor or the treatment
Device can also be any conventional processor etc..
Memory 820 can be used to storing non-transient software program, non-as a kind of non-transient computer readable storage medium storing program for executing
The corresponding program of detection method of the program's source code in transient computer executable program and module, such as the embodiment of the present application refers to
Order/module.Processor 810 passes through to run the non-transient software program stored in memory 820, instruction and module, so that
The various function application of execute server and data processing, that is, realize the detection method of above method embodiment program's source code.
Memory 820 can include storing program area and storage data field, wherein, storing program area can store operation system
Application program required for system, at least one function;Storage data field can store the use of the detection means according to program's source code
Data for being created etc..Additionally, memory 820 can include high-speed random access memory, non-transient storage can also be included
Device, for example, at least one disk memory, flush memory device or other non-transient solid-state memories.In certain embodiments,
Memory 820 is optional including the memory remotely located relative to processor 810, and these remote memories can be connected by network
It is connected to the detection means of program's source code.The example of above-mentioned network includes but is not limited to internet, intranet, LAN, shifting
Dynamic communication network and combinations thereof.
Input unit 830 can receive the numeral or character information of input, and produce and the detection means of program's source code
The key signals input that user is set and function control is relevant.Output device 840 may include the display devices such as display screen.
One or more of modules are stored in the memory 820, when by one or more of processors
During 810 execution, method as Figure 1-5 is performed.
The method that the executable embodiment of the present invention of the said goods is provided, possesses the corresponding functional module of execution method and has
Beneficial effect.Ins and outs of detailed description in the present embodiment, not for details, reference can be made to the correlation in embodiment as Figure 1-5
Description.
The embodiment of the present invention additionally provides a kind of non-transient computer storage medium, and the computer-readable storage medium is stored with
Computer executable instructions, the computer executable instructions can perform the detection of the program's source code in above-mentioned any means embodiment
Method.Wherein, the storage medium can be magnetic disc, CD, read-only memory (Read-Only Memory, ROM), random
Storage memory (Random Access Memory, RAM), flash memory (Flash Memory), hard disk (Hard Disk
Drive, abbreviation:) or solid state hard disc (Solid-State Drive, SSD) etc. HDD;The storage medium can also include above-mentioned
The combination of the memory of species.
It will be understood by those skilled in the art that all or part of flow in realizing above-described embodiment method, can be logical
Computer program is crossed to instruct the hardware of correlation to complete, described program can be stored in a computer read/write memory medium
In, the program is upon execution, it may include such as the flow of the embodiment of above-mentioned each method.Wherein, described storage medium can be magnetic
Dish, CD, read-only memory (ROM) or random access memory (RAM) etc..
Although being described in conjunction with the accompanying embodiments of the invention, those skilled in the art can not depart from the present invention
Spirit and scope in the case of various modification can be adapted and modification, such modification and modification are each fallen within by appended claims institute
Within the scope of restriction.
Claims (17)
1. a kind of detection method of program's source code, it is characterised in that including:
Obtain sound code file to be detected;
Judge that the sound code file to be detected is not to specify area code rule with the presence or absence of second language coding rule, it is described
Second language coding rule is the coding rule in addition to English coding rule;
When the second language coding rule of the sound code file to be detected is not when specifying area code rule, then to judge described
Sound code file to be detected needs translation.
2. the detection method of program's source code according to claim 1, it is characterised in that the judgement source to be detected
Code file is not that the step for specifying area code rule includes with the presence or absence of second language coding rule:
Judge whether the number of species of the speech encoding rule employed in the sound code file to be detected is more than default species
Quantity;
When the number of species of speech encoding rule is more than default number of species, judge that the sound code file to be detected is deposited
It is not to specify area code rule in second language coding rule.
3. the detection method of program's source code according to claim 1 and 2, it is characterised in that the judgement is described to be detected
Sound code file with the presence or absence of second language coding rule be not specify area code rule step include:
Whether the species for judging the speech encoding rule employed in the sound code file to be detected is two kinds;
When the number of species of speech encoding rule is two kinds, and second language coding rule is not to specify area code rule
When then, then it is not to specify area code rule to judge that the sound code file to be detected has second language coding rule.
4. the detection method of program's source code according to claim 1, it is characterised in that acquisition source code text to be detected
The step of part, includes:
Obtain program source code file;
Whether determining program sound code file is default file type;
When program source code file is the default file type, using the sound code file as sound code file to be detected.
5. the detection method of the program's source code according to claim 1 or 4, it is characterised in that described program source code uses root
Catalogue form is stored;It is described to include the step of obtain sound code file to be detected:
Obtain program source code file;
Whether determining program sound code file belongs to default file catalogue;
When program source code file belongs to default file catalogue, using the sound code file as sound code file to be detected.
6. the detection method of program's source code according to claim 1, it is characterised in that described when the source code to be detected
The second language coding rule of file is not when specifying area code rule, then to judge that the sound code file to be detected needs to turn over
After the step of translating, also include:
Progressive scan needs the sound code file of translation;
The row of translation is needed in the sound code file for determining the needs translation;
The output sound code file for needing translation and its row for needing translation.
7. the detection method of program's source code according to claim 6, it is characterised in that the progressive scan needs translation
The step of sound code file, including:
Whether contain annotation symbol in the row for judging the sound code file for needing translation;
When in the row of the sound code file for needing translation containing annotation symbol, the content after annotation symbol in this journey is skipped
Start to scan next line.
8. the detection method of the program's source code according to claim 6 or 7, it is characterised in that the progressive scan needs to turn over
The step of sound code file translated, including:
Whether the initial character for judging the row of the sound code file for needing translation is preset characters;
When the initial character of the row of the sound code file for needing and translating is preset characters, skips this journey and start to scan next line.
9. a kind of detection means of program's source code, it is characterised in that including:
Acquiring unit, for obtaining sound code file to be detected;
Judging unit, for judging that the sound code file to be detected is not designated area with the presence or absence of second language coding rule
Coding rule, the second language coding rule is the coding rule in addition to English coding rule;
Identifying unit, is not to specify area code rule for the second language coding rule when the sound code file to be detected
When, then judge that the sound code file to be detected needs translation.
10. the detection means of program's source code according to claim 9, it is characterised in that the judging unit includes:
First judgment sub-unit, the species number for judging the speech encoding rule employed in the sound code file to be detected
Whether amount is more than default number of species;
First judges subelement, for when the number of species of speech encoding rule is more than default number of species, judging institute
State sound code file to be detected to have second language coding rule is not to specify area code rule.
The detection means of 11. program's source code according to claim 9 or 10, it is characterised in that the judging unit includes:
Second judgment sub-unit, for judge employed in the sound code file to be detected speech encoding rule species be
No is two kinds;
Second judges subelement, for being two kinds when the number of species of speech encoding rule, and second language coding rule
It is not then when specifying area code rule, then to judge that the sound code file to be detected has second language coding rule and do not refer to
Determine area code rule.
The detection means of 12. program's source codes according to claim 9, it is characterised in that the acquiring unit includes:
First obtains subelement, for obtaining program source code file;
Whether the 3rd judgment sub-unit, be default file type for determining program sound code file;
First determination subelement, for when program source code file is the default file type, using the sound code file as
Sound code file to be detected.
The detection means of 13. program's source code according to claim 9 or 12, it is characterised in that described program source code is used
Root form is stored;The acquiring unit includes:
Second obtains subelement, for obtaining program source code file;
Whether the 4th judgment sub-unit, default file catalogue is belonged to for determining program sound code file;
Second determination subelement, for when program source code file belongs to default file catalogue, using the sound code file as treating
The sound code file of detection.
The detection means of 14. program's source codes according to claim 9, it is characterised in that also include:
Scanning element, for it is determined that after the sound code file for needing translation, progressive scan needs the sound code file of translation;
Determining unit, the row for needing translation in the sound code file for determining the needs translation;
Output unit, for exporting the sound code file for needing translation and its row for needing translation.
The detection means of 15. program's source codes according to claim 14, it is characterised in that the scanning element includes:
5th judgment sub-unit, for whether containing annotation symbol in the row for judging the sound code file for needing translation;
First skips subelement, for when annotation symbol is contained in the row of the sound code file for needing and translating, skipping this journey
Content after middle annotation symbol starts to scan next line.
The detection means of 16. program's source code according to claims 14 or 15, it is characterised in that the scanning element bag
Include:
6th judgment sub-unit, for judging whether the initial character of row of the sound code file for needing translation is preset characters;
Second skips subelement, when the initial character for the row when the sound code file for needing and translating is preset characters, skips
This journey starts to scan next line.
17. a kind of electronic equipment, including:
At least one processor;
And the memory being connected with least one processor communication;Wherein, have can be by described one for the memory storage
The instruction of individual computing device, the instruction is by least one computing device, so that at least one processor is held
The detection method of the program's source code any one of row claim 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610990856.7A CN106844192A (en) | 2016-11-10 | 2016-11-10 | A kind of detection method of program's source code, device and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610990856.7A CN106844192A (en) | 2016-11-10 | 2016-11-10 | A kind of detection method of program's source code, device and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106844192A true CN106844192A (en) | 2017-06-13 |
Family
ID=59145782
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610990856.7A Pending CN106844192A (en) | 2016-11-10 | 2016-11-10 | A kind of detection method of program's source code, device and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106844192A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107608875A (en) * | 2017-08-03 | 2018-01-19 | 北京奇安信科技有限公司 | A kind of localization process method and device of static code |
CN109814874A (en) * | 2019-02-20 | 2019-05-28 | 湖南国科微电子股份有限公司 | A kind of compiling result output control method, system and application |
-
2016
- 2016-11-10 CN CN201610990856.7A patent/CN106844192A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107608875A (en) * | 2017-08-03 | 2018-01-19 | 北京奇安信科技有限公司 | A kind of localization process method and device of static code |
CN109814874A (en) * | 2019-02-20 | 2019-05-28 | 湖南国科微电子股份有限公司 | A kind of compiling result output control method, system and application |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108038134B (en) | Page display method and device, storage medium and electronic equipment | |
CN102662944B (en) | By the direct navigation of browser address bar | |
CN105868166B (en) | Regular expression generation method and system | |
CN104899016B (en) | Allocating stack Relation acquisition method and device | |
CN111124479B (en) | Method and system for analyzing configuration file and electronic equipment | |
US10067918B2 (en) | Encoding text units | |
CN105653949B (en) | A kind of malware detection methods and device | |
CN109002483A (en) | Document management method, device, computer equipment and storage medium | |
US8677314B1 (en) | Modifying a source code file to reduce dependencies included therein | |
CN107783946A (en) | Text display method and text display | |
CN111444453A (en) | Page return data processing method and device | |
CN106844192A (en) | A kind of detection method of program's source code, device and electronic equipment | |
CN106970758A (en) | Electronic document operation processing method, device and electronic equipment | |
CN106502707B (en) | Code generation method and device | |
CN109358919B (en) | Dynamic configuration method and device for universal page, computer equipment and storage medium | |
US20170010805A1 (en) | Character Input Method and Electronic Device | |
US11120099B2 (en) | Rendering a web element in a web page | |
CN107562423B (en) | UI page development method and device | |
CN110020343B (en) | Method and device for determining webpage coding format | |
CN112130908A (en) | Method and device for setting user guide | |
CN113704819B (en) | Coding output method and device of application log and computer readable storage medium | |
CN105279247A (en) | Expression library generation method and device | |
CN103970874A (en) | Method and device for processing Hadoop files | |
CN110083576B (en) | Cache directory identification method and device | |
CN108428189B (en) | Social resource processing method and device and readable medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20170613 |
|
WD01 | Invention patent application deemed withdrawn after publication |