CN114003489A - Front-end code file detection method and device, electronic equipment and storage medium - Google Patents

Front-end code file detection method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114003489A
CN114003489A CN202111165055.4A CN202111165055A CN114003489A CN 114003489 A CN114003489 A CN 114003489A CN 202111165055 A CN202111165055 A CN 202111165055A CN 114003489 A CN114003489 A CN 114003489A
Authority
CN
China
Prior art keywords
file
code
language
determining
configuration
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.)
Granted
Application number
CN202111165055.4A
Other languages
Chinese (zh)
Other versions
CN114003489B (en
Inventor
王凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202111165055.4A priority Critical patent/CN114003489B/en
Publication of CN114003489A publication Critical patent/CN114003489A/en
Application granted granted Critical
Publication of CN114003489B publication Critical patent/CN114003489B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Stored Programmes (AREA)

Abstract

The application discloses a front-end code file detection method, a front-end code file detection device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring a configuration file corresponding to each language type; determining a folder where a target front end code needing to be detected is located, and determining code files with suffixes of vue and js in the folder; scanning each code file line by line, and determining a code comprising a naming space of multi-language configuration and a key definition; querying a naming space and a key definition in a configuration file corresponding to each language type, if return values of the configuration files corresponding to all the language types are not received, determining the naming space as a target naming space, and determining the key definition as a target key definition; and outputting the target name space, the target key definition, the line number of the file where the corresponding code is located, the file path and the language type of the unreceived return value. The method and the device realize the automatic detection of the multi-language configuration of the target front-end code file in the development stage.

Description

Front-end code file detection method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for detecting a front-end code file, an electronic device, and a computer-readable storage medium.
Background
Js is increasingly being applied to actual project development as a popular front-end development framework. In some projects, to provide services to users of multiple language environments simultaneously, requires that products must implement international language switching. Vue-i18n is an internationalized plug-in provided by Vue. js official, provides a concise API and powerful functions, and can realize multi-language support of products by combining with Vue. js through simple configuration.
To implement the international multi-language switching function in product development, it is a common practice that multi-language files must be configured according to the specification Vue-i18n, and an Application Programming Interface (API) is called in service codes to implement automatic rendering. If the multi-language configuration is missed in the development process or the translation is realized by forgetting to call the API, research personnel can only check whether the multi-language configuration is perfect or correct by testing on a UI (User Interface Design) Interface. For example, research and development personnel may only configure a chinese language package and forget to configure an english language package, which may cause blank fields on a UI interface or even direct errors when a system product is switched to english, or even some system BUGs that are not easy to find, thereby seriously affecting user experience and product stability. In the related art, the detection of the multi-language configuration can only be performed in a mode of UI interface test, and a great deal of effort of research and development personnel is required to be consumed, so that the development efficiency is seriously influenced.
Therefore, how to implement automatic detection of multiple language configurations in the front-end code is a technical problem to be solved by those skilled in the art.
Disclosure of Invention
The application aims to provide a method and a device for detecting a front-end code file, an electronic device and a computer readable storage medium, which realize automatic detection of multi-language configuration in a front-end code.
In order to achieve the above object, the present application provides a front-end code file detection method, including:
acquiring a configuration file corresponding to each language type;
determining a folder where a target front end code needing to be detected is located, and determining code files with suffixes of vue and js in the folder;
scanning each code file line by line, and determining a code comprising a naming space of multi-language configuration and a key definition;
querying the name space and the key definition in the configuration file corresponding to each language type, if the return values of the configuration files corresponding to all the language types are not received, determining the name space as a target name space, and determining the key definition as a target key definition;
and outputting the target name space, the target key definition, the line number of the file where the corresponding code is located, the file path and the language type of the unreceived return value.
The obtaining of the configuration file corresponding to each language category includes:
reading a multi-language configuration file in a front-end code warehouse, and respectively caching the file content of the multi-language configuration file into a plurality of configuration files according to the language types.
Wherein code files for which all suffixes are. vue and.js are determined in the folder, include:
code files for all suffixes, vue and js, except for the multilingual configuration file, are determined in the folder.
Wherein, after determining the code files with all suffixes of. vue and.js in the folder, the method further comprises the following steps:
caching the code file into a temporary directory;
correspondingly, the scanning each code file line by line includes:
and scanning the code files in the temporary directory line by line.
Wherein, still include:
and outputting the line number, Chinese field and file path of the file containing the Chinese code.
Wherein, the scanning each code file line by line, determining the code containing the naming space of multi-language configuration and key definition, includes:
scanning each code file line by line, and determining a code containing a multi-language standard application programming interface as a code containing a multi-language configuration namespace and a key definition;
and acquiring a first parameter called by the multi-language standard application programming interface through a regular expression so as to determine the namespace and the key definition.
Wherein the multi-language standard application programming interface includes $ t (), $ tc (), $ te (), $ d (), $ n (), $ t (), $ tc (), $ te (), $ d () and $ n ().
In order to achieve the above object, the present application provides a front-end code file detection apparatus, including:
the acquisition module is used for acquiring the configuration file corresponding to each language type;
the system comprises a determining module, a detecting module and a judging module, wherein the determining module is used for determining a folder where a target front end code needing to be detected is located, and determining code files with suffixes of vue and js in the folder;
the scanning module is used for scanning each code file line by line and determining a naming space containing multi-language configuration and a code defined by key;
the query module is used for querying the namespace and the key definition in the configuration files corresponding to each language type, determining the namespace as a target namespace if return values of the configuration files corresponding to all the language types are not received, and determining the key definition as the target key definition;
and the output module is used for outputting the target name space, the target key definition, the line number of the file where the corresponding code is located, the file path and the language type of the unreceived return value.
To achieve the above object, the present application provides an electronic device including:
a memory for storing a computer program;
and the processor is used for realizing the steps of the front-end code file detection method when executing the computer program.
To achieve the above object, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when being executed by a processor, realizes the steps of the front-end code file detection method as described above.
According to the scheme, the front-end code file detection method provided by the application comprises the following steps: acquiring a configuration file corresponding to each language type; determining a folder where a target front end code needing to be detected is located, and determining code files with suffixes of vue and js in the folder; scanning each code file line by line, and determining a code comprising a naming space of multi-language configuration and a key definition; querying the name space and the key definition in the configuration file corresponding to each language type, if the return values of the configuration files corresponding to all the language types are not received, determining the name space as a target name space, and determining the key definition as a target key definition; and outputting the target name space, the target key definition, the line number of the file where the corresponding code is located, the file path and the language type of the unreceived return value.
According to the front-end code file detection method, the naming space and the key definition of the target front-end code are inquired in the configuration file corresponding to each language type in the development stage, and automatic detection of multi-language configuration of the target front-end code file is achieved. The method is different from a manual test method through a UI page, independent test of developers can be achieved in a product development stage, research and development personnel are helped to find problems in advance, and development efficiency and product quality are improved. The application also discloses a front-end code file detection device, an electronic device and a computer readable storage medium, which can also achieve the technical effects.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts. The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a flow diagram illustrating a front-end code file detection method in accordance with an exemplary embodiment;
FIG. 2 is a block diagram illustrating a front end code file detection apparatus in accordance with an exemplary embodiment;
FIG. 3 is a block diagram illustrating an electronic device in accordance with an exemplary embodiment.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application. In addition, in the embodiments of the present application, "first", "second", and the like are used for distinguishing similar objects, and are not necessarily used for describing a specific order or a sequential order.
The embodiment of the application discloses a front-end code file detection method, which realizes automatic detection of multi-language configuration in front-end codes.
Referring to fig. 1, a flowchart of a front-end code file detection method according to an exemplary embodiment is shown, as shown in fig. 1, including:
s101: acquiring a configuration file corresponding to each language type;
it will be appreciated that Vue-i18n multilingual configuration files have been predefined in the front-end code repository, and the fixed format to which the configuration files follow is maintained in the form of key: value in the js format file. The multi-language configuration can be defined in different files according to the functional modules according to needs, or can be defined in one file. In this step, the storage directory of the multi-language configuration file in the front-end code repository can be specified in advance, the multi-language configuration file in the front-end code repository is read, and the file content of the multi-language configuration file is cached in the memory in a JSON (JavaScript Object Notation, JS Object Notation, which is a lightweight data exchange format) format.
The cached data does not change the content and data format of the multi-language configuration file, but increases the name space according to the file name, for example: js, corresponding to data common. If multiple language types exist at the same time, each language type is used as a primary namespace, and the file name is used as a secondary namespace. For example: en _ us.common.test: "Test".
S102: determining a folder where a target front end code needing to be detected is located, and determining code files with suffixes of vue and js in the folder;
in this step, the code files of vue and js suffix under the folder are automatically traversed by designating the folder in which the target front code file to be detected is located. Preferably, the traversed code file can be stored in a temporary directory to prevent the modification of the file content from affecting the original development code and reduce the influence on the main line version of the front-end code.
In specific implementation, when traversing the code files in the folder, automatically judging whether the code files are the folder or the file, if the subfolders exist, reading the code files in the nested subfolders in a recursive mode. Meanwhile, in order to improve the file traversal performance and accuracy, the folder in which the multi-language configuration file specified in the previous step is located may be automatically excluded, that is, code files of all suffixes of vue and js are determined in the folder except for the multi-language configuration file, so that the multi-language configuration file of the js suffix is not repeatedly checked.
S103: scanning each code file line by line, and determining a code comprising a naming space of multi-language configuration and a key definition;
it can be understood that there are five ways to implement multilingual transformation according to the API standard provided by Vue-i18n, which are: $ t (), $ tc (), $ te (), $ d (), and $ n (). Under the Vue framework, the. vue file is mainly composed of two parts, namely < template > </template > and < script > </script >, wherein the < template > </template > part is mainly responsible for the page Dom (Document Object Model) framework, and for example, the multi-language definition can be directly realized through $ t ("xxx. The < script > </script > part is mainly responsible for Javascript logic processing, and for example, multiple language definitions can be realized by means of this. $ t ("XXX.xxx") and the like, wherein this definition is not fixed. XXX represents a namespace and XXX represents a Key of a JSON format file for a multilingual file configuration Key definition. For the js file, the multilingual configuration of Vue-i18n is the same as the < script > </script > portion of the vue file, and is not described herein again.
In this step, a line-by-line scan is performed on each code file in the temporary directory, and a code containing a namespace and key definitions for multi-language configuration is determined. As a possible implementation, the present step includes: scanning each code file line by line, and determining a code containing a multi-language standard application programming interface as a code containing a multi-language configuration namespace and a key definition; and acquiring a first parameter called by the multi-language standard application programming interface through a regular expression so as to determine the namespace and the key definition.
In a specific implementation, each code file is scanned line by line, when the scanned line code is an annotation area, the detection of the line is skipped, and the scanning of the next line is continued. When the scanned line code contains Chinese, the line number, Chinese field and file path of the file where the code is located are recorded. That is, the present embodiment further includes: and outputting the line number, Chinese field and file path of the file containing the Chinese code. When the scanned line code contains a multilingual standard application programming interface (Vue-i18n multilingual configuration API), namely any one of $ t (), $ tc (), $ te (), $ d (), $ n (), $ t (), $ tc (), $ te (), $ d (), and $ n (), the first parameter in the API call parameters, namely the name space and the key definition, is obtained through a regular expression.
The matching rule of the regular expression is as follows:
in the < template > </template > part, "$ t (", "$ tc (", "$ te (", "$ d (", "$ n" ("any one of them is the beginning, and the first one is the first") "is matched as the end, and any combination of characters such as a single quotation mark, a double quotation mark, an English dot symbol, an English letter, a space, an English comma, a middle bracket, a big bracket, a number, a colon and the like is contained in the middle;
in the < script > </script > sections and the js file, the match ends with "$ t (", "$ tc (", "$ te (", "$ d (", "$ n (" start, first "), with any combination of characters in the middle including a single quotation mark, double quotation marks, english dot symbols, english letters, spaces, english commas, middle brackets, big brackets, numbers, colon, etc.
S104: querying the name space and the key definition in the configuration file corresponding to each language type, if the return values of the configuration files corresponding to all the language types are not received, determining the name space as a target name space, and determining the key definition as a target key definition;
in this step, the namespace and the key definition are queried in the cached configuration files, the configuration files corresponding to each language type are queried independently, and if the configuration files corresponding to all the language types have return values, the multilingual configuration is correct. And if the configuration file corresponding to a certain language type has no return value, recording the line number, the name space, the key definition, the file path and the language type of the file where the corresponding code is located.
S105: and outputting the target name space, the target key definition, the line number of the file where the corresponding code is located, the file path and the language type of the unreceived return value.
In this step, the detection result is saved in a specified output directory in the form of a txt text file, which may include the contents of a scan file path, a problem code line number, an undefined namespace, a Key definition, a language type, and the like.
According to the front-end code file detection method provided by the embodiment of the application, the naming space and the key definition of the target front-end code are inquired in the configuration file corresponding to each language type in the development stage, so that the multi-language configuration automatic detection of the target front-end code file is realized. The embodiment of the application is different from a manual test method through a UI page, so that independent test of developers can be realized in a product development stage, the developers are helped to find problems in advance, and development efficiency and product quality are improved.
In the following, a front-end code file detection apparatus provided in an embodiment of the present application is introduced, and a front-end code file detection apparatus described below and a front-end code file detection method described above may be referred to each other.
Referring to fig. 2, a block diagram of a front-end code file detection apparatus according to an exemplary embodiment is shown, as shown in fig. 2, including:
an obtaining module 201, configured to obtain a configuration file corresponding to each language type;
a determining module 202, configured to determine a folder where a target front end code that needs to be detected is located, and determine code files with suffixes of vue and js in the folder;
the scanning module 203 is configured to scan each code file line by line, and determine a code including a namespace and a key definition of multi-language configuration;
the query module 204 is configured to query the namespace and the key definition in the configuration file corresponding to each language type, determine the namespace as a target namespace if return values of the configuration files corresponding to all the language types are not received, and determine the key definition as a target key definition;
and the output module 205 is configured to output the target namespace, the target key definition, the line number of the file where the corresponding code is located, the file path, and the language type where no return value is received.
According to the front-end code file detection device, the naming space and the key definition of the target front-end code are inquired in the configuration file corresponding to each language type in the development stage, and automatic detection of multi-language configuration of the target front-end code file is achieved. The embodiment of the application is different from a manual test method through a UI page, so that independent test of developers can be realized in a product development stage, the developers are helped to find problems in advance, and development efficiency and product quality are improved.
On the basis of the foregoing embodiment, as a preferred implementation manner, the obtaining module 201 is specifically a module that reads a multi-language configuration file in a front-end code repository, and respectively caches file contents of the multi-language configuration file into a plurality of configuration files according to language types.
On the basis of the foregoing embodiment, as a preferred implementation manner, the determining module 202 is specifically a module that determines a folder in which a target front-end code that needs to be detected is located, and determines code files with suffixes of vue and js in the folder except for the multi-language configuration file.
On the basis of the above embodiment, as a preferred implementation, the method further includes:
the cache module is used for caching the code file into a temporary directory;
correspondingly, the scanning module 203 is specifically a module that scans the code files in the temporary directory line by line and determines a name space containing multi-language configuration and a code defined by key.
On the basis of the above embodiment, as a preferred implementation, the method further includes:
and the output module is used for outputting the line number, the Chinese field and the file path of the file containing the Chinese codes.
On the basis of the foregoing embodiment, as a preferred implementation, the scanning module 203 includes:
the scanning unit is used for scanning each code file line by line and determining a code containing a multi-language standard application programming interface as a code containing a multi-language configured namespace and a key definition;
and the determining unit is used for acquiring the first parameter called by the multi-language standard application programming interface through the regular expression so as to determine the namespace and the key definition.
On the basis of the above-described embodiments, as a preferred implementation, the multi-language standard application programming interface includes $ t (), $ tc (), $ te (), $ d (), $ n (), $ t (), $ tc (), $ te (), $ d () and $ n ().
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Based on the hardware implementation of the program module, and in order to implement the method according to the embodiment of the present application, an embodiment of the present application further provides an electronic device, and fig. 3 is a structural diagram of an electronic device according to an exemplary embodiment, as shown in fig. 3, the electronic device includes:
a communication interface 1 capable of information interaction with other devices such as network devices and the like;
and the processor 2 is connected with the communication interface 1 to realize information interaction with other equipment, and is used for executing the front-end code file detection method provided by one or more technical schemes when running a computer program. And the computer program is stored on the memory 3.
In practice, of course, the various components in the electronic device are coupled together by the bus system 4. It will be appreciated that the bus system 4 is used to enable connection communication between these components. The bus system 4 comprises, in addition to a data bus, a power bus, a control bus and a status signal bus. For the sake of clarity, however, the various buses are labeled as bus system 4 in fig. 3.
The memory 3 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program for operating on an electronic device.
It will be appreciated that the memory 3 may be either volatile memory or nonvolatile memory, and may include both volatile and nonvolatile memory. Among them, the nonvolatile Memory may be a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a magnetic random access Memory (FRAM), a Flash Memory (Flash Memory), a magnetic surface Memory, an optical disk, or a Compact Disc Read-Only Memory (CD-ROM); the magnetic surface storage may be disk storage or tape storage. Volatile Memory can be Random Access Memory (RAM), which acts as external cache Memory. By way of illustration and not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), Enhanced Synchronous Dynamic Random Access Memory (Enhanced DRAM), Synchronous Dynamic Random Access Memory (SLDRAM), Direct Memory (DRmb Access), and Random Access Memory (DRAM). The memory 2 described in the embodiments of the present application is intended to comprise, without being limited to, these and any other suitable types of memory.
The method disclosed in the above embodiment of the present application may be applied to the processor 2, or implemented by the processor 2. The processor 2 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 2. The processor 2 described above may be a general purpose processor, a DSP, or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. The processor 2 may implement or perform the methods, steps and logic blocks disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the method disclosed in the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium located in the memory 3, and the processor 2 reads the program in the memory 3 and in combination with its hardware performs the steps of the aforementioned method.
When the processor 2 executes the program, the corresponding processes in the methods according to the embodiments of the present application are realized, and for brevity, are not described herein again.
In an exemplary embodiment, the present application further provides a storage medium, i.e. a computer storage medium, specifically a computer readable storage medium, for example, including a memory 3 storing a computer program, which can be executed by a processor 2 to implement the steps of the foregoing method. The computer readable storage medium may be Memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface Memory, optical disk, or CD-ROM.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.
Alternatively, the integrated units described above in the present application may be stored in a computer-readable storage medium if they are implemented in the form of software functional modules and sold or used as independent products. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially implemented or portions thereof that contribute to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling an electronic device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A front-end code file detection method is characterized by comprising the following steps:
acquiring a configuration file corresponding to each language type;
determining a folder where a target front end code needing to be detected is located, and determining code files with suffixes of vue and js in the folder;
scanning each code file line by line, and determining a code comprising a naming space of multi-language configuration and a key definition;
querying the name space and the key definition in the configuration file corresponding to each language type, if the return values of the configuration files corresponding to all the language types are not received, determining the name space as a target name space, and determining the key definition as a target key definition;
and outputting the target name space, the target key definition, the line number of the file where the corresponding code is located, the file path and the language type of the unreceived return value.
2. The method for detecting a front-end code file according to claim 1, wherein the obtaining a configuration file corresponding to each language category comprises:
reading a multi-language configuration file in a front-end code warehouse, and respectively caching the file content of the multi-language configuration file into a plurality of configuration files according to the language types.
3. The front-end code file detection method according to claim 2, wherein determining code files having all suffixes of. vue and.js in the folder comprises:
code files for all suffixes, vue and js, except for the multilingual configuration file, are determined in the folder.
4. The front-end code file detection method according to claim 1, wherein after determining code files with all suffixes of. vue and.js in the folder, further comprising:
caching the code file into a temporary directory;
correspondingly, the scanning each code file line by line includes:
and scanning the code files in the temporary directory line by line.
5. The front-end code file detection method according to claim 1, further comprising:
and outputting the line number, Chinese field and file path of the file containing the Chinese code.
6. The method for detecting a front-end code file according to claim 1, wherein said scanning each code file line by line to determine a code containing a namespace and a key definition of a multi-language configuration comprises:
scanning each code file line by line, and determining a code containing a multi-language standard application programming interface as a code containing a multi-language configuration namespace and a key definition;
and acquiring a first parameter called by the multi-language standard application programming interface through a regular expression so as to determine the namespace and the key definition.
7. The front-end code file detection method of claim 6, wherein the multi-language standard application programming interface comprises $ t (), $ tc (), $ te (), $ d (), $ n (), $ t (), $ tc (), $ te (), $ d (), and $ n ().
8. A front-end code file detection apparatus, comprising:
the acquisition module is used for acquiring the configuration file corresponding to each language type;
the system comprises a determining module, a detecting module and a judging module, wherein the determining module is used for determining a folder where a target front end code needing to be detected is located, and determining code files with suffixes of vue and js in the folder;
the scanning module is used for scanning each code file line by line and determining a naming space containing multi-language configuration and a code defined by key;
the query module is used for querying the namespace and the key definition in the configuration files corresponding to each language type, determining the namespace as a target namespace if return values of the configuration files corresponding to all the language types are not received, and determining the key definition as the target key definition;
and the output module is used for outputting the target name space, the target key definition, the line number of the file where the corresponding code is located, the file path and the language type of the unreceived return value.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the front-end code file detection method as claimed in any one of claims 1 to 7 when executing said computer program.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the front-end code file detection method according to any one of claims 1 to 7.
CN202111165055.4A 2021-09-30 2021-09-30 Front-end code file detection method and device, electronic equipment and storage medium Active CN114003489B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111165055.4A CN114003489B (en) 2021-09-30 2021-09-30 Front-end code file detection method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111165055.4A CN114003489B (en) 2021-09-30 2021-09-30 Front-end code file detection method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114003489A true CN114003489A (en) 2022-02-01
CN114003489B CN114003489B (en) 2023-08-18

Family

ID=79922243

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111165055.4A Active CN114003489B (en) 2021-09-30 2021-09-30 Front-end code file detection method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114003489B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070044066A1 (en) * 2005-08-19 2007-02-22 Microsoft Corporation Embedded multi-language programming
CN107203405A (en) * 2017-06-23 2017-09-26 郑州云海信息技术有限公司 A kind of method and apparatus for checking multilingual definition
CN109976840A (en) * 2017-12-27 2019-07-05 航天信息股份有限公司 The method and system of multilingual automatic adaptation are realized under a kind of separation platform based on front and back
CN111273898A (en) * 2020-02-25 2020-06-12 安徽以萨数据技术有限公司 Web front-end code automatic construction method, system and storage medium
CN112559354A (en) * 2020-12-18 2021-03-26 中国平安财产保险股份有限公司 Front-end code specification detection method and device, computer equipment and storage medium
CN112612448A (en) * 2020-12-16 2021-04-06 平安普惠企业管理有限公司 Front-end internationalized multi-page packaging method and device and computer equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070044066A1 (en) * 2005-08-19 2007-02-22 Microsoft Corporation Embedded multi-language programming
CN107203405A (en) * 2017-06-23 2017-09-26 郑州云海信息技术有限公司 A kind of method and apparatus for checking multilingual definition
CN109976840A (en) * 2017-12-27 2019-07-05 航天信息股份有限公司 The method and system of multilingual automatic adaptation are realized under a kind of separation platform based on front and back
CN111273898A (en) * 2020-02-25 2020-06-12 安徽以萨数据技术有限公司 Web front-end code automatic construction method, system and storage medium
CN112612448A (en) * 2020-12-16 2021-04-06 平安普惠企业管理有限公司 Front-end internationalized multi-page packaging method and device and computer equipment
CN112559354A (en) * 2020-12-18 2021-03-26 中国平安财产保险股份有限公司 Front-end code specification detection method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN114003489B (en) 2023-08-18

Similar Documents

Publication Publication Date Title
CN110362370B (en) Webpage language switching method and device and terminal equipment
US10229115B2 (en) System and method for creating an internationalized web application
US20050262440A1 (en) Localization of XML via transformations
US20120072831A1 (en) Method for creating a multi-lingual web page
CN111367595B (en) Data processing method, program running method, device and processing equipment
CN105843800A (en) DOI-based language information display method and device
CN110941779B (en) Page loading method and device, storage medium and electronic equipment
CN111831384A (en) Language switching method and device, equipment and storage medium
CN111126010B (en) Freemaker template file restoration method and device, computer equipment and storage medium
US20090241020A1 (en) Method and Related Apparatus and Website Access System Capable of Enhancing Website Compatibility
CN111984262A (en) WeChat cascading style sheet file processing method, device, equipment and storage medium
CN114638200A (en) Electronic book typesetting style code generation method, device, equipment and storage medium
JP2019522847A (en) Method, device and terminal device for extracting data
CN111240790B (en) Multi-language adaptation method, device, client and storage medium for application
CN113064556A (en) BIOS data storage method, device, equipment and storage medium
CN114003489B (en) Front-end code file detection method and device, electronic equipment and storage medium
CN113127776A (en) Breadcrumb path generation method and device and terminal equipment
CN111104805A (en) Translation processing method and device, computer storage medium and terminal
CN110083576B (en) Cache directory identification method and device
CN109948123B (en) Image merging method and device
JP2019057137A (en) Information processing apparatus and information processing program
CN113297425A (en) Document conversion method, device, server and storage medium
CN111783482A (en) Text translation method and device, computer equipment and storage medium
CN113408250B (en) Project file processing method and device
CN110929048A (en) Bookmark generation method and device, electronic equipment and storage medium

Legal Events

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