CN115730562A - Code display method and device of static text, electronic equipment and storage medium - Google Patents

Code display method and device of static text, electronic equipment and storage medium Download PDF

Info

Publication number
CN115730562A
CN115730562A CN202211436564.0A CN202211436564A CN115730562A CN 115730562 A CN115730562 A CN 115730562A CN 202211436564 A CN202211436564 A CN 202211436564A CN 115730562 A CN115730562 A CN 115730562A
Authority
CN
China
Prior art keywords
static
text
static text
page
application program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211436564.0A
Other languages
Chinese (zh)
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.)
Ping An E Wallet Electronic Commerce Co Ltd
Original Assignee
Ping An E Wallet Electronic Commerce 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 Ping An E Wallet Electronic Commerce Co Ltd filed Critical Ping An E Wallet Electronic Commerce Co Ltd
Priority to CN202211436564.0A priority Critical patent/CN115730562A/en
Publication of CN115730562A publication Critical patent/CN115730562A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the technical field of program development, and provides a code display method, a device, electronic equipment and a storage medium for a static text, wherein the method extracts the static text in an application program from the application program and stores the static text in a centralized manner, so that the static text is separated from the path and page constraint of the application program, a configuration file is generated according to the stored static text, lexical analysis is carried out on the configuration file, the content structure of the configuration file is obtained, and a display color is configured for the content structure; the codes of the static text are displayed according to the colors configured by the content structure, so that the configuration file can be seen more clearly in the VS code editor, and the content structure is more vivid, therefore, developers can be assisted to understand the functions of the codes in the configuration file more quickly, the static text can be maintained more easily, and the maintenance cost of an application program is reduced.

Description

