CN114416035A - Data processing method and device, electronic equipment and storage medium - Google Patents
Data processing method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN114416035A CN114416035A CN202210052775.8A CN202210052775A CN114416035A CN 114416035 A CN114416035 A CN 114416035A CN 202210052775 A CN202210052775 A CN 202210052775A CN 114416035 A CN114416035 A CN 114416035A
- Authority
- CN
- China
- Prior art keywords
- processed
- target
- character string
- file
- character strings
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/903—Querying
- G06F16/90335—Query processing
- G06F16/90348—Query processing by searching ordered data, e.g. alpha-numerically ordered data
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a data method, a data device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring a code file to be processed corresponding to a target project; determining an abstract syntax tree corresponding to a code file to be processed; the abstract syntax tree comprises root nodes and leaf nodes, and the root nodes and the leaf nodes correspond to character strings to be processed in the code files to be processed; acquiring character strings to be processed corresponding to each node in an abstract syntax tree, and determining at least one type of target character string corresponding to the character strings to be processed according to a preset configuration file; and updating the target character strings corresponding to the character strings to be processed into the target entry file so as to display the target character strings based on the target character strings stored in the target entry file. The scheme provided by the embodiment of the invention solves the problem that the creation of the internationalized entry cannot be automatically completed, and realizes the automatic generation of the internationalized entry.
Description
Technical Field
The embodiment of the invention relates to the technical field of data processing, in particular to a data processing method and device, electronic equipment and a storage medium.
Background
Internationalization is one way to design and manufacture products that easily accommodate the requirements of different areas. It requires the extraction of all regional language, country/region and culture related elements from the product. In other words, the functionality and code design of an application takes into account the need to run in different regions, the code of which simplifies the production of different local versions, and the process of developing such an application is known as internationalization.
At present, in the internationalization of an application program, the internationalization entry corresponding to a code file of the application program is mainly created, but in the creation process of the internationalization entry, a developer is often required to manually create the internationalization entry, and the internationalization entry cannot be automatically created. The creation of the internationalized entries is generally realized by regularly matching character strings in the code files, all the code files need to be traversed, and when the number of items is huge, the traversal time is very long. In addition, strings matched using regularization have certain errors and are not flexible enough to satisfy all situations. Therefore, there is a need for improvements in the way existing internationalized entries are created.
Disclosure of Invention
The invention provides a data processing method, a data processing device, electronic equipment and a storage medium, which are used for realizing automatic creation of international entries and improving the development efficiency of developers.
In a first aspect, an embodiment of the present invention provides a data processing method, including:
acquiring a code file to be processed corresponding to a target project;
determining an abstract syntax tree corresponding to the code file to be processed; the abstract syntax tree comprises a root node and leaf nodes, and the root node and the leaf nodes correspond to character strings to be processed in the code file to be processed;
acquiring character strings to be processed corresponding to each node in the abstract syntax tree, and determining at least one type of target character string corresponding to the character strings to be processed according to a preset configuration file;
and updating the target character strings corresponding to the character strings to be processed into a target entry file so as to display the target character strings based on the target character strings stored in the target entry file.
In a second aspect, an embodiment of the present invention further provides a data processing apparatus, including:
the code file acquisition module is used for acquiring a code file to be processed corresponding to the target project;
the abstract syntax tree determining module is used for determining an abstract syntax tree corresponding to the code file to be processed; the abstract syntax tree comprises a root node and leaf nodes, and the root node and the leaf nodes correspond to character strings to be processed in the code file to be processed;
the target character string determining module is used for acquiring the character strings to be processed corresponding to all nodes in the abstract syntax tree and determining at least one type of target character strings corresponding to the character strings to be processed according to a preset configuration file;
and the entry file updating module is used for updating the target character strings corresponding to the character strings to be processed into the target entry file so as to display the target character strings based on the target character strings stored in the target entry file.
In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method according to any one of the embodiments of the present invention.
In a fourth aspect, the embodiments of the present invention further provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are used for executing the data processing method according to any one of the embodiments of the present invention.
According to the technical scheme of the embodiment, the code file to be processed corresponding to the target project is obtained, the abstract syntax tree corresponding to the code file to be processed is constructed, whether the entry is an internationalized entry is determined according to the character string to be processed corresponding to each node in the syntax tree, and then the entries under multiple language types corresponding to the internationalized entry are generated according to the preset configuration file. Further, the generated entries in multiple language types are stored in the target entry file, so that the entries in a certain language can be acquired from the entry file when the device is used, and the internationalized entries in the code file to be processed are directly replaced, the problems that in the prior art, the creation of the internationalized entries needs manual creation by a developer and cannot be automatically generated, and when the number of target projects is large, the creation efficiency of the internationalized entry file is low, errors exist, and the internationalized entries are not flexible enough are solved, the automatic generation of the internationalized entries is realized, the internationalized entries can be directly replaced by the entries in the certain language when the device is used, the development of a multilingual software version is simplified, and the development efficiency of the developer is improved.
Drawings
In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, a brief description is given below of the drawings used in describing the embodiments. It should be clear that the described figures are only views of some of the embodiments of the invention to be described, not all, and that for a person skilled in the art, other figures can be derived from these figures without inventive effort.
Fig. 1 is a schematic flowchart of a data processing method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a data processing method according to a second embodiment of the present invention;
fig. 3 is a schematic flowchart of a data processing method according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a data processing apparatus according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a data processing method according to an embodiment of the present invention, where the method is applicable to determining international entries corresponding to each item and storing the entries for use.
With the global development of computer applications, a great demand of user software is to support local language characters, so that a great number of existing software products need to be internationalized. Internationalization is one way to design and manufacture products that easily accommodate the requirements of different areas. It requires the extraction of all regional language, country/region and culture related elements from the product. In other words, the functionality and code design of the application takes into account the need to run in different regions, the code of which simplifies the production of different local versions. The process of developing such programs is called internationalization.
As shown in fig. 1, the method includes:
and S110, acquiring a code file to be processed corresponding to the target project.
Wherein, the target project can be understood as an application program with multiple language versions developed by a developer. A developer may write a code file corresponding to a target project. And taking the written code file under a certain language as the code file to be processed. And determining the entries needing international processing based on the code file to be processed, so as to process the entries. During the development of the multi-lingual version of the application, the developer needs to use the code file corresponding to the target project. And acquiring a code file required to be used for developing the target project, and taking the acquired code file as a code file to be processed corresponding to the target project.
Specifically, the to-be-processed code file corresponding to the target item may be obtained by writing command information in a command line, where the command information includes a storage location of the to-be-processed code file, and by writing the command information in the command line and pressing a Ctrl key, the to-be-processed code file may be automatically obtained according to the storage location included in the command information. The method can also be used for triggering operation of a developer on a mobile terminal or a PC terminal, and a file triggered by the developer is used as a code file to be processed. Illustratively, a file list is displayed on a display interface of the mobile terminal or the PC, and a developer can select one or more files from the file list as code files to be processed by touching or clicking the display interface of the PC.
And S120, determining an abstract syntax tree corresponding to the code file to be processed.
In computer science, an Abstract Syntax Tree (AST), or simply Syntax Tree (Syntax Tree), is an Abstract representation of the Syntax structure of source code. It represents the syntactic structure of the programming language in the form of a tree, each node on the tree representing a structure in the source code. The abstract syntax tree comprises a root node and leaf nodes, and the root node and the leaf nodes correspond to character strings to be processed in the code files to be processed.
Specifically, the code file to be processed is abstracted into an abstract syntax tree structure, the code file to be processed contains character strings to be processed, the character strings to be processed in the code file to be processed are represented by root nodes and leaf nodes in the abstract syntax tree, and the root nodes and the leaf nodes correspond to the character strings to be processed in the code file to be processed.
Optionally, the determining an abstract syntax tree corresponding to the to-be-processed code file may further include: filtering the code information in the code file to be processed according to preset character string suffix information to obtain a code file to be used; compiling the code file to be used based on the object tool chain, and determining an abstract syntax tree corresponding to the code file to be used.
Specifically, when a developer writes a code file to be processed, the developer may add character string suffix information to a character string that needs to be internationalized in the code file to be processed, and exemplarily add suffix information to the character string that needs to be internationalized in the code file to be processed to html. Further, some character string suffix information may be preset, a code file that does not conform to the preset character string suffix information in the code file to be processed is filtered, and a code file that is the same as the preset character string suffix information is reserved as a code file to be used. For example, the code file whose suffix information does not conform to html format in the code file to be processed may be filtered. The present embodiment is only an example of the suffix information in the code file, and is not limited. Specifically, some suffix information corresponding to code files which are only concentrated on interface display can be selected as preset character string suffix information, the code files which do not accord with the preset character string suffix information in the code files to be processed are filtered based on the preset character string suffix information, and the code files for page display are reserved as the code files to be used.
After the code file to be processed is filtered according to the preset character string suffix information to obtain the code file to be used, the code file to be used can be compiled based on the target tool chain to determine the abstract syntax tree corresponding to the code file to be used. Illustratively, the file of the Code to be used can be traversed by adopting the parse and the reverse in the base plug-in based on the Visual Studio Code, and the file of the Code to be used can be resolved into an abstract syntax tree. Among them, Visual Studio Code is a cross-platform source Code editor that Microsoft formally announced to run on Mac OS X, Windows and Linux in 2015, 4/30 Build developer, and aims to write modern Web and cloud applications. Can run on the desktop and can be used for Windows, macOS and Linux. It has built-in support for JavaScript, TypeScript and node. js, and has rich ecosystems for other languages (e.g., C + +, C #, Java, Python, PHP, Go) and runtime (e.g.,. NET and Unity) extensions.
S130, acquiring character strings to be processed corresponding to each node in the abstract syntax tree, and determining at least one type of target character string corresponding to the character strings to be processed according to a preset configuration file.
Wherein each node refers to the root node and the leaf node mentioned above. The configuration file may contain language conversion type information. The language translation type information may be stored in key-value pairs, optionally class. Class (key value), where key may represent a unique identification of a string, values corresponding to different language types. And processing the character string to be processed based on a preset algorithm to obtain a corresponding key value, and converting the character string to be processed into a character string in a certain language type to obtain a value. The target character string is a character string in a certain language type corresponding to the character string to be processed.
Specifically, each root node and leaf node in the abstract syntax tree can be traversed by babel, and whether the character string is a character string to be processed is judged according to the attribute information of the character string to be selected corresponding to each node. If yes, converting the character string to be processed into a character string under a certain language type according to a language conversion type contained in a preset configuration file, and taking the character string under the certain language type as a target character string. The language conversion types may be, for example, french, japanese, english, chinese, etc., and the specific language types are not limited herein.
Optionally, obtaining the to-be-processed character string corresponding to each node in the abstract syntax tree includes: traversing attribute information of character strings to be selected of each root node and leaf node on the abstract syntax tree; determining a character string to be processed from the character string to be selected according to the attribute information and preset white list information;
specifically, the target tool chain can traverse each root node and leaf node on the abstract syntax tree, and the attribute information of the character string to be selected corresponding to each node is determined. The attribute information of the character string to be selected may be a type of the character string, a length of the character string, index information of the character string, and the like, and is not limited herein. The developer may preset white list information, where the white list information may be a type of a certain character string, compare a character string type in the attribute information of the character string to be selected with the character string type in the white list information, and determine a character string of the same type as the character string in the white list information as a character string to be processed.
Optionally, the determining, according to a preset configuration file, at least one type of target character string corresponding to the character string to be processed includes; determining target identifiers corresponding to the character strings to be processed according to the generation rules in the configuration file, and converting the character strings to be processed into target character strings corresponding to at least one language type in the generation rules; the character string to be processed is an internationalized character string, and the target character string is a character string of the character string to be processed under different language types.
The target mark is generated according to the sequence of international conversion of each character string to be processed, or a random number is generated by adopting a snowflake algorithm after each character string to be processed is converted into a target character string.
Specifically, a developer may preset a configuration file, where the configuration file includes a generation rule, and the generation rule may be a custom rule configured by the developer in a Visual Studio Code, or a storage rule of a target character string, or a language type to be converted of the character string to be processed. For example, a developer may configure a storage rule of a target character string as a storage manner of a key value pair, and a language type to be converted of the character string to be processed is english. In computer science, name-value pairs, which may also be referred to as key-value pairs or attribute-value pairs, are basic data that are represented in computing systems and applications. The embodiment may set a target identifier corresponding to each target character string, where the target identifier is associated with the target character string. Specifically, the target identification numbers, i.e., the target identifications, of the target character strings may be sequentially set according to the sequence of converting the character string to be processed into the target character string. And taking the target identification corresponding to the character string to be processed as a key in the key value pair, taking the target character string as a value in the key value pair, and converting the character string to be processed into a character string in English according to the language conversion type in the configuration file generation rule.
Specifically, the language conversion type may also be set to the chinese language, that is, the character string to be processed may be converted into a character string in the chinese language. Specifically, the type and number of the conversion languages are not limited, and the character string to be processed may be converted into a target character string in a plurality of languages.
And S140, updating the target character strings corresponding to the character strings to be processed into the target entry file, and displaying the target character strings based on the target character strings stored in the target entry file. The method has the advantages that when the character strings to be processed in the code files to be processed corresponding to the target projects need to be internationally converted, the target character strings corresponding to the character strings to be processed can be directly obtained from the target entry files, the convenience of language type conversion is improved, and the problems that manual conversion is needed in the prior art, the efficiency is low, and the labor cost is high are solved.
Optionally, the updating the target character string corresponding to each character string to be processed into the target entry file includes: and correspondingly storing the target identification of each character string to be processed and the corresponding target character string into the target entry file.
The target identifier may be generated according to the sequence of international conversion of each character string to be processed, or may be a random number generated by adopting a snowflake algorithm after each character string to be processed is converted into a target character string.
For example, the target identifier and the language type may be stored and updated in a term file according to a storage manner of the key value pair, where the term file includes a relationship between the identifier corresponding to the character string to be processed and the language type. The KEY in the KEY pair is used to represent the target identifier, and the VALUE in the KEY pair is used to represent the language type.
Illustratively, the target character strings corresponding to the target identifier 1 in the three languages are respectively a character string a, a character string B and a character string C, a corresponding relationship between the target character strings and the target identifier is established, and the corresponding relationship and the target character strings are stored in the entry file.
The display page of the application program can be displayed based on each target character string stored in the target entry file, and the display is the internationalized entry file. The method is suitable for software development requiring multi-language versions, and developers only need to concentrate on development work, so that the development efficiency of the developers is improved.
According to the technical scheme of the embodiment, the code file to be processed corresponding to the target project is obtained, the abstract syntax tree corresponding to the code file to be processed is constructed, whether the entry is an internationalized entry is determined according to the character string to be processed corresponding to each node in the syntax tree, and then the entries under multiple language types corresponding to the internationalized entry are generated according to the preset configuration file. Further, the generated entries in multiple language types are stored in the target entry file, so that the entries in a certain language can be acquired from the entry file when the target entry file is used, and the internationalized entries in the code file to be processed are directly replaced. The problems that in the prior art, the creation of the internationalized entry needs manual creation by a developer, the creation cannot be automatically performed, and when the number of target projects is large, the creation efficiency of an internationalized entry file is low, errors exist, and the internationalized entry file is not flexible enough are solved, the internationalized entry can be automatically generated, and can be directly replaced by the entry in a certain language during use, so that the development of a multi-language software version is simplified, and the development efficiency of the developer is improved.
Example two
Fig. 2 is a flowchart illustrating a data processing method according to a second embodiment of the present invention. On the basis of the foregoing embodiment, after the target entry file is determined, the corresponding target character string may be called from the target entry file according to a trigger operation of a user to obtain a code file in a certain language type, and a specific implementation manner of the method may be described in detail in this technical solution. The technical terms that are the same as or corresponding to the above-mentioned embodiments are not repeated.
As shown in fig. 2, the method includes:
and S210, acquiring a code file to be processed corresponding to the target project.
S220, determining an abstract syntax tree corresponding to the code file to be processed; the abstract syntax tree comprises a root node and leaf nodes, and the root node and the leaf nodes correspond to character strings to be processed in the code files to be processed.
S230, acquiring character strings to be processed corresponding to each node in the abstract syntax tree, and determining at least one type of target character string corresponding to the character strings to be processed according to a preset configuration file.
And S240, updating the target character strings corresponding to the character strings to be processed into a target entry file, and displaying the target character strings based on the target character strings stored in the target entry file.
S250, when the language type switching operation is received, determining the switched target language type;
specifically, the developer may trigger the operation of switching the language type through the mobile terminal or the PC, for example, the developer inputs the language type to be switched, that is, the target language type, on the UI interface, which may be chinese, japanese, german, or the like, and is not limited herein.
S260, calling target character strings of the character strings to be processed under the target language type from the entry file, and replacing the target character strings into the code file to be processed.
Specifically, after a developer inputs a target language type at a mobile terminal or a PC, the data processing apparatus according to the embodiment of the present invention retrieves a target character string of each to-be-processed character string in the target language type from the entry file, and replaces each to-be-processed character string in the to-be-processed code file with a corresponding target character string. Illustratively, a developer sets a target language type chinese, the character string 1 to be processed is "function", and the character string 1 "function" to be processed in the code file to be processed can be replaced with "function" by querying the target character string 1 corresponding to the character string 1 "function" to be processed in the entry file. According to the method, the target character string can be replaced into the code file to be processed.
It should be noted that, before the language type conversion, a copy of the code file to be processed is needed to keep the original code file to be processed.
According to the technical scheme of the embodiment, the code file to be processed corresponding to the target project is obtained, the abstract syntax tree corresponding to the code file to be processed is constructed, whether the entry is an internationalized entry is determined according to the character string to be processed corresponding to each node in the syntax tree, and then the entries under multiple language types corresponding to the internationalized entry are generated according to the preset configuration file. And further, storing the generated entries under multiple language types in a target entry file, determining the language type to be converted when receiving a language switching operation, acquiring the entries under the language from the entry file, and directly replacing the internationalized entries in the code file to be processed. The problems that in the prior art, the creation of the internationalized entry needs manual creation by a developer, the creation cannot be automatically performed, and when the number of target projects is large, the creation efficiency of an internationalized entry file is low, errors exist, and the internationalized entry file is not flexible enough are solved, the internationalized entry can be automatically generated, and can be directly replaced by the entry in a certain language during use, so that the development of a multi-language software version is simplified, and the development efficiency of the developer is improved.
EXAMPLE III
As a preferred embodiment of the foregoing embodiments, the technical solution may specifically be:
referring to FIG. 3, all code files are traversed first. Specifically, the code files are traversed by using the parse and the reverse of the base, and the code files are filtered according to the suffixes, so that only the code files for interface display are focused. Selecting some suffix information corresponding to the code file which is only focused on the interface display as preset character string suffix information, filtering the code file which does not accord with the preset character string suffix information in the code file to be processed based on the preset character string suffix information, and reserving the code file for page display as the code file to be used. The file filtering type is configurable, so that the time required by traversing the code file can be greatly saved.
Again, the file is parsed into an abstract syntax tree. And generating an abstract syntax tree by analyzing and traversing the file traversed in the last step.
And further traversing character string nodes on the syntax tree. Specifically, nodes of all character string types on the syntax tree are traversed, and character strings corresponding to the root node and the leaf nodes, namely character strings to be processed, are determined.
And further, extracting the character strings required to be internationalized. And judging whether the character string is finally displayed in the software interface or not according to the type of the node. Specifically, nodes of all character string types on the syntax tree are traversed, and whether the character string is finally displayed in the software interface is judged according to the type of the node. The attribute information of the character string to be selected may be a type of the character string, a length of the character string, index information of the character string, and the like, and is not limited herein. The developer can preset white list information, wherein the white list information can be the type of a certain character string, the character string type in the character string attribute information to be selected is compared with the character string type in the white list information, and the character string with the same type as the character string in the white list information is determined as a character string to be processed.
And finally, generating corresponding entries according to the rules and writing the entries into entry files. And generating an internationalized entry by using a certain rule for the extracted character string needing internationalization, or generating the internationalized entry according to a custom rule configured in the Visual Studio Code by a developer. And writing the generated internationalized entries into corresponding files in a file writing mode to complete the whole internationalized entry creating process.
According to the technical scheme, all the code files are traversed, the code files are filtered according to suffixes, and only the code files focused on interface display are reserved; generating an abstract syntax tree by analyzing and traversing the traversed file; and traversing nodes of all character string types on the grammar tree, and judging whether the character string is finally displayed in the software interface or not according to the type of the node. And generating the international entries by the character strings through a certain rule, or generating the international entries according to a user-defined rule configured in a Visual Studio Code by a developer, and writing the generated international entries into corresponding files in a file writing mode to complete the whole international entry creating process. The problem that in the process of internationalized entry creation, developers are often required to manually create entries and cannot automatically complete the creation is solved. The general implementation mode is to traverse all the files by matching character strings regularly, and when the number of items is huge, the traversal time is very long. The method has the advantages that the problems that certain errors exist in matching by using the regular method and the problems are not flexible enough to meet all conditions, the international entry creation is automatically completed, the accuracy rate of scanning entries is improved by defining a white list and learning the existing entry rules, character string fields needing to be internationalized are screened out, developers are helped to directly generate the international entries, the method is suitable for software development needing multi-language versions, the developers only need to concentrate on development work, the problems that the creation of the international entries in the prior art needs manual creation of developers and cannot be automatically generated are solved, when the number of target items is huge, the creation efficiency of international entry files is low, the international entries are generated automatically, the international entries can be directly replaced by entries in a certain language during use, the development of the multi-language software version is simplified, and the development efficiency of developers is improved.
Example four
Fig. 4 is a data processing apparatus according to a fourth embodiment of the present invention, where the apparatus includes: a code file obtaining module 410, an abstract syntax tree determining module 420, a target character string determining module 430 and a term file updating module 430.
A code file obtaining module 410, configured to obtain a code file to be processed corresponding to the target project;
an abstract syntax tree determining module 420, configured to determine an abstract syntax tree corresponding to the to-be-processed code file; the abstract syntax tree comprises a root node and leaf nodes, and the root node and the leaf nodes correspond to character strings to be processed in the code file to be processed;
a target character string determining module 430, configured to obtain a to-be-processed character string corresponding to each node in the abstract syntax tree, and determine, according to a preset configuration file, at least one type of target character string corresponding to the to-be-processed character string;
and the entry file updating module 430 is configured to update the target character strings corresponding to the character strings to be processed into the target entry file, so as to display the target character strings based on the target character strings stored in the target entry file.
The data processing device provided by this embodiment can be used to execute the data processing method provided by any of the above embodiments, and has corresponding functions and advantages.
On the basis of any optional technical solution in the embodiment of the present invention, optionally, the abstract syntax tree determining module includes:
the code file to be used acquiring unit is used for filtering the code information in the code file to be processed according to preset character string suffix information to obtain a code file to be used;
and the abstract syntax tree determining unit is used for compiling the code file to be used based on the target tool chain and determining the abstract syntax tree corresponding to the code file to be used.
On the basis of any optional technical solution in the embodiment of the present invention, optionally, the target character string determining module includes:
the traversal module is used for traversing the attribute information of the character strings to be selected of each root node and leaf node on the abstract syntax tree;
and the character string to be processed determining module is used for determining the character string to be processed from the character string to be selected according to the attribute information and the preset white list information.
On the basis of any optional technical solution in the embodiment of the present invention, optionally, the target character string determining module further includes:
and the character string conversion module to be processed is used for determining a target identifier corresponding to each character string to be processed according to the generation rule in the configuration file and converting each character string to be processed into a target character string corresponding to at least one language type in the generation rule.
On the basis of any optional technical solution in the embodiment of the present invention, optionally, the entry file updating module is further configured to:
and correspondingly storing the target identification of each character string to be processed and the corresponding target character string into the target entry file.
On the basis of any optional technical solution in the embodiment of the present invention, optionally, the to-be-processed character string is an internationalized character string, and the target character string is a character string of the to-be-processed character string in different language types.
According to the technical scheme of the embodiment, the code file to be processed corresponding to the target project is obtained, the abstract syntax tree corresponding to the code file to be processed is constructed, whether the entry is an internationalized entry is determined according to the character string to be processed corresponding to each node in the syntax tree, and then the entries under multiple language types corresponding to the internationalized entry are generated according to the preset configuration file. Further, the generated entries in multiple language types are stored in the target entry file, so that the entries in a certain language can be acquired from the entry file when the target entry file is used, and the internationalized entries in the code file to be processed are directly replaced. The problems that in the prior art, the creation of the internationalized entry needs manual creation by a developer, the creation cannot be automatically performed, and when the number of target projects is large, the creation efficiency of an internationalized entry file is low, errors exist, and the internationalized entry file is not flexible enough are solved, the internationalized entry can be automatically generated, and can be directly replaced by the entry in a certain language during use, so that the development of a multi-language software version is simplified, and the development efficiency of the developer is improved.
The data processing device provided by the embodiment of the invention can execute the data processing method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, the units and modules included in the apparatus are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the embodiment of the invention.
EXAMPLE five
Fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention. FIG. 5 illustrates a block diagram of an exemplary electronic device 50 suitable for use in implementing embodiments of the present invention. The electronic device 50 shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 5, electronic device 50 is embodied in the form of a general purpose computing device. The components of the electronic device 50 may include, but are not limited to: one or more processors or processing units 501, a system memory 502, and a bus 503 that couples the various system components (including the system memory 502 and the processing unit 501).
The system memory 502 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)504 and/or cache memory 505. The electronic device 50 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 506 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, commonly referred to as a "hard drive"). Although not shown in FIG. 5, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 503 by one or more data media interfaces. Memory 502 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 508 having a set (at least one) of program modules 507 may be stored, for instance, in memory 502, such program modules 507 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 507 generally perform the functions and/or methodologies of embodiments of the invention as described herein.
The electronic device 50 may also communicate with one or more external devices 509 (e.g., keyboard, pointing device, display 510, etc.), with one or more devices that enable a user to interact with the electronic device 50, and/or with any devices (e.g., network card, modem, etc.) that enable the electronic device 50 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interfaces 511. Also, the electronic device 50 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via the network adapter 512. As shown, the network adapter 512 communicates with the other modules of the electronic device 50 over the bus 503. It should be appreciated that although not shown in FIG. 5, other hardware and/or software modules may be used in conjunction with electronic device 50, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 501 executes various functional applications and data processing, for example, a method of data processing provided by an embodiment of the present invention, by executing a program stored in the system memory 502.
EXAMPLE six
An embodiment of the present invention further provides a storage medium containing computer-executable instructions, which when executed by a computer processor, perform a method of data processing, the method including:
acquiring a code file to be processed corresponding to a target project;
determining an abstract syntax tree corresponding to the code file to be processed; the abstract syntax tree comprises a root node and leaf nodes, and the root node and the leaf nodes correspond to character strings to be processed in the code file to be processed;
acquiring character strings to be processed corresponding to each node in the abstract syntax tree, and determining at least one type of target character string corresponding to the character strings to be processed according to a preset configuration file;
and updating the target character strings corresponding to the character strings to be processed into a target entry file so as to display the target character strings based on the target character strings stored in the target entry file.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for embodiments of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims (10)
1. A data processing method, comprising:
acquiring a code file to be processed corresponding to a target project;
determining an abstract syntax tree corresponding to the code file to be processed; the abstract syntax tree comprises a root node and leaf nodes, and the root node and the leaf nodes correspond to character strings to be processed in the code file to be processed;
acquiring character strings to be processed corresponding to each node in the abstract syntax tree, and determining at least one type of target character string corresponding to the character strings to be processed according to a preset configuration file;
and updating the target character strings corresponding to the character strings to be processed into a target entry file so as to display the target character strings based on the target character strings stored in the target entry file.
2. The method of claim 1, wherein determining the abstract syntax tree corresponding to the code file to be processed comprises:
filtering the code information in the code file to be processed according to preset character string suffix information to obtain a code file to be used;
compiling the code file to be used based on the object tool chain, and determining an abstract syntax tree corresponding to the code file to be used.
3. The method according to claim 1, wherein the obtaining the to-be-processed character string corresponding to each node in the abstract syntax tree comprises:
traversing attribute information of character strings to be selected of each root node and leaf node on the abstract syntax tree;
and determining a character string to be processed from the character string to be selected according to the attribute information and preset white list information.
4. The method according to claim 1, wherein the determining at least one type of target character string corresponding to the character string to be processed according to a preset configuration file comprises;
and determining a target identifier corresponding to each character string to be processed according to a generation rule in the configuration file, and converting each character string to be processed into a target character string corresponding to at least one language type in the generation rule.
5. The method of claim 4, wherein the updating the target character string corresponding to each character string to be processed into the target entry file comprises:
and correspondingly storing the target identification of each character string to be processed and the corresponding target character string into the target entry file.
6. The method according to any one of claims 1 to 5, wherein the character string to be processed is an internationalized character string, and the target character string is a character string of the character string to be processed under different language types.
7. The method of claim 6, further comprising:
when receiving a language type switching operation, determining a target language type to which the switching is performed;
and calling a target character string of each character string to be processed under the target language type from the entry file, and replacing the target character string into the code file to be processed.
8. A data processing apparatus, comprising:
the code file acquisition module is used for acquiring a code file to be processed corresponding to the target project;
the abstract syntax tree determining module is used for determining an abstract syntax tree corresponding to the code file to be processed; the abstract syntax tree comprises a root node and leaf nodes, and the root node and the leaf nodes correspond to character strings to be processed in the code file to be processed;
the target character string determining module is used for acquiring the character strings to be processed corresponding to all nodes in the abstract syntax tree and determining at least one type of target character strings corresponding to the character strings to be processed according to a preset configuration file;
and the entry file updating module is used for updating the target character strings corresponding to the character strings to be processed into the target entry file so as to display the target character strings based on the target character strings stored in the target entry file.
9. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a data processing method as claimed in any one of claims 1-7.
10. A storage medium containing computer-executable instructions for performing the data processing method of any one of claims 1 to 7 when executed by a computer processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210052775.8A CN114416035A (en) | 2022-01-18 | 2022-01-18 | Data processing method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210052775.8A CN114416035A (en) | 2022-01-18 | 2022-01-18 | Data processing method and device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114416035A true CN114416035A (en) | 2022-04-29 |
Family
ID=81274164
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210052775.8A Pending CN114416035A (en) | 2022-01-18 | 2022-01-18 | Data processing method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114416035A (en) |
-
2022
- 2022-01-18 CN CN202210052775.8A patent/CN114416035A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107402746B (en) | Method and device for automatically generating code file | |
CN111736840B (en) | Method for compiling applet application, method for running applet application, storage medium and electronic device | |
US20210406033A1 (en) | Method for running applets, and electronic device | |
CN113139390A (en) | Language conversion method and device applied to code character strings | |
CN113076167A (en) | Code processing method and related equipment | |
US12032941B2 (en) | Method and system for updating legacy software | |
WO2019042349A1 (en) | Translation method, mobile terminal and storage device of operating system framework | |
CN118245050B (en) | Front end frame assembly automatic conversion method, system, electronic device and storage medium | |
CN111443979B (en) | Document processing method, device, computer equipment and storage medium | |
CN114327492A (en) | Code translation method, device and equipment | |
CN116150527A (en) | Component style isolation method, device, equipment, storage medium and product | |
CN114416035A (en) | Data processing method and device, electronic equipment and storage medium | |
CN113361286B (en) | Information prompting method and device | |
CN111273913B (en) | Method and device for outputting application program interface data represented by specifications | |
CN113901025A (en) | Database management method, device, equipment and storage medium | |
CN109948251B (en) | CAD-based data processing method, device, equipment and storage medium | |
CN114089980A (en) | Programming processing method, device, interpreter and nonvolatile storage medium | |
CN113918254A (en) | Language text management method and device, storage medium and electronic equipment | |
CN113296754B (en) | Script language conversion method, editor, equipment and storage medium based on xml | |
CN115618887B (en) | Dynamic long text internationalization method, device, equipment and storage medium | |
CN116521169A (en) | Code processing method, apparatus, storage medium, and program product | |
CN113535147A (en) | Method and device for generating calling code, electronic terminal and storage medium | |
CN118504593A (en) | Translation method, translation device, electronic equipment and storage medium | |
CN114048175A (en) | Multi-language file generation method and device | |
CN115904483A (en) | Interface document generation method and device, medium and computer equipment |
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 |