CN114003489B - 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
CN114003489B
CN114003489B CN202111165055.4A CN202111165055A CN114003489B CN 114003489 B CN114003489 B CN 114003489B CN 202111165055 A CN202111165055 A CN 202111165055A CN 114003489 B CN114003489 B CN 114003489B
Authority
CN
China
Prior art keywords
file
language
configuration
code
end code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111165055.4A
Other languages
Chinese (zh)
Other versions
CN114003489A (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

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

Abstract

The application discloses a front-end code file detection method and device, electronic equipment and storage medium, wherein the method comprises the following steps: acquiring a configuration file corresponding to each language type; determining a folder in which a target front end code to be detected is located, and determining all code files with suffixes of vue and js in the folder; each code file is scanned line by line, and codes containing namespaces and key definitions of multi-language configuration are determined; inquiring a name space and a key definition in a configuration file corresponding to each language type, if the returned 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 definition of the target name space and the target key, the line number of the file where the corresponding code is located, the file path and the language type of which the return value is not received. The application realizes 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 technology, and more particularly, to a method and apparatus for detecting a front-end code file, an electronic device, and a computer readable storage medium.
Background
Vue.js is increasingly being applied to practical project development as a popular front-end development framework. In some projects, to provide services to users of multiple language environments simultaneously, this requires that the product must implement an internationalized language switch. The Vue-i18n is an internationalized plug-in provided by the Vue.js official, provides concise API and powerful functions, and can realize multi-language support of products by combining with the Vue.js through simple configuration.
To implement the international multi-language switching function in product development, it is a common practice to configure multi-language files according to the specification of Vue-i18n, and call APIs (Application Programming Interface, application program interfaces) in service codes to implement automatic rendering. If the multi-language configuration is omitted in the development process or the API is forgotten to be called for realizing translation, the research and development personnel can only check whether the multi-language configuration is perfect and correct by testing on a UI (User Interface Design, interface design) interface. For example, a developer may only configure a chinese language package and forget to configure an english language package, so that when a system product is switched to english, a blank field exists on a UI interface, even a direct error occurs, even some system BUGs which are not easy to find occur, and further user experience and product stability are seriously affected. In the related art, the detection of the multi-language configuration can only pass through the UI interface test mode, so that a great deal of effort is required for research and development personnel, and development efficiency is seriously affected.
Therefore, how to implement automatic detection of multi-language configuration in front-end code is a technical problem that needs 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, electronic equipment and a computer readable storage medium, which realize automatic detection of multi-language configuration in the front-end code.
In order to achieve the above object, the present application provides a method for detecting a front-end code file, including:
acquiring a configuration file corresponding to each language type;
determining a folder in which a target front end code to be detected is located, and determining all code files with suffixes of vue and js in the folder;
each code file is scanned line by line, and codes containing namespaces and key definitions of multi-language configuration are determined;
inquiring 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 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 line number, the file path and the language type of the file where the target name space and the target key definition are located and the corresponding codes are located.
The obtaining the configuration file corresponding to each language type includes:
and reading the multilingual configuration files in the front-end code warehouse, and respectively caching the file contents of the multilingual configuration files into a plurality of configuration files according to the language types.
Wherein, determining all code files with suffixes of. vue and.js in the folder comprises:
code files with suffixes of. vue and.js are all determined in the folder except the multilingual configuration file.
Wherein after determining all code files with suffixes of. vue and.js in the folder, the method further comprises:
caching the code file into a temporary directory;
correspondingly, the step of scanning each code file line by line includes:
and scanning the code files in the temporary directory line by line.
Wherein, still include:
the number of lines of the file containing the Chinese code, the Chinese field and the file path are output.
Wherein the step of scanning each code file line by line to determine a code containing a namespace and a key definition of a multilingual configuration comprises:
each code file is scanned line by line, and codes containing multi-language standard application programming interfaces are determined to be codes containing namespaces and key definitions of multi-language configuration;
the first parameter of the multi-language standard application programming interface call is obtained through a regular expression to determine a namespace and a key definition.
Wherein the multi-language standard application programming interface comprises $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 configuration files corresponding to each language type;
the determining module is used for determining a folder in which the front end code of the target to be detected is located, and determining all code files with suffixes of vue and js in the folder;
the scanning module is used for carrying out progressive scanning on each code file and determining codes containing namespaces and key definitions of multi-language configuration;
the query module is used for querying the name space and the key definition in the configuration file corresponding to each language type, and if the return values of the configuration files corresponding to all the language types are not received, the name space is determined to be a target name space, and the key definition is determined to be a target key definition;
and the output module is used for outputting the line number, the file path and the language type of the file where the target name space, the target key definition and the corresponding codes are located and the language type of which the return value is not received.
To achieve the above object, the present application provides an electronic device including:
a memory for storing a computer program;
and a processor for implementing the steps of the front end code file detection method as described above when executing the computer program.
To achieve the above object, the present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements 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 in which a target front end code to be detected is located, and determining all code files with suffixes of vue and js in the folder; each code file is scanned line by line, and codes containing namespaces and key definitions of multi-language configuration are determined; inquiring 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 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 line number, the file path and the language type of the file where the target name space and the target key definition are located and the corresponding codes are located.
According to the front-end code file detection method, in the development stage, the naming space and key definition of the target front-end code are queried in the configuration file corresponding to each language type, so that the automatic detection of the multi-language configuration of the target front-end code file is realized. The application is different from the method of manual testing through the UI page, can realize the independent testing of the developer in the product development stage, helps the developer to find the problem in advance, and is beneficial to improving the development efficiency and the product quality. The application also discloses a front-end code file detection device, an electronic device and a computer readable storage medium, and the technical effects can be realized.
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 as claimed.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art. The accompanying drawings are included to provide a further understanding of the disclosure, and are incorporated in and constitute a part of this specification, illustrate the disclosure and together with the description serve to explain, but do not limit the disclosure. In the drawings:
FIG. 1 is a flowchart illustrating a method of front end code file detection, according to an example embodiment;
FIG. 2 is a block diagram of a front end code file detection apparatus according to an exemplary embodiment;
fig. 3 is a block diagram of an electronic device, according to an example embodiment.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. It will be apparent that the described embodiments are only some, but not all, embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application. In addition, in the embodiments of the present application, "first", "second", etc. are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence.
The embodiment of the application discloses a method for detecting a front-end code file, which realizes the automatic detection of multi-language configuration in a front-end code.
Referring to fig. 1, a flowchart of a front end code file detection method according to an exemplary embodiment is shown, and as shown in fig. 1, includes:
s101: acquiring a configuration file corresponding to each language type;
it will be appreciated that in the front-end code repository, a Vue-i18n multilingual configuration file has been predefined, the configuration file following a fixed format, stored in the form of key: value in a file in js format. The multi-language configuration method can be respectively defined in different files according to the functional modules as required, and can also be defined in one file. In this step, the storage directory of the multilingual configuration file in the front-end code repository may be specified in advance, so as to read the multilingual configuration file in the front-end code repository, and the file content of the multilingual configuration file is cached in the memory in JSON (JavaScript Object Notation, JS object profile, which is a lightweight data exchange format).
The cached data does not change the content and data format of the multilingual configuration file, but simply adds a namespace based on the file name, such as: the file name is common.js, and the corresponding data is common.test. If multiple language categories exist simultaneously, each language category is taken as a primary namespace and the file name is taken as a secondary namespace. For example: en_US. Common. Test: "Test".
S102: determining a folder in which a target front end code to be detected is located, and determining all code files with suffixes of vue and js in the folder;
in this step, the code files of the. vue and.js suffixes under the folder are automatically traversed by specifying the folder in which the target front-end code file to be detected is located. Preferably, the traversed code file can be stored in the temporary directory, so that the original development code is prevented from being influenced by modification of file content, and the influence on the main line version of the front-end code is reduced.
In specific implementation, when traversing the code files under the folder, automatically judging whether the file is the folder or the file, and if the subfolder exists, reading the code files under the nested subfolder in a recursion mode. Meanwhile, in order to improve the traversal performance and accuracy of the file, the folder in which the multi-language configuration file designated in the previous step is located can be automatically eliminated, namely, all code files with suffixes of. vue and.js except the multi-language configuration file are determined in the folder, so that repeated inspection of the multi-language configuration file with the suffix of.js is avoided.
S103: each code file is scanned line by line, and codes containing namespaces and key definitions of multi-language configuration are determined;
it can be appreciated that, according to the API standard provided by Vue-i18n, there are five ways to implement multilingual conversion, respectively: t (), $tc (), $te (), $d (), and $n (). Under the Vue framework, the Vue file is mainly composed of two parts, a < template > </template > and a < script > </script >, where the < template > </template > part is mainly responsible for the page Dom (document object model ) framework, e.g., multi-lingual definition can be implemented directly in a $t ("xxx. Xxx") like manner. The < script > </script > portion is primarily responsible for Javascript logic processing, e.g., multi-lingual definition may be implemented by means of this ($t ("xxx. Xxx") etc., where this definition is not fixed. Where "XXX. XXX" configures Key definitions for multilingual files, "XXX" stands for namespaces and "XXX" stands for keys of JSON format files. For the js file, the multilingual configuration of Vue-i18n is the same as the < script > </script > portion of the Vue file, and will not be described again here.
In this step, a progressive scan is performed on each code file in the temporary directory, determining the code containing the namespace and key definitions of the multilingual configuration. As a possible embodiment, the step includes: each code file is scanned line by line, and codes containing multi-language standard application programming interfaces are determined to be codes containing namespaces and key definitions of multi-language configuration; the first parameter of the multi-language standard application programming interface call is obtained through a regular expression to determine a namespace and a key definition.
In a specific implementation, each code file is scanned line by line, and when the scanned line code is the 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. Namely, the present embodiment further includes: the number of lines of the file containing the Chinese code, the Chinese field and the file path are output. When the scanned line code contains any one of the multilingual standard application programming interfaces (Vue-i 18n multilingual configuration APIs), that is, there is any one of $t (), $tc (), $te (), $d (), $n (), the first parameter of the API call parameters, namely, the namespace and key definition, is acquired by a regular expression.
The matching rule of the regular expression is as follows:
in the < template > </template > part, matching is carried out by using "$t (", "$tc (", "$te (", "$d (", "$n (any item is the beginning and is the first") 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 large bracket, a number, a colon and the like is included in the middle;
in the < script > </script > section and the js file, the matches are any combination of characters of "$t (", "$tc (", "$te (", "$d (", "$n (" beginning, first ") ending with a single quotation mark, double quotation mark, english dot symbol, english letter, space, english comma, bracket, number, colon, and the like.
S104: inquiring 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 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 namespaces and key definitions are queried in the cached configuration files, the configuration files corresponding to each language category are queried independently, and if the configuration files corresponding to all language categories have return values, the multi-language configuration is correct. If the configuration file corresponding to a certain language type does not have a return value, the line number, the name space and key definition, the file path and the language type of the file where the corresponding code is located are recorded.
S105: and outputting the line number, the file path and the language type of the file where the target name space and the target key definition are located and the corresponding codes are located.
In this step, the detection result is saved in the form of txt text file in the designated output directory, and may include contents such as scan file path, number of lines of problem code, undefined namespace, key definition, language type, and the like.
According to the front-end code file detection method provided by the embodiment of the application, in the development stage, the naming space and key definition of the target front-end code are queried in the configuration file corresponding to each language type, so that the automatic detection of the multi-language configuration of the target front-end code file is realized. The embodiment of the application is different from a method for manually testing through a UI page, can realize autonomous testing of developers in a product development stage, helps the developers discover problems in advance, and is beneficial to improving development efficiency and product quality.
The following describes a front-end code file detection device according to an embodiment of the present application, and the front-end code file detection device described below and the 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 in which a target front end code to be detected is located, and determine all code files with suffixes of. vue and.js in the folder;
a scanning module 203, configured to scan each code file line by line, and determine a code including a namespace and a key definition of a multilingual configuration;
a query module 204, configured to query the namespaces and the key definitions in configuration files corresponding to each language class, and if no return values of the configuration files corresponding to all language classes are received, determine the namespaces as target namespaces, and determine the key definitions as target key definitions;
and the output module 205 is configured to output the number of lines, the file path and the language type of the file where the target namespace and the target key definition are located and the corresponding code is located, and the language type of the returned value is not received.
According to the front end code file detection device provided by the embodiment of the application, in the development stage, the naming space and key definition of the target front end code are queried in the configuration file corresponding to each language type, so that the automatic detection of the multi-language configuration of the target front end code file is realized. The embodiment of the application is different from a method for manually testing through a UI page, can realize autonomous testing of developers in a product development stage, helps the developers discover problems in advance, and is beneficial to improving development efficiency and product quality.
Based on the foregoing embodiment, as a preferred implementation manner, the obtaining module 201 specifically reads a multilingual configuration file in the front-end code repository, and caches file contents of the multilingual configuration file into a plurality of configuration files according to language types.
Based on the above embodiment, as a preferred implementation manner, the determining module 202 is specifically a module that determines a folder in which the target front end code to be detected is located, and determines all code files with suffixes of. vue and.js except the multi-language configuration file in the folder.
On the basis of the above embodiment, as a preferred implementation manner, the method further includes:
the caching module is used for caching the code file into a temporary directory;
correspondingly, the scanning module 203 specifically performs progressive scanning on the code files in the temporary directory, and determines a code including a namespace and a key definition of the multilingual configuration.
On the basis of the above embodiment, as a preferred implementation manner, 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 code.
Based on the above embodiment, as a preferred implementation manner, the scanning module 203 includes:
the scanning unit is used for scanning each code file line by line, and determining the code containing the multi-language standard application programming interface as the code containing the naming space and key definition of multi-language configuration;
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 name space and the key definition.
On the basis of the above examples, as a preferred implementation, the multi-language standard application programming interface includes $t (), $tc (), $te (), $d (), $n (), $t (), $tc (), $te (), $d (), and $n ().
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
Based on the hardware implementation of the program modules, and in order to implement the method according to the embodiment of the present application, the embodiment of the present application further provides an electronic device, and fig. 3 is a block diagram of an electronic device according to an exemplary embodiment, and 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 devices and is used for executing the front-end code file detection method provided by one or more technical schemes when running the computer program. And the computer program is stored on the memory 3.
Of course, in practice, the various components in the electronic device are coupled together by a bus system 4. It will be appreciated that the bus system 4 is used to enable connected communications 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. But for clarity of illustration 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. Wherein the nonvolatile Memory may be Read Only Memory (ROM), programmable Read Only Memory (PROM, programmable Read-Only Memory), erasable programmable Read Only Memory (EPROM, erasable Programmable Read-Only Memory), electrically erasable programmable Read Only Memory (EEPROM, electrically Erasable Programmable Read-Only Memory), magnetic random access Memory (FRAM, ferromagnetic random access Memory), flash Memory (Flash Memory), magnetic surface Memory, optical disk, or compact disk Read Only Memory (CD-ROM, compact Disc Read-Only Memory); the magnetic surface memory may be a disk memory or a tape memory. The volatile memory may be random access memory (RAM, random Access Memory), which acts as external cache memory. By way of example, and not limitation, many forms of RAM are available, such as static random access memory (SRAM, static Random Access Memory), synchronous static random access memory (SSRAM, synchronous Static Random Access Memory), dynamic random access memory (DRAM, dynamic Random Access Memory), synchronous dynamic random access memory (SDRAM, synchronous Dynamic Random Access Memory), double data rate synchronous dynamic random access memory (ddr SDRAM, double Data Rate Synchronous Dynamic Random Access Memory), enhanced synchronous dynamic random access memory (ESDRAM, enhanced Synchronous Dynamic Random Access Memory), synchronous link dynamic random access memory (SLDRAM, syncLink Dynamic Random Access Memory), direct memory bus random access memory (DRRAM, direct Rambus Random Access Memory). 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 with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in the processor 2 or by instructions in the form of software. The processor 2 described above may be a general purpose processor, 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 embodiments of the present application. The general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the method disclosed in the embodiment of the application can be directly embodied in the hardware of the decoding processor or can be implemented by combining hardware and software modules in the decoding processor. The software modules may be located in a storage medium in the memory 3 and the processor 2 reads the program in the memory 3 to perform the steps of the method described above in connection with its hardware.
The corresponding flow in each method of the embodiments of the present application is implemented when the processor 2 executes the program, and for brevity, will not be described in detail herein.
In an exemplary embodiment, the present application also provides a storage medium, i.e. a computer storage medium, in particular a computer readable storage medium, for example comprising a memory 3 storing a computer program executable by the processor 2 for performing the steps of the method described above. The computer readable storage medium may be FRAM, ROM, PROM, EPROM, EEPROM, flash Memory, magnetic surface Memory, optical disk, or CD-ROM.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the above method embodiments may be implemented by hardware associated with program instructions, where the foregoing program may be stored in a computer readable storage medium, and when executed, the program performs steps including the above method embodiments; and the aforementioned storage medium includes: a removable storage device, ROM, RAM, magnetic or optical disk, or other medium capable of storing program code.
Alternatively, the above-described integrated units of the present application may be stored in a computer-readable storage medium if implemented in the form of software functional modules and sold or used as separate products. Based on such understanding, the technical solutions of the embodiments of the present application may be embodied in essence or a part contributing to the prior art in the form of a software product stored in a storage medium, including several instructions for causing an electronic device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a removable storage device, ROM, RAM, magnetic or optical disk, or other medium capable of storing program code.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within 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 method for detecting a front-end code file, comprising:
acquiring a configuration file corresponding to each language type;
determining a folder in which a target front end code to be detected is located, and determining all code files with suffixes of vue and js in the folder;
each code file is scanned line by line, and codes containing namespaces and key definitions of multi-language configuration are determined;
inquiring 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 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 line number, the file path and the language type of the file where the target name space and the target key definition are located and the corresponding codes are located.
2. The method for detecting a front-end code file according to claim 1, wherein the obtaining a configuration file corresponding to each language class includes:
and reading the multilingual configuration files in the front-end code warehouse, and respectively caching the file contents of the multilingual configuration files into a plurality of configuration files according to the language types.
3. The front-end code file detection method of claim 2, wherein determining all code files with suffixes of. vue and.js in the folder comprises:
code files with suffixes of. vue and.js are all determined in the folder except the multilingual configuration file.
4. The front-end code file detection method of claim 1, further comprising, after determining all code files with suffixes of. vue and.js in the folder:
caching the code file into a temporary directory;
correspondingly, the step of 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 of claim 1, further comprising:
the number of lines of the file containing the Chinese code, the Chinese field and the file path are output.
6. The method for detecting a front-end code file according to claim 1, wherein said step of scanning each of said code files line by line to determine a code containing a namespace and a key definition of a multilingual configuration comprises:
each code file is scanned line by line, and codes containing multi-language standard application programming interfaces are determined to be codes containing namespaces and key definitions of multi-language configuration;
the first parameter of the multi-language standard application programming interface call is obtained through a regular expression to determine a namespace and a 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 configuration files corresponding to each language type;
the determining module is used for determining a folder in which the front end code of the target to be detected is located, and determining all code files with suffixes of vue and js in the folder;
the scanning module is used for carrying out progressive scanning on each code file and determining codes containing namespaces and key definitions of multi-language configuration;
the query module is used for querying the name space and the key definition in the configuration file corresponding to each language type, and if the return values of the configuration files corresponding to all the language types are not received, the name space is determined to be a target name space, and the key definition is determined to be a target key definition;
and the output module is used for outputting the line number, the file path and the language type of the file where the target name space, the target key definition and the corresponding codes are located and the language type of which the return value is not received.
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 according to any of claims 1 to 7 when executing said computer program.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the front end code file detection method according to any 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 CN114003489A (en) 2022-02-01
CN114003489B true 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 (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Family Cites Families (1)

* 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

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
CN114003489A (en) 2022-02-01

Similar Documents

Publication Publication Date Title
JP6629848B2 (en) Page processing for mobile applications
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
CN110727417B (en) Data processing method and device
CN111367595B (en) Data processing method, program running method, device and processing equipment
JP2023541186A (en) Visualization page rendering method, device, equipment and storage medium
CN111831384A (en) Language switching method and device, equipment and storage medium
CN112417338B (en) Page adaptation method, system and equipment
US20130124969A1 (en) Xml editor within a wysiwyg application
US10282174B2 (en) Software layout processing localization
US20150161160A1 (en) Application Localization
US20070150477A1 (en) Validating a uniform resource locator (&#39;URL&#39;) in a document
CN111984262A (en) WeChat cascading style sheet file processing method, device, equipment and storage medium
CN112181924A (en) File conversion method, device, equipment and 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
JP2019057137A (en) Information processing apparatus and information processing program
CN110083576B (en) Cache directory identification method and device
US11482027B2 (en) Automated extraction of performance segments and metadata values associated with the performance segments from contract documents
CN109948123B (en) Image merging method and device
CN111783482A (en) Text translation method and device, computer equipment and storage medium
KR20130103239A (en) Method, server and terminal for providing web browsing service having translation

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