Code display method and device of static text, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of program development, in particular to a code display method and device of a static text, electronic equipment and a storage medium.
Background
The rapid development of computer technology and network communication technology has promoted the rapid growth and popularization of application programs, which have become an indispensable tool for people, and users access pages of application programs deployed on servers through browsers in the aspects of people's life.
The inventor finds that, in the process of implementing the present invention, because the application program usually contains a large amount of static texts and is frequently changed, the application program needs to be reissued after the static texts are changed each time, so that the development of the application program is complicated, and errors of the application program are easily caused in the process of reissuing the application program.
Disclosure of Invention
In view of the above, it is necessary to provide a code display method, device, electronic device and storage medium for static text, which can display static text codes in a hierarchical manner and assist developers in improving the development efficiency of the codes.
Acquiring a static text in an application program, and extracting and storing the static text from the application program;
generating a configuration file according to the stored static text;
performing lexical analysis on the configuration file to obtain a content structure of the configuration file;
configuring a display color for the content structure;
and displaying the codes of the static text according to the colors configured by the content structure.
In an optional embodiment, the obtaining the static text in the application program, and extracting and storing the static text from the application program includes:
acquiring a plurality of pages of the application program, and traversing a text suffix of each text in each page;
extracting a text containing a preset suffix in the text suffix to serve as a static text;
creating a folder, and naming the folder according to a preset file name;
and storing the static text in the named folder.
In an optional embodiment, the generating a configuration file according to the stored static text includes:
partitioning the stored static text;
setting a name space for each static text by adopting an i18n tool;
setting a variable name and an attribute for each static text in each name space by adopting the i18n tool;
and generating a configuration file according to the static text, the name space, the variable name and the attribute.
In an optional embodiment, the blocking the stored static text includes:
acquiring a page identifier of the stored static text;
the static texts with the same page identifications are divided into the same block, and the static texts with different page identifications are divided into different blocks.
In an optional embodiment, the dividing the static text of the same page identifier into the same block includes:
calculating the number of static texts corresponding to each same page identifier;
determining a maximum value, a second maximum value and a minimum value of the number;
generating a random number between said second maximum value and said minimum value;
and partitioning the static text corresponding to the maximum value according to the random number.
In an alternative embodiment, said configuring the display color for the content structure comprises:
acquiring the utilization rate of each page in the application program;
determining the page with the highest utilization rate as a target page;
acquiring a target code of the target page;
matching the code structure of the target code with the content structure one by one;
configuring a display color of the content structure to match a color of a code structure of the object code that was successful.
In an optional embodiment, the method further comprises:
acquiring the file size of the static file;
matching the file size with a plurality of preset file sizes;
determining the preset file size successfully matched with the file size as a target preset file size;
determining a classification identifier corresponding to the size of the target preset file as a classification identifier of the static file;
and when the number of the static files displayed on a certain page in the application program is larger than a preset number, displaying a plurality of the static files in batches according to the classification identification, wherein the sum of the file sizes of the static files in each batch is smaller than a preset threshold value.
A second aspect of the present invention provides a code display apparatus for static text, the apparatus comprising:
the acquisition module is used for acquiring a static text in an application program, and extracting and storing the static text from the application program;
the generating module is used for generating a configuration file according to the stored static text;
the analysis module is used for carrying out lexical analysis on the configuration file to obtain a content structure of the configuration file;
a configuration module for configuring a display color for the content structure;
and the display module is used for displaying the codes of the static texts according to the colors configured by the content structure.
A third aspect of the invention provides an electronic device comprising a processor and a memory, the processor being configured to implement the code display method of static text when executing a computer program stored in the memory.
A fourth aspect of the present invention provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the code display method of static text.
The invention relates to the technical field of program development, and provides a code display method, a device, electronic equipment and a storage medium for a static text, wherein the static text in an application program is extracted from the application program and is stored in a centralized manner, so that the static text is separated from the restriction of a path and a page of the application program, a configuration file is generated according to the stored static text, lexical analysis is carried out on the configuration file, the content structure of the configuration file is obtained, and a display color is configured for the content structure; the codes of the static text are displayed according to the colors configured by the content structure, so that the configuration file can be seen more clearly in the VS code editor, and the content structure is more vivid, developers can be assisted to understand the functions of the codes in the configuration file more quickly, the static text is maintained more easily, the maintenance cost of the application program is reduced, and the publishing efficiency of the application program is improved.
Drawings
Fig. 1 is a flowchart of a code display method for static text according to an embodiment of the present invention.
Fig. 2 is a structural diagram of a code display apparatus for static text according to a second embodiment of the present invention.
Fig. 3 is a schematic structural diagram of an electronic device according to a third embodiment of the present invention.
Detailed Description
In order that the above objects, features and advantages of the present invention can be more clearly understood, a detailed description of the present invention will be given below with reference to the accompanying drawings and specific embodiments. The embodiments of the invention and the features of the embodiments can be combined with each other without conflict.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
The code display method of the static text provided by the embodiment of the invention is executed by the electronic equipment, and correspondingly, the code display device of the static text runs in the electronic equipment.
The embodiment of the invention can carry out standardized treatment on symptoms based on an artificial intelligence technology. Among them, artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
Example one
Fig. 1 is a flowchart of a code display method for static text according to an embodiment of the present invention. The code display method of the static text specifically comprises the following steps, and the sequence of the steps in the flowchart can be changed and some steps can be omitted according to different requirements.
S11, obtaining a static text in an application program, and extracting and storing the static text from the application program.
The electronic equipment acquires the static text in the application program, and after the static text is acquired, the static text is extracted from the application program and stored in the same folder, so that the configuration file is generated according to the static text in the folder, and the codes corresponding to the static text in the application program can be conveniently highlighted according to the configuration file.
The application in this embodiment may be, for example, a financial application, a medical application, a game application, or other types of applications, such as an information application, an order application, an audio application, a video playing application, etc. At least one page (user page) exists in the application, and in the case of a financial application, there may be an application page, a setup page, a chat page, a refund page, and the like. For each page in an application, there may be one or more static texts in the page.
The static text refers to a text statically configured in the application program, that is, the static text refers to a text that cannot be dynamically changed in the application program. In the case of a financial application, the financial application usually has one or more visible user pages, and the text that cannot be dynamically loaded in each user page is static text. For example, in a financial application, each user page usually has buttons, sliders, icons and the like for the user to operate, and messages and the like for prompting the user are fixedly displayed, and text contents included in the buttons, sliders, icons and the like, such as "contacts", "session lists", "group announcements", "group chat names", "group chat members" and the like, and messages fixedly displayed, such as "insurance claim" and the like, are static texts in the application.
In an optional embodiment, the obtaining the static text in the application program, and extracting and storing the static text from the application program includes:
acquiring a plurality of pages of the application program, and traversing a text suffix of each text in each page;
extracting a text containing a preset suffix in the text suffix to serve as a static text;
creating a folder, and naming the folder according to a preset file name;
and storing the static text in a named folder.
The preset suffix is a suffix of a predefined text name, and for example, jpg, pdf, or the like can be used as the preset suffix. Therefore, when the electronic device extracts the static text in the page, the electronic device can traverse the text suffix of each text in the page, extract the text containing the preset suffix in the text suffix, and the extracted text is the static text.
The preset file name may be i18n.static.
In the embodiment, the static text in the application program is acquired and stored in the folder, so that the static text is separated from the path and page constraints of the application program, the effect of extracting the static text from the application program is realized, when the static text needs to be changed subsequently, the static text is directly searched from the folder without scanning logic codes, and when the logic codes are scanned, on one hand, the scanning is missed, on the other hand, the codes are unconsciously deleted, so that all the static texts of the application program are stored in the same folder, the risk of errors in the scanning of the codes is reduced, and the centralized management of the static text is facilitated.
And S12, generating a configuration file according to the stored static text.
In this embodiment, the electronic device may generate the configuration file according to the static text stored in the folder with the preset file name.
In an optional embodiment, the generating a configuration file according to the stored static text includes:
partitioning the stored static text;
setting a name space for each static text by adopting an i18n tool;
setting a variable name and an attribute for each static text in each name space by adopting the i18n tool;
and generating a configuration file according to the static text, the name space, the variable name and the attribute.
The electronic equipment can divide the static texts stored in the folder with the preset file name into blocks according to an equal division principle, wherein the quantity of the static texts in each block is the same.
i18n (the source is the first and last characters i and n of the English word international, 18 is the number of the middle characters) is the abbreviation of "internationalization". The namespace, variable name and attribute set by the i18n tool are all unique.
The electronic device may also command a configuration file generated using static text processed by the i18n tool as i18 8n static.
In an optional embodiment, the blocking the stored static text includes:
acquiring a page identifier of the stored static text;
the static texts with the same page identifications are divided into the same block, and the static texts with different page identifications are divided into different blocks.
The page identifier is used for distinguishing pages in the application program, and different pages in the application program correspond to different page identifiers. Static text from the same page in the application has the same page identification, and static text from different pages in the application has different page identifications.
In the optional embodiment, the static text originally on the same page in the application program can be stored in the same namespace through the page identifier, and the static text originally on different pages in the application program can be stored in different namespaces.
In an optional embodiment, the dividing the static text of the same page identifier into the same block includes:
calculating the number of static texts corresponding to each same page identifier;
determining a maximum value, a second maximum value and a minimum value of the number;
generating a random number between said second maximum value and said minimum value;
and partitioning the static text corresponding to the maximum value according to the random number.
The electronic device may sort the numbers in order from large to small or from small to large, and determine the maximum value, the second large value, and the minimum value according to the sorting result, where the second large value is a value smaller than the maximum value.
A random number generation algorithm may be used to generate a random number between the second largest value and the smallest value, where the generated random number is an integer and does not include the second largest value and the smallest value.
Illustratively, assume that there are 5 pages, and the page identifiers of the 5 pages are ID1, ID2, ID3, ID4, and ID5, respectively, where the page identifier ID1 corresponds to 10 static texts, the page identifier ID2 corresponds to 6 static texts, the page identifier ID3 corresponds to 5 static texts, the page identifier ID4 corresponds to 3 static texts, and the page identifier ID5 corresponds to 3 static texts, then the maximum value is 10, the second maximum value is 6, and the minimum value is 3, a random number may be generated between 3 and 6, so as to block the 10 static texts corresponding to the page identifier ID1 according to the random number.
Since the generated random number is an integer and does not include the second largest and smallest values, the random number generated between 3 and 6 is 4 or 5. Assuming that the generated random number is 4, the 10 static texts corresponding to the page identification ID1 can be divided into two blocks, wherein one block includes 4 static texts and the other block includes 6 static texts. Assuming that the generated random number is 5, the 10 static texts corresponding to the page identification ID1 may be divided into two blocks, each of which includes 5 static texts.
In the above optional embodiment, the static text with the largest number may be determined according to the number of the static texts corresponding to the same page identifier, and a random number is generated according to the second large value and the minimum value, so that the static text with the largest number is partitioned by using the random number. The static texts with the same page identifications are divided into one block, but the static texts in the block are very time-consuming to search subsequently due to the large number of the static texts in the block, so that the static texts which are divided into the same block are divided into blocks again according to the number of the static texts corresponding to other same page identifications, the static texts with the maximum number of the page identifications are divided into blocks twice, the static texts can be conveniently and rapidly searched subsequently, and codes corresponding to the static texts can be rapidly edited.
In an alternative embodiment, the static text corresponding to the same page identifier corresponds to one namespace, and the namespace corresponding to the static text with the same page identifier and the largest number may be divided into two naming subspaces, that is, one namespace includes two naming subspaces, and each naming subspace stores one blocked static text. For example, suppose that the page identifier ID1 corresponds to 100 static texts, and the namespace set for the 100 static texts corresponding to the page identifier ID1 is name1, if the 100 static texts are divided into two blocks, where one block includes 45 static texts and the other block includes 55 static texts, then the namespace name11 may be set for the block including 45 static texts, and the namespace name12 may be set for the block including 55 static texts.
And S13, performing lexical analysis on the configuration file to obtain a content structure of the configuration file.
Because the content structure in the configuration file i18n.static includes: namespace, attribute, and variable name of each static text, so that the structure of the configuration file i18n.static becomes more complicated, but the configuration file i18n.static is the same as that of the txt document in the VS code, that is, the content in the configuration file i18n.static is the same color, so that the content structure of the configuration file i18n.static looks unclear. For developers, when staring at a content of one color for a long time, visual fatigue is likely to occur, and thus errors are likely to occur when developing codes, resulting in low development efficiency and poor development quality.
In this embodiment, the content structure of the configuration file is obtained by performing lexical analysis on the configuration file, which facilitates color configuration according to the content structure, so that the content structures of the configuration file i 11 8n.static are differentiated.
The electronic device may generate a lexical analysis plug-in before performing lexical analysis on the configuration file, and perform the lexical analysis on the configuration file using the generated lexical analysis plug-in.
In an optional embodiment, the generating the lexical analysis plug-in includes:
installing a VS code plug-in scaffold;
after the installation is finished, inputting a command to generate a VS code generator code;
and after the completion, opening a VS code editor, and generating the lexical analysis plug-in after debugging and running.
Specifically, the lexical analysis plug-in is implemented based on a VS code editor, and the plug-in is developed first, and what is required to generate a plug-in code is generated when the plug-in is developed. Opening a cmd execution command nmp install-g yo generator-code to install lexical analysis plug-ins, inputting a code command to generate VS code generator codes after installation is completed, opening a VS code editor after completion, pressing an 'F5' key to debug, calling a new VS code window to display a title of an 'extended development host' in a title bar after a project runs, wherein the window is a command supporting the running plug-in project, and thus, a plug-in foundation project is generated.
And S14, configuring display colors for the content structure.
The content structure in the configuration file i18n.static includes: the name space namespace, the attribute, and the variable name of each static text, the electronic device may set a first color for the name space namespace, a second color for the attribute, and a third color for the variable name of the static text in the VS code editor.
The content structure in the configuration file i18n.static may further include: number, = number, creation time Create, etc. The electronic device may also set a fourth color for # number, a fifth color for = number, and a sixth color for creation time Create.
In specific implementation, the electronic device modifies editors in a configuration file, seting in json, and configures different content structures and colors in a configuration file, i.e., i.18n.static, one by one in a VS code editor.
In an alternative embodiment, said configuring the display color for the content structure comprises:
acquiring the utilization rate of each page in the application program;
determining the page with the highest utilization rate as a target page;
acquiring a target code of the target page;
matching the code structure of the target code with the content structure one by one;
configuring a display color of the content structure to match a color of a code structure of the object code that was successful.
The page utilization rate can be calculated according to the number of times that the user clicks the page, the more the number of times that the user clicks the page, the higher the page utilization rate is indicated, and the less the number of times that the user clicks the page, the lower the page utilization rate is indicated. The usage rates of different pages in the application program can be the same or different. The usage of at least two pages in the application is different. And determining the page with the highest utilization rate as a target page, and configuring the color for the content structure of the configuration file according to the code structure of the target code of the target page. For example, assuming that the variable name of the static text in the code structure of the object code uses red, the variable name of the static text in the content structure of the configuration file is configured to be red, and assuming that the attribute in the code structure of the object code uses brown, the attribute in the content structure of the configuration file is configured to be brown.
In the above optional embodiment, the page with the highest usage rate in the application program is a page frequently clicked by the user, and this page best conforms to the usage habit of the user, so that the display color of the content structure is configured to the color of the code structure of the object code that is successfully matched by determining the page with the highest usage rate in the application program as the object page and matching the code structure of the object code of the object page with the content structure of the configuration file one by one, so that the display color of the content structure can also conform to the usage habit of the user.
And S15, displaying the codes of the static texts according to the colors configured by the content structure.
The codes of the static text are displayed according to the colors configured by the content structure, so that the configuration file i18n.static can be seen more clearly in a VS code editor, and the content structure is more vivid, thereby assisting developers to understand the functions of the codes in the configuration file more quickly, enabling the static text to be maintained more easily, and reducing the maintenance cost of an application program.
In an optional embodiment, the method further comprises:
acquiring the file size of the static file;
matching the file size with a plurality of preset file sizes;
determining the preset file size successfully matched with the file size as a target preset file size;
determining a classification identifier corresponding to the size of a target preset file as a classification identifier of the static file;
and when the number of the static files displayed on a certain page in the application program is larger than a preset number, displaying a plurality of the static files in batches according to the classification identification, wherein the sum of the file sizes of the static files in each batch is smaller than a preset threshold value.
The electronic equipment is pre-stored with a plurality of preset file sizes and a plurality of classification identifications, and the preset file sizes and the classification identifications have one-to-one correspondence relationship. After the file size of each static file is obtained, matching the file size of the static file with a plurality of preset file sizes to obtain a matching result. And acquiring a classification identifier corresponding to the file size of the static file from the plurality of classification identifiers, so that the acquired classification identifier is determined as the classification identifier of the static file.
The classification identification is a file attribute of the static files and is used for distinguishing different types of static files. For example, the classification identifier is used to identify the file size of the static files, a plurality of static files with equal or similar file sizes have the same classification identifier, a plurality of static files with different file sizes or with larger differences have different classification identifiers, and the file sizes of the static files are classified through the classification identifiers.
When the number of static files in a certain page is large, a plurality of large static files are displayed simultaneously, which may cause the static files in a part of pages to be displayed incompletely or displayed unsmoothly. Therefore, because the static files are classified through the classification identifiers, the static files with different file sizes can be displayed in batches according to the classification identifiers, the sum of the file sizes of all the static files in each batch is smaller than the preset threshold value, namely the sum of the file sizes of the static files in the same batch is smaller, so that the consumed computer resources are less, and the display fluency can be improved.
In specific implementation, each batch includes static files corresponding to a plurality of classification identifiers, that is, each batch includes static files corresponding to a plurality of different classification identifiers, so that each batch can display static files of different classification identifiers. The static file with only one classification mark in one batch is avoided, so that the page display is avoided being too single.
In one embodiment, the batch display may be a split-screen display or a paginated display, and the present invention is not limited in any way.
According to the optional implementation mode, the static files with different file sizes are displayed separately, so that the static files displayed on the same display page are displayed more orderly, the reasonable distribution of the static files is facilitated, and the unsmooth display caused by the overlarge display files on the same display page is avoided.
Example two
Fig. 2 is a structural diagram of a code display apparatus for static text according to a second embodiment of the present invention.
In some embodiments, the code display device 20 of static text may include a plurality of functional modules composed of computer program segments. The computer programs of the various program segments in the code display apparatus 20 of the static text may be stored in a memory of the electronic device and executed by at least one processor to perform the functions of the code display of the static text (described in detail in fig. 1).
In this embodiment, the code display device 20 for static text may be divided into a plurality of functional modules according to the functions to be executed. The functional module may include: the device comprises an acquisition module 201, a generation module 202, an analysis module 203, a configuration module 204, a first display module 205 and a second display module 206. The module referred to herein is a series of computer program segments capable of being executed by at least one processor and capable of performing a fixed function and is stored in memory. In the present embodiment, the functions of the modules will be described in detail in the following embodiments.
The obtaining module 201 is configured to obtain a static text in an application program, and extract and store the static text from the application program.
The electronic equipment acquires the static text in the application program, and after the static text is acquired, the static text is extracted from the application program and stored in the same folder, so that the configuration file is generated according to the static text in the folder, and the codes corresponding to the static text in the application program can be conveniently highlighted according to the configuration file.
The application in this embodiment may be, for example, a financial application, a medical application, a game application, or other types of applications, such as an information application, an order application, an audio application, a video playing application, etc. There is at least one page (user page) in the application, and in the case of a financial application, there may be an application page, a setup page, a chat page, and a rebate page, etc. For each page in an application, there may be one or more static texts in the page.
The static text refers to a text statically configured in the application program, that is, the static text refers to a text that cannot be dynamically changed in the application program. In the case of a financial application, the financial application usually has one or more visible user pages, and the text that cannot be dynamically loaded in each user page is static text. For example, in a financial application, each user page usually has buttons, sliders, icons and the like for the user to operate, and messages and the like for prompting the user are fixedly displayed, and text contents included in the buttons, sliders, icons and the like, such as "contacts", "session lists", "group announcements", "group chat names", "group chat members" and the like, and messages fixedly displayed, such as "insurance claim" and the like, are static texts in the application.
In an optional embodiment, the obtaining the static text in the application program, and extracting and storing the static text from the application program includes:
acquiring a plurality of pages of the application program, and traversing a text suffix of each text in each page;
extracting a text containing a preset suffix in the text suffix to serve as a static text;
creating a folder, and naming the folder according to a preset file name;
and storing the static text in a named folder.
The preset suffix is a suffix of a predefined text name, and for example, jpg, pdf, or the like can be used as the preset suffix. Therefore, when the electronic device extracts the static text in the page, the electronic device can traverse the text suffix of each text in the page, extract the text containing the preset suffix in the text suffix, and the extracted text is the static text.
The preset file name may be i18n.static.
In the embodiment, the static text in the application program is acquired and stored in one folder, so that the static text is separated from the constraints of the path and the page of the application program, the effect of extracting the static text from the application program is realized, and when the static text needs to be changed subsequently, the static text is directly searched from the folder without scanning logic codes, and when the logic codes are scanned, on one hand, the scanning is missed, and on the other hand, the codes are unconsciously deleted, so that all the static texts of the application program are stored in the same folder, the risk of error in scanning the codes is reduced, and the static text is conveniently managed in a centralized manner.
The generating module 202 is configured to generate a configuration file according to the stored static text.
In this embodiment, the electronic device may generate the configuration file according to the static text stored in the folder with the preset file name.
In an optional embodiment, the generating a configuration file according to the stored static text includes:
partitioning the stored static text;
setting a name space for each static text by adopting an i18n tool;
setting a variable name and an attribute for each static text in each name space by adopting the i18n tool;
and generating a configuration file according to the static text, the name space, the variable name and the attribute.
The electronic equipment can divide the static texts stored in the folder with the preset file name into blocks according to an equal division principle, wherein the quantity of the static texts in each block is the same.
i18n (the source is the first and last characters i and n of the English word international, 18 is the number of the middle characters) is the abbreviation of "internationalization". The namespace, variable name and attribute set by the i18n tool are all unique.
The electronic device may also command a profile generated using static text processed by the i18n tool to be i18n.
In an optional embodiment, the blocking the stored static text includes:
acquiring a page identifier of the stored static text;
the static texts with the same page identifiers are divided into the same block, and the static texts with different page identifiers are divided into different blocks.
The page identification is used for distinguishing pages in the application program, and different pages in the application program correspond to different page identifications. Static text from the same page in the application has the same page identification, and static text from different pages in the application has different page identifications.
In the optional embodiment, the static text originally on the same page in the application program can be stored in the same namespace through the page identifier, and the static text originally on different pages in the application program can be stored in different namespaces.
In an optional embodiment, the dividing the static text of the same page identifier into the same block includes:
calculating the number of static texts corresponding to each same page identifier;
determining a maximum value, a second maximum value and a minimum value of the number;
generating a random number between said second maximum value and said minimum value;
and partitioning the static text corresponding to the maximum value according to the random number.
The electronic device may sort the numbers in order from large to small or from small to large, and determine the maximum value, the second large value, and the minimum value according to the sorting result, where the second large value is a value smaller than the maximum value.
A random number generation algorithm may be used to generate a random number between the second largest value and the smallest value, where the generated random number is an integer and does not include the second largest value and the smallest value.
Illustratively, assume that there are 5 pages, and the page identifiers of the 5 pages are ID1, ID2, ID3, ID4, and ID5, respectively, where the page identifier ID1 corresponds to 10 static texts, the page identifier ID2 corresponds to 6 static texts, the page identifier ID3 corresponds to 5 static texts, the page identifier ID4 corresponds to 3 static texts, and the page identifier ID5 corresponds to 3 static texts, then the maximum value is 10, the second maximum value is 6, and the minimum value is 3, a random number may be generated between 3 and 6, so as to block the 10 static texts corresponding to the page identifier ID1 according to the random number.
Since the generated random number is an integer and does not include the second largest and smallest values, the random number generated between 3 and 6 is 4 or 5. Assuming that the generated random number is 4, the 10 static texts corresponding to the page identification ID1 can be divided into two blocks, wherein one block includes 4 static texts and the other block includes 6 static texts. Assuming that the generated random number is 5, the 10 static texts corresponding to the page identification ID1 may be divided into two blocks, each of which includes 5 static texts.
In the above optional embodiment, the static text with the largest number may be determined according to the number of the static texts corresponding to the same page identifier, and a random number is generated according to the second large value and the minimum value, so that the static text with the largest number is partitioned by using the random number. The static texts with the same page identifications are divided into one block, but the static texts in the block are very time-consuming to search subsequently due to the large number of the static texts in the block, so that the static texts which are divided into the same block are divided into blocks again according to the number of the static texts corresponding to other same page identifications, the static texts with the maximum number of the page identifications are divided into blocks twice, the static texts can be conveniently and rapidly searched subsequently, and codes corresponding to the static texts can be rapidly edited.
In an alternative embodiment, the static text corresponding to the same page identifier corresponds to one namespace, and the namespace corresponding to the static text with the same page identifier and the largest number may be divided into two naming subspaces, that is, one namespace includes two naming subspaces, and each naming subspace stores one blocked static text. For example, assuming that the page identifier ID1 corresponds to 100 static texts, and the namespace set for the 100 static texts corresponding to the page identifier ID1 is name1, if the 100 static texts are divided into two blocks, where one block includes 45 static texts and the other block includes 55 static texts, then the namespace name11 may be set for the block including 45 static texts, and the namespace name12 may be set for the block including 55 static texts.
The analysis module 203 is configured to perform lexical analysis on the configuration file to obtain a content structure of the configuration file.
Because the content structure in the configuration file i18n.static includes: namespace, attribute, and variable name of each static text, so that the structure of the configuration file i18n.static becomes more complicated, but the configuration file i18n.static is the same as that of the txt document in the VS code, that is, the content in the configuration file i18n.static is the same color, so that the content structure of the configuration file i18n.static looks unclear. For developers, looking at the content of one color for a long time, visual fatigue is easy to occur, so that errors are easy to occur when developing codes, and the development efficiency is low and the development quality is poor.
In this embodiment, the content structure of the configuration file is obtained by performing lexical analysis on the configuration file, which facilitates color configuration according to the content structure, so that the content structures of the configuration file i 11 8n.static are differentiated.
The electronic device may generate a lexical analysis plug-in before performing lexical analysis on the configuration file, and perform the lexical analysis on the configuration file using the generated lexical analysis plug-in.
In an optional embodiment, the generating the lexical analysis plug-in includes:
installing a VS code plug-in scaffold;
after the installation is finished, inputting a command to generate a VS code generator code;
and after the completion, opening a VS code editor, and generating the lexical analysis plug-in after debugging and running.
Specifically, the lexical analysis plug-in is implemented based on a VS code editor, and the plug-in is developed first, and what is required to generate a plug-in code is generated when the plug-in is developed. Opening a cmd execution command nmp install-g yo generator-code to install lexical analysis plug-ins, inputting a code command to generate VS code generator codes after installation is completed, opening a VS code editor after completion, pressing an 'F5' key to debug, calling a new VS code window to display a title of an 'extended development host' in a title bar after a project runs, wherein the window is a command supporting the running plug-in project, and thus, a plug-in foundation project is generated.
The configuring module 204 is configured to configure a display color for the content structure.
The content structure in the configuration file i18n.static includes: the name space namespace, the attribute, and the variable name of each static text, the electronic device may set a first color for the name space namespace, a second color for the attribute, and a third color for the variable name of the static text in the VS code editor.
The content structure in the configuration file i18n.static may further include: number, = number, creation time Create, etc. The electronic device may also set a fourth color for # number, a fifth color for = number, and a sixth color for creation time Create.
In specific implementation, the electronic device modifies editors, semanticTokenColorCustomizations in a configuration file settings in json, and configures different content structures and colors of a configuration file i18n.static one by one.
In an alternative embodiment, said configuring the display color for the content structure comprises:
acquiring the utilization rate of each page in the application program;
determining the page with the highest utilization rate as a target page;
acquiring a target code of the target page;
matching the code structure of the target code with the content structure one by one;
configuring a display color of the content structure to match a color of a code structure of the object code that was successful.
The page utilization rate can be calculated according to the number of times that the user clicks the page, the more the number of times that the user clicks the page, the higher the page utilization rate is indicated, and the less the number of times that the user clicks the page, the lower the page utilization rate is indicated. The usage rates of different pages in the application program can be the same or different. The usage of at least two pages in an application is different. And determining the page with the highest utilization rate as a target page, and performing color configuration on the content structure of the configuration file according to the code structure of the target code of the target page. For example, the variable name of the static text in the content structure of the configuration file is configured to be red, and the attribute in the content structure of the configuration file is configured to be brown, assuming that the variable name of the static text is red in the code structure of the object code, and the attribute is brown in the code structure of the object code.
In the above optional embodiment, the page with the highest usage rate in the application program is a page frequently clicked by the user, and this page best conforms to the usage habit of the user, so that the display color of the content structure is configured to the color of the code structure of the object code that is successfully matched by determining the page with the highest usage rate in the application program as the object page and matching the code structure of the object code of the object page with the content structure of the configuration file one by one, so that the display color of the content structure can also conform to the usage habit of the user.
The first display module 205 is configured to display the code of the static text according to the color configured by the content structure.
The codes of the static text are displayed according to the colors configured by the content structure, so that the configuration file i18n.static can be seen more clearly in a VS code editor, and the content structure is more vivid, thereby assisting developers to understand the functions of the codes in the configuration file more quickly, enabling the static text to be maintained more easily, and reducing the maintenance cost of an application program.
The second display module 206 is configured to obtain a file size of the static file; matching the file size with a plurality of preset file sizes; determining the preset file size successfully matched with the file size as a target preset file size; determining a classification identifier corresponding to the size of a target preset file as a classification identifier of the static file; and when the number of the static files displayed on a certain page in the application program is larger than a preset number, displaying a plurality of the static files in batches according to the classification identification, wherein the sum of the file sizes of the static files in each batch is smaller than a preset threshold value.
The electronic equipment is pre-stored with a plurality of preset file sizes and a plurality of classification identifications, and the preset file sizes and the classification identifications have one-to-one correspondence. After the file size of each static file is obtained, matching the file size of the static file with a plurality of preset file sizes to obtain a matching result. And acquiring a classification identifier corresponding to the file size of the static file from the plurality of classification identifiers, so that the acquired classification identifier is determined as the classification identifier of the static file.
The classification identification is a file attribute of the static files and is used for distinguishing different types of static files. For example, the classification identifier is used to identify the file size of the static files, a plurality of static files with equal or similar file sizes have the same classification identifier, a plurality of static files with different file sizes or with larger differences have different classification identifiers, and the file sizes of the static files are classified through the classification identifiers.
When the number of static files in a certain page is large, a plurality of large static files are displayed simultaneously, which may cause the static files in a part of pages to be displayed incompletely or displayed unsmoothly. Therefore, because the static files are classified through the classification identifiers, the static files with different file sizes can be displayed in batches according to the classification identifiers, the sum of the file sizes of all the static files in each batch is smaller than the preset threshold value, namely the sum of the file sizes of the static files in the same batch is smaller, so that the consumed computer resources are less, and the display fluency can be improved.
In a specific implementation, each batch includes a plurality of static files corresponding to the category identifier, that is, each batch includes a plurality of static files corresponding to different category identifiers, so that each batch can display the static files with different category identifiers. The static file with only one classification mark in one batch is avoided, so that the page display is avoided being too single.
EXAMPLE III
The present embodiment provides a computer-readable storage medium, on which a computer program is stored, and when being executed by a processor, the computer program implements the steps in the code display method embodiment of the static text, for example, S11 to S15 shown in fig. 1:
s11, acquiring a static text in an application program, and extracting and storing the static text from the application program;
s12, generating a configuration file according to the stored static text;
s13, performing lexical analysis on the configuration file to obtain a content structure of the configuration file;
s14, configuring display colors for the content structure;
and S15, displaying the codes of the static texts according to the colors configured by the content structure.
Alternatively, the computer program, when executed by a processor, implements the functionality of the various modules/units in the above-described apparatus embodiments, such as modules 201-206 in fig. 2:
the obtaining module 201 is configured to obtain a static text in an application program, and extract and store the static text from the application program;
the generating module 202 is configured to generate a configuration file according to the stored static text;
the analysis module 203 is configured to perform lexical analysis on the configuration file to obtain a content structure of the configuration file;
the configuration module 204 is configured to configure a display color for the content structure;
the first display module 205 is configured to display the code of the static text according to the color configured by the content structure.
The second display module 206 is configured to obtain a file size of the static file; matching the file size with a plurality of preset file sizes; determining the preset file size successfully matched with the file size as a target preset file size; determining a classification identifier corresponding to the size of a target preset file as a classification identifier of the static file; and when the number of the static files displayed on a certain page in the application program is larger than a preset number, displaying a plurality of the static files in batches according to the classification identification, wherein the sum of the file sizes of the static files in each batch is smaller than a preset threshold value.
Example four
Fig. 3 is a schematic structural diagram of an electronic device according to a third embodiment of the present invention. In the preferred embodiment of the present invention, the electronic device 3 comprises a memory 31, at least one processor 32, at least one communication bus 33 and a transceiver 34.
It will be appreciated by those skilled in the art that the configuration of the electronic device shown in fig. 2 does not constitute a limitation of the embodiment of the present invention, and may be a bus-type configuration or a star-type configuration, and the electronic device 3 may include more or less hardware or software than those shown, or different component arrangements.
In some embodiments, the electronic device 3 is a device capable of automatically performing numerical calculation and/or information processing according to instructions set or stored in advance, and the hardware thereof includes but is not limited to a microprocessor, an application specific integrated circuit, a programmable gate array, a digital processor, an embedded device, and the like. The electronic device 3 may also include a client device, which includes, but is not limited to, any electronic product that can interact with a client through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device, for example, a personal computer, a tablet computer, a smart phone, a digital camera, and the like.
The electronic device 3 is only an example, and other existing or future electronic products, such as those that may be adapted to the present invention, are also included in the scope of the present invention and are incorporated by reference herein.
In some embodiments, the memory 31 has stored therein a computer program which, when executed by the at least one processor 32, implements all or part of the steps of the method of code display of static text as described. The Memory 31 includes a Read-Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), a One-time Programmable Read-Only Memory (OTPROM), an electronically Erasable rewritable Read-Only Memory (Electrically-Erasable Programmable Read-Only Memory (EEPROM)), an optical Read-Only disk (CD-ROM) or other optical disk Memory, a magnetic disk Memory, a tape Memory, or any other medium readable by a computer capable of carrying or storing data.
Further, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the blockchain node, and the like.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
In some embodiments, the at least one processor 32 is a Control Unit (Control Unit) of the electronic device 3, connects various components of the electronic device 3 by various interfaces and lines, and executes various functions and processes data of the electronic device 3 by running or executing programs or modules stored in the memory 31 and calling data stored in the memory 31. For example, the at least one processor 32, when executing the computer program stored in the memory, implements all or part of the steps of the code display method of static text described in the embodiment of the present invention; or implement all or part of the functionality of the code display means of static text. The at least one processor 32 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips.
In some embodiments, the at least one communication bus 33 is arranged to enable connection communication between the memory 31 and the at least one processor 32 or the like.
Although not shown, the electronic device 3 may further include a power supply (such as a battery) for supplying power to various components, and preferably, the power supply may be logically connected to the at least one processor 32 through a power management device, so as to implement functions of managing charging, discharging, and power consumption through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device 3 may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
The integrated unit implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, an electronic device, or a network device) or a processor (processor) to execute parts of the methods according to the embodiments of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or that the singular does not exclude the plural. A plurality of units or means recited in the specification may also be implemented by one unit or means through software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A method for displaying codes of static text, the method comprising:
acquiring a static text in an application program, and extracting and storing the static text from the application program;
generating a configuration file according to the stored static text;
performing lexical analysis on the configuration file to obtain a content structure of the configuration file;
configuring a display color for the content structure;
and displaying the codes of the static text according to the colors configured by the content structure.
2. The method for code display of static text according to claim 1, wherein the obtaining the static text in an application program, and extracting and storing the static text from the application program comprises:
acquiring a plurality of pages of the application program, and traversing a text suffix of each text in each page;
extracting a text containing a preset suffix in the text suffix to serve as a static text;
creating a folder, and naming the folder according to a preset file name;
and storing the static text in a named folder.
3. The method for code display of static text according to claim 1, wherein the generating a configuration file from the stored static text comprises:
partitioning the stored static text;
setting a name space for each static text by adopting an i18n tool;
setting a variable name and an attribute for each static text in each name space by adopting the i18n tool;
and generating a configuration file according to the static text, the name space, the variable name and the attribute.
4. The method for code display of static text according to claim 3, wherein said blocking the stored static text comprises:
acquiring a page identifier of the stored static text;
the static texts with the same page identifications are divided into the same block, and the static texts with different page identifications are divided into different blocks.
5. The code display method of static text according to claim 4, wherein said dividing the static text of the same page id into the same block comprises:
calculating the number of static texts corresponding to each same page identifier;
determining a maximum value, a second maximum value and a minimum value of the number;
generating a random number between said second maximum value and said minimum value;
and partitioning the static text corresponding to the maximum value according to the random number.
6. The code display method of static text according to any one of claims 1 to 5, wherein the configuring of the display color for the content structure comprises:
acquiring the utilization rate of each page in the application program;
determining the page with the highest utilization rate as a target page;
acquiring a target code of the target page;
matching the code structure of the target code with the content structure one by one;
configuring a display color of the content structure to match a color of a code structure of the object code that was successful.
7. The code display method of static text according to any one of claims 1 to 5, characterized in that the method further comprises:
acquiring the file size of the static file;
matching the file size with a plurality of preset file sizes;
determining the preset file size successfully matched with the file size as a target preset file size;
determining a classification identifier corresponding to the size of the target preset file as a classification identifier of the static file;
and when the number of the static files displayed on a certain page in the application program is larger than a preset number, displaying a plurality of the static files in batches according to the classification identification, wherein the sum of the file sizes of the static files in each batch is smaller than a preset threshold value.
8. A code display device for static text, the device comprising:
the acquisition module is used for acquiring a static text in an application program, and extracting and storing the static text from the application program;
the generating module is used for generating a configuration file according to the stored static text;
the analysis module is used for carrying out lexical analysis on the configuration file to obtain a content structure of the configuration file;
a configuration module for configuring a display color for the content structure;
and the display module is used for displaying the codes of the static texts according to the colors configured by the content structure.
9. An electronic device, characterized in that the electronic device comprises a processor and a memory, the processor being configured to implement a code display method of static text according to any one of claims 1 to 7 when executing a computer program stored in the memory.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out a method of code display of static text according to any one of claims 1 to 7.
CN202211436564.0A 2022-11-16 2022-11-16 Code display method and device of static text, electronic equipment and storage medium Pending CN115730562A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211436564.0A CN115730562A (en) 2022-11-16 2022-11-16 Code display method and device of static text, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211436564.0A CN115730562A (en) 2022-11-16 2022-11-16 Code display method and device of static text, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115730562A true CN115730562A (en) 2023-03-03

Family

ID=85296128

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211436564.0A Pending CN115730562A (en) 2022-11-16 2022-11-16 Code display method and device of static text, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115730562A (en)

Similar Documents

Publication Publication Date Title
CN113282795B (en) Data structure diagram generation and updating method and device, electronic equipment and storage medium
CN113806434B (en) Big data processing method, device, equipment and medium
CN113094674A (en) Page display method and device, electronic equipment and storage medium
CN112486491A (en) Page generation method and device, computer equipment and storage medium
CN114020256A (en) Front-end page generation method, device and equipment and readable storage medium
CN114707474A (en) Report generation method and device, electronic equipment and computer readable storage medium
CN113434542B (en) Data relationship identification method and device, electronic equipment and storage medium
CN114185776A (en) Big data point burying method, device, equipment and medium for application program
CN107256167A (en) The upgrade control method and upgrading control device migrated applied to application system
CN115730562A (en) Code display method and device of static text, electronic equipment and storage medium
CN114398282A (en) Test script generation method, device, equipment and storage medium
CN114356379A (en) Backup-based service upgrading method, device, equipment and storage medium
CN114881313A (en) Behavior prediction method and device based on artificial intelligence and related equipment
CN112667874A (en) Webpage data extraction method and device, electronic equipment and storage medium
CN113268695A (en) Data embedding point processing method and device and related equipment
CN112905470A (en) Interface calling method and device, computer equipment and medium
CN114860314B (en) Deployment upgrading method, device, equipment and medium based on database compatibility
CN114637564B (en) Data visualization method and device, electronic equipment and storage medium
CN112308440B (en) Work order processing method, device, computer equipment and computer readable storage medium
EP4141586A1 (en) Method and system for generating user specific engineering programs in a multi-user engineering environment
CN113886446A (en) Job automatic scheduling method and device, electronic equipment and readable storage medium
CN114968415A (en) Configuration file modification method, device, equipment and storage medium
CN114816439A (en) Big data deployment method, device, equipment and storage medium
CN114925688A (en) Data processing method and device based on artificial intelligence, electronic equipment and medium
CN114218905A (en) Form configuration method and device, computer 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