CN117708385A - Operation method and device of resource character string and electronic equipment - Google Patents

Operation method and device of resource character string and electronic equipment Download PDF

Info

Publication number
CN117708385A
CN117708385A CN202311788427.8A CN202311788427A CN117708385A CN 117708385 A CN117708385 A CN 117708385A CN 202311788427 A CN202311788427 A CN 202311788427A CN 117708385 A CN117708385 A CN 117708385A
Authority
CN
China
Prior art keywords
resource
character string
key value
string
file
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
CN202311788427.8A
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.)
Hillstone Networks Co Ltd
Original Assignee
Hillstone Networks 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 Hillstone Networks Co Ltd filed Critical Hillstone Networks Co Ltd
Priority to CN202311788427.8A priority Critical patent/CN117708385A/en
Publication of CN117708385A publication Critical patent/CN117708385A/en
Pending legal-status Critical Current

Links

Abstract

The application discloses an operation method and device of a resource character string and electronic equipment, wherein the method is applied to the field of code programming and comprises the following steps: receiving a query instruction of a resource character string aiming at a target item; responding to a query instruction, and querying in a resource character string object set pre-constructed for a target item to obtain at least one first resource character string object; and displaying the character string identification or the code text of at least one first resource character string object on a preset interface. According to the method and the device, the problems that in the related technology, a plurality of resource character strings with the same semantic meaning for the resource strings are solved, as different contexts can generate a plurality of translation results, when the resource character strings corresponding to codes are operated in project files, the resource character strings need to be switched back and forth between the resource character string files and the project files, more time is spent, and the working efficiency of developers is reduced are solved.

Description

Operation method and device of resource character string and electronic equipment
Technical Field
The present invention relates to the field of code programming, and in particular, to a method and an apparatus for operating a resource string, and an electronic device.
Background
In designing the functions and codes of an application program, in order to adapt the codes to the running requirements of different areas and avoid more changes to the codes (changing the range includes but is not limited to language, culture, writing habit, products and other information), the internationalization processing needs to be carried out on the codes of the application program.
The main internationalization scheme is independent language configuration files, namely resource character string files, of language feature configuration codes for different regions. The content of the resource string file usually adopts a mode of key value pairs, keys are unique identifiers of the resource strings, values are text of interpretation codes, and the text of the interpretation codes is determined by a configured region. The documents with the same semantics have the same key (namely the unique identifier of the resource character string) in different resource character string files, and the unique identifiers of the resource character strings corresponding to the documents with different semantics are unique in the same language environment.
In the project development, under some complex scenarios, due to different business requirements and contexts, the situation that resource strings have the same semantic meaning, but are translated differently, may occur, and in this case, multiple resource strings may be generated. If a developer wants to check a plurality of resource character strings with the same Chinese meaning, the developer needs to switch back and forth between the resource character string file and the project file, so that more time is spent, and the working efficiency of the developer is reduced.
For a plurality of resource character strings with the same semantic meaning for the resource strings in the related technology, as various translation results can be generated by different contexts, when the resource character strings corresponding to codes are operated in the project file, the resource character string files and the project file need to be switched back and forth, more time is spent, and the working efficiency of developers is reduced.
Disclosure of Invention
The main purpose of the present application is to provide a method, an apparatus, and an electronic device for operating a resource string, so as to solve the problem that in the related art, for a plurality of resource strings with the same semantic meaning of the resource string, as different contexts can generate a plurality of translation results, when the resource string corresponding to a code is operated in a project file, the resource string file and the project file need to be switched back and forth, which takes more time, and reduces the working efficiency of a developer.
To achieve the above object, according to one aspect of the present application, there is provided a method of operating a resource string, the method including: receiving a query instruction of a resource character string aiming at a target item; responding to the query instruction, and querying in a resource character string object set pre-constructed for the target item to obtain at least one first resource character string object, wherein the resource character string object set comprises a plurality of resource character string objects, and code text of different resource character strings corresponding to the same code semantic information under different language types is different; and displaying the character string identification or the code text of at least one first resource character string object on a preset interface.
Further, the query instruction comprises code semantic information of a resource character string; after displaying the character string identifier or the code text of at least one of the first resource character string objects on a preset interface, the method further comprises: receiving a replacement instruction aiming at least one character string identifier on the preset interface; and replacing the code semantic information in the query instruction with the target character string identifier acted by the replacement instruction.
Further, before displaying the character string identifier or the code text of at least one of the first resource character string objects on the preset interface, the method further includes: identifying a file containing the resource character string from the files contained in the target item to obtain a target resource character string file; analyzing the resource string key value pairs in the target resource string file to obtain a first resource string key value pair set, wherein the resource string key value pairs at least comprise: character string identification and code document; dividing the first resource character string key value pair set into at least one second resource character string key value pair set according to the language type of the resource character string key value pair, and determining the language type of each second resource character string key value pair set; dividing each second resource string key value pair set into at least one third resource string key value pair set according to the file to which the resource string key value pair belongs, and determining a file path corresponding to each third resource string key value pair set; and respectively determining the resource character string key value pairs in the third resource character string key value pair set corresponding to each file path as resource character string objects to obtain the resource character string object set.
Further, querying in a resource string object set pre-constructed for the target item, to obtain at least one first resource string object includes: when the query instruction contains the character string identifier, traversing resource character string key value pairs contained in each third resource character string key value pair set in each second resource character string key value pair set in turn until a third resource character string key value pair set containing the character string identifier is determined; determining a file path corresponding to a third resource character string key value pair set containing the character string identifier, and obtaining at least one first file path; traversing the file corresponding to the at least one first file path, and determining the resource character string corresponding to the character string identifier to obtain the at least one first resource character string.
Further, querying in a resource string object set pre-constructed for the target item, to obtain at least one first resource string object includes: when the query instruction contains the code semantic information, determining a target language type of the code semantic information; determining a second resource character string key value pair set corresponding to the target language type to obtain a target second resource character string key value pair set; traversing the resource character string key value pairs in the target second resource character string key value pair set until the resource character string key value pairs corresponding to the code semantic information are determined, and obtaining at least one first resource character string key value pair; determining a file path corresponding to the at least one first resource string key value pair to obtain at least one second file path, traversing a file corresponding to the at least one second file path, and determining a resource string corresponding to the code semantic information to obtain the at least one first resource string.
Further, analyzing the target resource string file, determining a second resource string key value pair set corresponding to the target language type, and obtaining the target second resource string key value pair set includes: determining character string identifiers of the resource character strings in the resource character string object set to obtain a character string identifier set; determining a second resource character string key value pair set corresponding to a first preset language under the condition that the target language type does not belong to the first preset language, and obtaining the target second resource character string key value pair set, wherein the first preset language refers to English; determining the at least one first resource character string according to the character string identifier corresponding to the code semantic information under the condition that the target language type belongs to the first preset language and the character string identifier set contains the code semantic information; and under the condition that the target language type belongs to the first preset language and the character string identification set does not contain the code semantic information, determining a second resource character string key value pair set corresponding to the first preset language to obtain the target second resource character string key value pair set.
Further, analyzing the resource string key value pairs in the target resource string file, and obtaining the first resource string key value pair set includes: analyzing each line of data of the target resource character string file to obtain a data line which does not contain a preset character string, and obtaining a data line set, wherein the preset character string represents a character string irrelevant to the resource character string; writing each row of data in the data row set into a file to obtain a first file; and separating the character string identifier from the code file corresponding to the character string identifier in each line of data of the first file to obtain the resource character string key value pair set.
Further, before receiving the replacement instruction for at least one character string identifier on the preset interface, the method further includes: under the condition that a target object triggers a preset triggering condition, determining the project name of a running project in target equipment to obtain a project name set; acquiring a file path of a current processed file to obtain a third file path; determining the project names contained in the third file path according to the project names in the project name set to obtain target project names; and determining the target item according to the target item name, and triggering a replacement instruction aiming at least one character string identifier on the preset interface.
In order to achieve the above object, according to another aspect of the present application, there is provided an operation device for a resource string, the device comprising: the first receiving unit is used for receiving a query instruction of a resource character string aiming at a target item; the query unit is used for responding to the query instruction, querying in a resource character string object set pre-constructed for the target item to obtain at least one first resource character string object, wherein the resource character string object set comprises a plurality of resource character string objects, and code text cases of different resource character strings corresponding to the same code semantic information under different language types are different; and the display unit is used for displaying the character string identification or the code text of at least one first resource character string object on a preset interface.
Further, the query instruction comprises code semantic information of a resource character string; the apparatus further comprises: the second receiving unit is used for receiving a replacement instruction aiming at least one character string identifier on a preset interface after the character string identifier or the code file of at least one first resource character string object is displayed on the preset interface; and the replacing unit is used for replacing the code semantic information in the query instruction with the target character string identifier acted by the replacing instruction.
Further, the apparatus further comprises: the identification unit is used for identifying a file containing the resource character string from the files contained in the target item before the character string identification or the code file of at least one first resource character string object is displayed on a preset interface, so as to obtain a target resource character string file; the analyzing unit is configured to analyze the resource string key value pairs in the target resource string file, and obtain a first resource string key value pair set, where the resource string key value pairs at least include: character string identification and code document; the first dividing unit is used for dividing the first resource character string key value pair set into at least one second resource character string key value pair set according to the language type of the resource character string key value pair, and determining the language type of each second resource character string key value pair set; the second dividing unit is used for dividing each second resource character string key value pair set into at least one third resource character string key value pair set according to the file to which the resource character string key value pair belongs, and determining a file path corresponding to each third resource character string key value pair set; and the first determining unit is used for respectively determining the resource character string key value pairs in the third resource character string key value pair set corresponding to each file path as resource character string objects to obtain the resource character string object set.
Further, the query unit includes: the first determining subunit is configured to, when the query instruction includes the string identifier, sequentially traverse resource string key value pairs included in each third resource string key value pair set in each second resource string key value pair set until determining a third resource string key value pair set including the string identifier; a second determining subunit, configured to determine a file path corresponding to the third resource string key value pair set that includes the string identifier, to obtain at least one first file path; and the third determining subunit is used for traversing the file corresponding to the at least one first file path, determining the resource character string corresponding to the character string identifier and obtaining the at least one first resource character string.
Further, the query unit further includes: a fourth determining subunit, configured to determine, when the query instruction includes the code semantic information, a target language type of the code semantic information; a fifth determining subunit, configured to determine a second resource string key value pair set corresponding to the target language type, to obtain a target second resource string key value pair set; a sixth determining subunit, configured to traverse the resource string key value pairs in the target second resource string key value pair set until determining the resource string key value pair corresponding to the code semantic information, to obtain at least one first resource string key value pair; a seventh determining subunit, configured to determine a file path corresponding to the at least one first resource string key pair, obtain at least one second file path, traverse a file corresponding to the at least one second file path, determine a resource string corresponding to the code semantic information, and obtain the at least one first resource string.
Further, the fifth determining subunit includes: the first determining module is used for determining character string identifiers of the resource character strings in the resource character string object set to obtain a character string identifier set; the second determining module is configured to determine a second resource string key value pair set corresponding to a first preset language when the target language type does not belong to the first preset language, so as to obtain the target second resource string key value pair set, where the first preset language refers to english; a third determining module, configured to determine, when the target language type belongs to the first preset language and the string identifier set includes the code semantic information, the at least one first resource string according to a string identifier corresponding to the code semantic information; a fourth determining module, configured to determine a second resource string key value pair set corresponding to the first preset language, to obtain the target second resource string key value pair set, where the target language type belongs to the first preset language, and the string identification set does not include the code semantic information.
Further, the parsing unit includes: the acquisition subunit is used for analyzing each line of data of the target resource character string file, acquiring data lines which do not contain preset character strings, and obtaining a data line set, wherein the preset character strings represent character strings irrelevant to the resource character strings; a writing subunit, configured to write each row of data in the data row set into a file, to obtain a first file; and the separation subunit is used for separating the character string identifier in each row of data of the first file from the code file corresponding to the character string identifier to obtain the resource character string key value pair set.
Further, the apparatus further comprises: the second determining unit is used for determining the project names of running projects in the target equipment to obtain a project name set under the condition that the target object triggers a preset trigger condition before receiving a replacement instruction aiming at least one character string identifier on the preset interface; the acquisition unit is used for acquiring a file path of the current processed file to obtain a third file path; a third determining unit, configured to determine, according to the item names in the item name set, item names included in the third file path, and obtain a target item name; and the triggering unit is used for determining the target item according to the name of the target item and triggering a replacement instruction aiming at least one character string identifier on the preset interface.
In order to achieve the above object, according to one aspect of the present application, there is provided a computer readable storage medium, including a stored computer program, where the computer program when executed controls a device in which the computer readable storage medium is located to perform the method for operating the resource string according to any one of the above.
To achieve the above object, according to one aspect of the present application, there is provided an electronic device including one or more processors and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method for operating a resource string according to any one of the above.
Through the application, the following steps are adopted: receiving a query instruction of a resource character string aiming at a target item; responding to the query instruction, and querying in a resource character string object set pre-constructed for the target item to obtain at least one first resource character string object, wherein the resource character string object set comprises a plurality of resource character string objects, and code text of different resource character strings corresponding to the same code semantic information under different language types is different; the character string identification or the code text of at least one first resource character string object is displayed on a preset interface, and a plurality of resource character strings with the same semantic meaning of the resource string can be accurately positioned in a file contained in a target item according to target resource character string information in a resource character string replacement instruction by constructing a resource character string object set corresponding to the target item, so that the problem that a plurality of resource character strings with the same semantic meaning of the resource string in the related art can be solved, and as a plurality of translation results can be generated in different contexts, when the resource character strings corresponding to codes are operated in the item file, the resource character string files and the item files need to be switched back and forth, more time is spent, and the working efficiency of developers is reduced.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application, illustrate and explain the application and are not to be construed as limiting the application. In the drawings:
FIG. 1 is a flow chart of a method of operation of a resource string provided in accordance with an embodiment of the present application;
FIG. 2 is a schematic diagram I of an alternative method of operation of resource strings according to the first embodiment of the present application;
FIG. 3 is a second schematic diagram of an alternative method of operation of resource strings according to the first embodiment of the present application;
FIG. 4 is a third schematic diagram of an alternative method of operation of a resource string according to the first embodiment of the present application;
FIG. 5 is a schematic diagram IV of an alternative method of operation of resource strings according to the first embodiment of the present application;
FIG. 6 is a schematic diagram five of an alternative method of operation of resource strings according to the first embodiment of the present application;
FIG. 7 is a diagram six of an alternative method of operation of resource strings according to the first embodiment of the present application;
FIG. 8 is a schematic diagram of an operation device of a resource string according to a second embodiment of the present application;
fig. 9 is a schematic diagram of an electronic device for operating a resource string according to a fifth embodiment of the present application.
Detailed Description
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
It should be noted that, the user information (including, but not limited to, user equipment information, user personal information, information contained in the code, etc.) and the data (including, but not limited to, data used for analysis, stored data, displayed data, data contained in the code, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the relevant data need to comply with relevant laws and regulations and standards of the relevant area, and are provided with corresponding operation entries for the user to select authorization or rejection.
In order to make the present application solution better understood by those skilled in the art, the following description will be made in detail and with reference to the accompanying drawings in the embodiments of the present application, it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe the embodiments of the present application described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In the project development, under some complex scenarios, due to different business requirements and contexts, the situation that the meaning of the resource strings is the same, but the translation is not the same may occur, and in this case, multiple resource strings may be generated. If a developer wants to check a plurality of resource character strings with the same Chinese meaning, the developer needs to switch back and forth between the resource character string file and the project file, so that more time is spent, and the working efficiency of the developer is reduced.
In addition, when the unique identifier defining the resource string is applied to the file contained in the project, the unique identifier can be obtained by using the following method: and storing the information of the resource character string in a mode of 'unique identification' of the resource character string, traversing the file content by utilizing a parser, and replacing by using the resource character string file when detecting that the Chinese is identical with the unique identification of the resource character string. However, this method is only suitable for the front-end project built based on VueJS (Vue JavaScript), and the developer cannot flexibly select the resource character string to be replaced. In addition, under some complex scenes, because of different service requirements or contexts, the same Chinese meaning of the resource character strings can appear, but the translations are not the same, so that a plurality of resource character strings are generated, if the resource character strings consistent with Chinese are found by the method, the resource character strings are replaced immediately, other resource character strings needing to be replaced are omitted, and the problem of lower accuracy of the replacement of the resource character strings is caused. In addition, the method requires that the storage positions of the resource character string files are required to be in the same catalog, and if the resource character strings are distributed in different catalogues, paths are required to be manually set, so that the operation is complicated.
Example 1
The present invention will be described with reference to preferred implementation steps, and fig. 1 is a flowchart of a method for operating a resource string according to an embodiment of the present application, and as shown in fig. 1, the method includes the following steps:
step S101, receiving a query instruction of a resource string for a target item.
In the first embodiment, the target item refers to a code item handled when a developer develops an application program, and is typically composed of a code file and various resource files (e.g., pictures, texts, videos, etc.). Code items may use resource strings to reference code documents of different language types in order to display correct text content in different language environments. The code text refers to a text string actually presented in the code item.
Here, the query instruction is customized by the user, and in this embodiment, the query instruction may be replaced by: keywords or function interfaces, etc.
In order to enable application programs developed by enterprises to meet the requirements of different areas, resource character strings are required to be configured for code files in the code items when the code items corresponding to the application programs are designed, and developers can inquire the positions of each resource character string in the code items through inquiry instructions, so that the code files in the code items are favorably adjusted to other language types, and further development requirements of code developers in other areas are met.
Step S102, responding to a query instruction, and querying in a resource character string object set pre-constructed for a target item to obtain at least one first resource character string object, wherein the resource character string object set comprises a plurality of resource character string objects, and code text of different resource character strings corresponding to the same code semantic information under different language types is different.
In the first embodiment, in order to obtain the resource string queried by the developer, the corresponding resource string is queried from the pre-constructed resource string object set, so as to obtain the at least one first resource string object. The resource character string object comprises character string identifiers and code text, wherein the character string identifiers refer to identifiers corresponding to the code text of the same code semantic information in different language types, and the code text refers to text character strings actually displayed in code items. The query instruction at least comprises one of the following: the code semantic information refers to the same semantic information corresponding to the character string identification of the resource character string in different language types, and the code semantic information of the resource character string may be the same as the code text corresponding to the resource character string.
Step S103, displaying the character string identification or the code text of at least one first resource character string object on a preset interface.
In the first embodiment, after the character string identifier or the code document of the at least one first resource character string object is queried, the character string identifier or the code document of the at least one first resource character string object may be displayed in a preset interface, so that a developer can know relevant information of the resource character string in the preset interface.
In an optional embodiment, the developer may edit the query instruction to "intl.get (" account ")", query the first resource string object corresponding to the code semantic information "account", and display the string identifier of the first resource string object appearing in the target item in the preset interface. The preset interface for displaying the string identifier of the first resource string object in the target item may be shown in fig. 2, where the preset interface may be a floating window, "common_account", "system_account" and "terminal_account" are the string identifiers corresponding to the code semantic information "account", and "d: the workplace name \Path 1\local\zh_CN.ts "is the file path where the string identification" common_account "is located," d: the workplace name \Path 2\1ocal\zh_CN.ts "is the file path where the string identification" system_account "is located," d: the workplace name \Path 3\local\zh_CN.ts "is the file path where the string identification" terminal_account "is located.
In an alternative embodiment, the developer may edit the query instruction to "intel_delete", query the code text corresponding to the string identifier "common_delete", and display the code text corresponding to the string identifier "common_delete" in the target item in the preset interface. The preset interface for displaying the code documents of different language types of the character string identifier in the target item may be shown in fig. 3, where "chinese: delete "is a chinese code case," english: delete "is an english code document.
In summary, in the method for operating a resource string according to the first embodiment of the present application, a query instruction for a resource string of a target item is received; responding to a query instruction, and querying in a resource character string object set pre-constructed for a target item to obtain at least one first resource character string object, wherein the resource character string object set comprises a plurality of resource character string objects, and code text of different resource character strings corresponding to the same code semantic information under different language types is different; the character string identification or the code text of at least one first resource character string object is displayed on a preset interface, so that a developer can more conveniently and intuitively check the resource character string, global searching is not needed, the developer can be helped to determine whether the newly added semantic text is defined or not, and the problems that a plurality of resource character strings with the same semantic meaning as the resource string in the related art are solved, and as a plurality of translation results can be generated by different contexts, when the resource character string corresponding to the code is operated in a project file, the resource character string file and the project file need to be switched back and forth, more time is spent, and the working efficiency of the developer is reduced are solved.
Optionally, in the method for operating a resource string provided in the first embodiment of the present application, the query instruction includes code semantic information of the resource string; after displaying the character string identifier or the code text of the at least one first resource character string object on the preset interface, the method further comprises: receiving a replacement instruction aiming at least one character string identifier on a preset interface; and replacing the code semantic information in the query instruction with the target character string identifier acted by the replacement instruction.
In the first embodiment, in order to improve the efficiency of processing the resource character string by the developer, the code semantic information in the query instruction can be directly replaced by the character string identifier corresponding to the code semantic information, the code text corresponding to the character string identifier in different language types is queried, and the code text corresponding to the different language types is displayed to the developer, so that the effect of quickly evaluating the code text is achieved, the efficiency of processing the resource character string by the developer is improved, the accuracy of the resource character string and the code text is ensured, and the accuracy of the target item is further ensured. In addition, the code semantic information is replaced by the target character string identifier acted by the replacement instruction, so that the resource character string is replaced rapidly, the back and forth switching between the resource string file and the project file in development is avoided, the development efficiency is improved, and the effect of improving the accuracy of the replacement of the resource character string is achieved.
In an alternative embodiment, the developer may edit the query instruction to "intl.get (" account ")", query the first resource string object corresponding to the code semantic information "account"), locate, through a preset interface (for example, an extension interface getWordRangeAtPosition) and a regular expression, a starting range of a string identifier of the first resource string object to be replaced in the code item, and display the string identifier to be replaced in the preset interface. The preset interface for displaying the character string identification to be replaced may be as shown in fig. 2. Then, the developer can click on the character string identifier in the preset interface to replace the code semantic information in the query instruction with the clicked character string identifier. And finally, displaying the code file marked by the replaced character string in a preset interface so as to enable a reviewer to review the code file.
Optionally, in the method for operating a resource string according to the first embodiment of the present application, before displaying the string identifier or the code document of the at least one first resource string object on the preset interface, the method further includes: identifying a file containing the resource character string in the file contained in the target item to obtain a target resource character string file; analyzing the resource character string key value pairs in the target resource character string file to obtain a first resource character string key value pair set, wherein the resource character string key value pairs at least comprise: character string identification and code document; dividing the first resource character string key value pair set into at least one second resource character string key value pair set according to the language type of the resource character string key value pair, and determining the language type of each second resource character string key value pair set; dividing each second resource character string key value pair set into at least one third resource character string key value pair set according to the file to which the resource character string key value pair belongs, and determining a file path corresponding to each third resource character string key value pair set; and respectively determining the resource character string key value pairs in the third resource character string key value pair set corresponding to each file path as resource character string objects to obtain a resource character string object set.
In the first embodiment, in order to more comprehensively and accurately manage the resource strings in the target item, a three-layer mapping (Map) structure may be used to store the resource strings, so as to obtain the resource string object set.
Specifically, as shown in fig. 4, the storage structure of the resource string object set may be that the first Map structure is a resource string object set, in which the resource string key value pairs corresponding to different language types in the whole target item, that is, the second resource string key value pair set (such as the file object in fig. 4), are stored, at least one key value pair stored in the resource string object set is that a key is a language type, and a value is the second resource string key value pair set; the second Map structure is a file object set, wherein the resource string key value pairs contained in different files under the same language type, namely a third resource string key value pair set, and a file path (such as a file A path in fig. 4) corresponding to each third resource string key value pair set are stored, at least one key value pair stored in the file object set is a file absolute path, and the value is the third resource string key value pair set; the third Map structure is a set of resource string key value pairs, where each resource string key value pair included in the set of third resource string key value pairs is stored, the key in the resource string key value pair is a unique identifier of the resource string (e.g., the string identifier A1 in fig. 4, i.e., the above-mentioned string identifier), and the value is a resource string value (e.g., the above-mentioned code document).
Note that the file path mentioned in the first embodiment may be an absolute file path or a relative file path, which is not specifically limited in the first embodiment.
In an alternative embodiment, the set of resource string objects may be characterized using json (JavaScript Object Notation) strings, the json string may be as follows: { zh_cn: { chinese File 1 Path: { Common_account_1: account number } chinese file 2 path: { Common_account_2: account number, common_password_2: cipher }, en_us: { English File 1 Path: { Common_account_3: account number } english file 2 path: { Common_account_4: account number }, wherein, "zh_cn" represents chinese, "common_account_2" is a string identifier, "account number" is a code document corresponding to the string identifier, and "en_us" represents english.
The three-layer Map structure is adopted to represent the resource character strings contained in the target item, so that the resource character strings can be divided into objects with smaller granularity according to the language types and the absolute paths of the files, the inquired resource character string objects can be directly indexed, the effect of improving the inquiring efficiency of the resource character strings is achieved, meanwhile, when the resource character string files are updated or deleted, the file object monitor can timely capture that the resource character string files are changed, the absolute paths of the changed resource character string files are obtained, the modified file names and the language types corresponding to the modified file names (for example, through file name or directory extraction) can be extracted according to the absolute paths of the files, and further the related information of the modified resource character strings can be updated in an object set directly through the modified file names and the language types corresponding to the file names, and the timeliness of the resource character string object set is guaranteed.
Optionally, in the method for operating a resource string provided in the first embodiment of the present application, querying a resource string object set pre-configured for a target item to obtain at least one first resource string object includes: when the query instruction contains the character string identifier, traversing the resource character string key value pairs contained in each third resource character string key value pair set in each second resource character string key value pair set in turn until the third resource character string key value pair set containing the character string identifier is determined; determining a file path corresponding to a third resource character string key value pair set containing character string identifiers, and obtaining at least one first file path; traversing the file corresponding to the at least one first file path, and determining the resource character string corresponding to the character string identifier to obtain at least one first resource character string.
In the first embodiment, when the query instruction includes a string identifier, first, traversing from a third resource string key value pair set included in each second resource string key value pair set (e.g., a file object corresponding to chinese and a file object corresponding to english in fig. 4) until the third resource string key value pair set including the string identifier is determined, and determining at least one first file path corresponding to the third resource string key value pair set including the string identifier, so as to traverse a file corresponding to the at least one first file path, and determine a resource string corresponding to the string identifier in the file, thereby obtaining at least one first resource string.
By starting traversing from each second resource string key value pair set, stopping traversing the second resource string key value pair set when determining the resource string key value pair corresponding to the queried string identification in each language type, and then starting traversing from the next second resource string key value pair set, the effect that the resource string key value pair corresponding to the string identification in different language types can be obtained without traversing the resource string key value pair contained in the whole target item is achieved, and the effect of improving the efficiency of positioning the resource string to be replaced is achieved.
Optionally, in the method for operating a resource string provided in the first embodiment of the present application, querying a resource string object set pre-configured for a target item to obtain at least one first resource string object includes: when the query instruction contains code semantic information, determining a target language type of the code semantic information; determining a second resource character string key value pair set corresponding to the target language type to obtain a target second resource character string key value pair set; traversing the resource character string key value pairs in the target second resource character string key value pair set until the resource character string key value pairs corresponding to the code semantic information are determined, and obtaining at least one first resource character string key value pair; determining a file path corresponding to at least one first resource character string key value pair to obtain at least one second file path, traversing a file corresponding to the at least one second file path, and determining a resource character string corresponding to code semantic information to obtain at least one first resource character string.
In the first embodiment, when the query instruction includes code semantic information, the language type (i.e., the target language type) corresponding to the code semantic information can be determined by means of the existing third party language recognition library (for example, the langdetect language recognition library, the polyglot library, and the cld3 library based on n-grams), and then the resource string object in the object set can be traversed according to the target language type. It should be noted that the code semantic information in the query instruction may be the same as the code document of the resource string.
Specifically, a target second resource character string key value pair set is obtained from a resource character string object set according to a second resource character string key value pair set corresponding to a target language type; traversing the resource character string key value pairs contained in the target second resource character string key value pair set according to the code semantic information in the query instruction until at least one resource character string key value pair (namely the first resource character string key value pair) corresponding to the code semantic information is determined; and finally, determining a corresponding file absolute path in a third resource character string key value pair set according to at least one first resource character string key value pair to obtain at least one second file path, traversing project files contained in the target project, and positioning the first resource character string according to code semantic information in the query instruction to obtain at least one first resource character string.
By determining the language type of the code semantic information in the query instruction, the target second resource character string key value pair set corresponding to the code semantic information can be searched in the second resource character string key value pair set according to the language type, so that the resource character string key value pair corresponding to the code semantic information is searched in the target second resource character string key value pair set, and at least one first resource character string is positioned in the project file, and the effect of improving the efficiency of positioning the resource character string to be queried is achieved.
Optionally, in the method for operating a resource string provided in the first embodiment of the present application, determining a second set of resource string key value pairs corresponding to a target language type, where obtaining the target second set of resource string key value pairs includes: determining character string identifiers of the resource character strings in the resource character string object set to obtain a character string identifier set; under the condition that the target language type does not belong to a first preset language, determining a second resource character string key value pair set corresponding to the first preset language to obtain a target second resource character string key value pair set, wherein the first preset language refers to English; determining at least one first resource character string according to the character string identification corresponding to the code semantic information under the condition that the target language type belongs to a first preset language and the character string identification set contains the code semantic information; and under the condition that the target language type belongs to a first preset language and the character string identification set does not contain code semantic information, determining a second resource character string key value pair set corresponding to the first preset language to obtain a target second resource character string key value pair set.
In the first embodiment, since each line of code in the code file is generally composed of english characters, when the target language type belongs to english, it is necessary to determine whether the code semantic information in the query instruction is actually a character string identifier or a code document.
Specifically, when the code semantic information in the query instruction belongs to english, and the resource string corresponding to the code semantic information needs to be located in the target item, all the string identifications in the resource string object set corresponding to the target item may be stored in the string identification set in advance. When the code semantic information is determined to be English, judging whether the code semantic information is contained in the character string identification set or not: if the character string identification set contains the code semantic information, the code semantic information is a character string identification, and at least one first file path corresponding to the character string identification can be determined in the resource character string object set directly according to the character string identification, so that at least one first resource character string is determined in the project file according to the at least one first file path; if the character string identification set does not contain the code semantic information, the code semantic information is really a code document, and the second resource character string key value pair set corresponding to English in the resource character string object set can be determined as a target second resource character string key value pair set.
By acquiring the character string identification set, whether the code semantic information in the query instruction is the character string identification or the code text can be judged according to the character string identification set, so that the first resource character string to be queried can be accurately positioned in the project file according to the target resource character string information, the problem that the character string identification is misjudged to be the code text and the wrong first resource character string is positioned is avoided, and the effect of improving the accuracy of the query resource character string is achieved.
Optionally, in the method for operating a resource string provided in the first embodiment of the present application, analyzing a resource string key pair in a target resource string file, the obtaining a first set of resource string key pairs includes: analyzing each line of data of the target resource character string file to obtain a data line which does not contain a preset character string, and obtaining a data line set, wherein the preset character string represents a character string irrelevant to the resource character string; writing each row of data in the data row set into a file to obtain a first file; and separating the character string identifier in each row of data of the first file from the code file corresponding to the character string identifier to obtain a resource character string key value pair set.
In the first embodiment, in order to extract the resource string from the target resource string file, the target resource string file needs to be parsed.
In an alternative embodiment, the target resource string file may be processed row by row, which specifically includes the following steps:
step S701, reading the data reading content of the 1 st row to obtain a target character string;
step S702, if the target string includes a string unrelated to the resource string (i.e., the above-mentioned preset string), step S703 is performed, where the preset string may be a string such as "import", "=", space character, line feed character, etc. commonly found in the code program; if the target character string does not contain the preset character string, temporarily storing the target character string in the data line set, and executing step S703;
step S703, reading the next line of data, taking the next line of data as the target string, and jumping to step S702 until each line of data of the target resource string file is traversed.
Step S704, writing each row of data in the data row set into the first file, using: and separating the character string identifier of each row of data in the first file from the code file (namely the preset characters) to obtain resource character string key value pairs corresponding to each row of data, thereby obtaining a resource character string key value pair set.
By analyzing the target resource character string file line by line, all resource character strings can be extracted from the target resource character string file, so that the resource character strings are managed and maintained, and the problem that the resource character strings can only be stored in the same file is avoided.
In the first embodiment, in order to ensure timeliness of the resource string object set, it is necessary to monitor the change of the resource string file in the target item, and update the resource string object set in time after the resource string file is changed. After determining the set of resource string objects for the target item, the method further comprises: under the condition that a preset processing instruction aiming at the target resource string file is received, acquiring a file path of the processed target resource string file to obtain a target file path, wherein the preset processing instruction at least comprises one of the following processes: adding, updating and deleting; and reading the processed target resource string file according to the target file path, and updating the data in the resource string object set of the target item according to the processed target resource string file.
Specifically, a file object monitor may be created by code editing software, through which changes to resource string files are monitored. When the resource string information (i.e., the unique identifier of the resource string or the code file) in the target resource string file is changed (e.g., added, modified or deleted, i.e., the above-mentioned preset processing instruction), the file object monitor returns the file path of the target resource string file (i.e., the above-mentioned target file path), then locates the target resource string file according to the target file path, analyzes the resource string contained in the target resource string file, and updates the resource string information in the resource string object set corresponding to the target item according to the resource string currently contained in the target resource string file.
By creating the file object monitor, whether the target resource character string file changes or not can be timely found, so that the resource character string information in the resource character string object set corresponding to the target item is timely updated, the accuracy of the resource character string object set is improved, the timeliness of the resource character string object set is ensured, the effect of improving the accuracy of locating the resource character string is achieved, and the effect of improving the accuracy of replacing the resource character string is further achieved.
Optionally, in the method for operating a resource string according to the first embodiment of the present application, before receiving a replacement instruction for at least one string identifier on a preset interface, the method further includes: under the condition that a target object triggers a preset triggering condition, determining the project name of a running project in target equipment to obtain a project name set; acquiring a file path of a current processed file to obtain a third file path; determining the project names contained in the third file path according to the project names in the project name set to obtain target project names; and determining a target item according to the name of the target item, and triggering a replacement instruction aiming at least one character string identifier on a preset interface.
In an alternative embodiment, the preset trigger condition may be that the executable link is clicked. The process of triggering the resource string replacement instruction according to the scheme can be as shown in fig. 5, the replacement function can be registered as a built-in command of the code editing software, the command is represented by an executable link mode, then a floating frame is created at the position where the developer (namely the target object) hovers with a mouse, the executable link is inserted into the floating frame, and the target object can trigger the resource string replacement instruction by clicking the executable link mode.
In the first embodiment, when the target object triggers the preset trigger condition, the item processed by the target object (i.e. the target item described above) may be determined according to the file currently processed by the target object, so as to trigger the resource string replacement instruction for the target item.
Specifically, when the target object opens the item or switches the item, all the item names are stored in the item name set, and when the target object clicks the executable link, the file path of the current processing file of the target object (i.e. the third file path) is divided into a character string array, and the item names contained in the character string array are determined according to the item names in the item name set, so as to determine the item name of the target item.
When the target object triggers the preset triggering condition each time, the detection is only carried out from the object set corresponding to the item where the current processing file of the target object is located, so that the effect of isolating the item is realized.
By configuring preset trigger conditions and determining the current processed item of the target object, the item where the resource character string which is intended to be replaced by the target object is located can be accurately positioned, and the effect of improving the accuracy of replacing the resource character string is achieved.
Optionally, in the first embodiment, the present solution may be applied to a resource string query device, where the resource string query device includes four modules: the system comprises a data preprocessing module, an object set construction module, a detection module and a monitoring module. The interaction process among the data preprocessing module, the object set construction module and the monitoring module in the scheme can be as shown in fig. 6, the data preprocessing module is responsible for traversing the project catalog when the project is initialized, identifying the resource character string file in the target file, and carrying out traversing analysis on the content of the resource character string file to obtain the resource character string key value pair. The resource character string object set construction module is responsible for converting the acquired resource character string key value pairs into a resource character string object set and constructing a character string identification set. The monitoring module comprises a work area (namely the project) monitor and a file monitor, and is responsible for monitoring the change of the current processing project and the file, and dynamically updating the character string identification set and the resource character string object set. The execution flow included in the detection module may be as shown in fig. 7. The detection module is triggered according to a preset triggering condition and is responsible for searching relevant information of detection content from the resource character string object set.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
Example two
The second embodiment of the present application further provides an operation device for a resource string, and it should be noted that the operation device for a resource string in the second embodiment of the present application may be used to execute the operation method for a resource string provided in the first embodiment of the present application. The following describes an operation device for resource strings provided in the second embodiment of the present application.
Fig. 8 is a schematic diagram of an operation device of a resource string according to a second embodiment of the present application. As shown in fig. 8, the apparatus includes: a first receiving unit 801, a querying unit 802, and a display unit 803.
Specifically, the first receiving unit 801 is configured to receive a query instruction of a resource string for a target item.
The query unit 802 is configured to query, in response to a query instruction, a resource string object set pre-configured for a target item to obtain at least one first resource string object, where the resource string object set includes a plurality of resource string objects, and code documents of different resource strings corresponding to the same code semantic information under different language types are different.
And a display unit 803, configured to display a character string identifier or a code document of at least one first resource character string object on a preset interface.
In the operation device for resource strings provided in the second embodiment of the present application, a first receiving unit 801 receives a query instruction for a resource string of a target item; the query unit 802 responds to a query instruction, queries in a resource string object set pre-constructed for a target item to obtain at least one first resource string object, wherein the resource string object set comprises a plurality of resource string objects, and code text of different resource strings corresponding to the same code semantic information under different language types is different; the display unit 803 displays the character string identifier or the code text of at least one first resource character string object on a preset interface, so that a developer can more conveniently and intuitively check the resource character string, global searching is not needed, the developer can be helped to determine whether the newly added semantic text is defined or not, and the problems that a plurality of resource character strings with the same semantic meaning as the resource string in the related art can be solved, and as a plurality of translation results can be generated by different contexts, when the resource character string corresponding to the code in the project file is operated, the resource character string file and the project file need to be switched back and forth, more time is spent, and the working efficiency of the developer is reduced are solved.
Optionally, in the operating device for resource strings provided in the second embodiment of the present application, the query instruction includes code semantic information of the resource string; the device further comprises: the second receiving unit is used for receiving a replacement instruction aiming at least one character string identifier on a preset interface after the character string identifier or the code text of at least one first resource character string object is displayed on the preset interface; and the replacing unit is used for replacing the code semantic information in the query instruction with the target character string identifier acted by the replacing instruction.
Optionally, in the operation device for resource strings provided in the second embodiment of the present application, the device further includes: the identification unit is used for identifying the file containing the resource character string in the file contained in the target item before the character string identification or the code text of at least one first resource character string object is displayed on the preset interface, so as to obtain a target resource character string file; the analyzing unit is configured to analyze the resource string key value pairs in the target resource string file, and obtain a first resource string key value pair set, where the resource string key value pairs at least include: character string identification and code document; the first dividing unit is used for dividing the first resource character string key value pair set into at least one second resource character string key value pair set according to the language type of the resource character string key value pair, and determining the language type of each second resource character string key value pair set; the second dividing unit is used for dividing each second resource character string key value pair set into at least one third resource character string key value pair set according to the file to which the resource character string key value pair belongs, and determining a file path corresponding to each third resource character string key value pair set; and the first determining unit is used for respectively determining the resource character string key value pairs in the third resource character string key value pair set corresponding to each file path as resource character string objects to obtain a resource character string object set.
Optionally, in the operation device for resource strings provided in the second embodiment of the present application, the query unit 802 includes: the first determining subunit is configured to traverse, when the query instruction includes a string identifier, the resource string key value pairs included in each third resource string key value pair set in each second resource string key value pair set in turn until a third resource string key value pair set including the string identifier is determined; a second determining subunit, configured to determine a file path corresponding to the third resource string key value pair set that includes the string identifier, to obtain at least one first file path; and the third determining subunit is used for traversing the file corresponding to the at least one first file path, determining the resource character string corresponding to the character string identifier and obtaining at least one first resource character string.
Optionally, in the operation device for resource strings provided in the second embodiment of the present application, the query unit 802 further includes: a fourth determining subunit, configured to determine, when the query instruction includes code semantic information, a target language type of the code semantic information; a fifth determining subunit, configured to determine a second resource string key value pair set corresponding to the target language type, to obtain a target second resource string key value pair set; a sixth determining subunit, configured to traverse the resource string key value pairs in the target second resource string key value pair set until the resource string key value pair corresponding to the code semantic information is determined, to obtain at least one first resource string key value pair; and a seventh determining subunit, configured to determine a file path corresponding to the at least one first resource string key pair, obtain at least one second file path, traverse a file corresponding to the at least one second file path, and determine a resource string corresponding to the code semantic information, so as to obtain at least one first resource string.
Optionally, in the operation device for resource strings provided in the second embodiment of the present application, the fifth determining subunit includes: the first determining module is used for determining character string identifiers of the resource character strings in the resource character string object set to obtain a character string identifier set; the second determining module is used for determining a second resource character string key value pair set corresponding to a first preset language under the condition that the target language type does not belong to the first preset language, so as to obtain a target second resource character string key value pair set, wherein the first preset language refers to English; the third determining module is used for determining at least one first resource character string according to the character string identifier corresponding to the code semantic information when the target language type belongs to a first preset language and the character string identifier set contains the code semantic information; and the fourth determining module is used for determining a second resource character string key value pair set corresponding to the first preset language to obtain a target second resource character string key value pair set under the condition that the target language type belongs to the first preset language and the character string identification set does not contain code semantic information.
Optionally, in the operation device for resource strings provided in the second embodiment of the present application, the parsing unit includes: the acquisition subunit is used for analyzing each line of data of the target resource character string file, acquiring data lines which do not contain preset character strings, and obtaining a data line set, wherein the preset character strings represent character strings irrelevant to the resource character strings; a writing subunit, configured to write each row of data in the data row set into a file, to obtain a first file; and the separation subunit is used for separating the character string identifier in each row of data of the first file from the code file corresponding to the character string identifier to obtain a resource character string key value pair set.
Optionally, in the operation device for resource strings provided in the second embodiment of the present application, the device further includes: the second determining unit is used for determining the project names of the running projects in the target equipment to obtain a project name set under the condition that the target object triggers a preset trigger condition before receiving a replacement instruction aiming at least one character string identifier on a preset interface; the acquisition unit is used for acquiring a file path of the current processed file to obtain a third file path; a third determining unit, configured to determine, according to the item names in the item name set, the item names included in the third file path, and obtain target item names; and the triggering unit is used for determining the target item according to the name of the target item and triggering a replacement instruction aiming at least one character string identifier on a preset interface.
The operation device of the resource string includes a processor and a memory, where the first receiving unit 801, the querying unit 802, the display unit 803, and the like are stored as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel can be provided with one or more than one, and the accuracy of replacing the resource character string is improved by adjusting the kernel parameters.
The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
A third embodiment of the present invention provides a computer-readable storage medium having stored thereon a program that, when executed by a processor, implements a method of operating a resource string.
The fourth embodiment of the invention provides a processor, which is used for running a program, wherein the program runs to execute an operation method of a resource character string.
As shown in fig. 9, a fifth embodiment of the present invention provides an electronic device, where the device includes a processor, a memory, and a program stored in the memory and executable on the processor, and the processor implements the following steps when executing the program: receiving a query instruction of a resource character string aiming at a target item; responding to a query instruction, and querying in a resource character string object set pre-constructed for a target item to obtain at least one first resource character string object, wherein the resource character string object set comprises a plurality of resource character string objects, and code text of different resource character strings corresponding to the same code semantic information under different language types is different; and displaying the character string identification or the code text of at least one first resource character string object on a preset interface.
The processor also realizes the following steps when executing the program: the inquiry instruction comprises code semantic information of a resource character string; after displaying the character string identifier or the code text of the at least one first resource character string object on the preset interface, the method further comprises: receiving a replacement instruction aiming at least one character string identifier on a preset interface; and replacing the code semantic information in the query instruction with the target character string identifier acted by the replacement instruction.
The processor also realizes the following steps when executing the program: before displaying the character string identifier or the code document of the at least one first resource character string object on the preset interface, the method further comprises: identifying a file containing the resource character string in the file contained in the target item to obtain a target resource character string file; analyzing the resource character string key value pairs in the target resource character string file to obtain a first resource character string key value pair set, wherein the resource character string key value pairs at least comprise: character string identification and code document; dividing the first resource character string key value pair set into at least one second resource character string key value pair set according to the language type of the resource character string key value pair, and determining the language type of each second resource character string key value pair set; dividing each second resource character string key value pair set into at least one third resource character string key value pair set according to the file to which the resource character string key value pair belongs, and determining a file path corresponding to each third resource character string key value pair set; and respectively determining the resource character string key value pairs in the third resource character string key value pair set corresponding to each file path as resource character string objects to obtain a resource character string object set.
The processor also realizes the following steps when executing the program: querying in a resource string object set pre-constructed for a target item to obtain at least one first resource string object, wherein the obtaining comprises the following steps: when the query instruction contains the character string identifier, traversing the resource character string key value pairs contained in each third resource character string key value pair set in each second resource character string key value pair set in turn until the third resource character string key value pair set containing the character string identifier is determined; determining a file path corresponding to a third resource character string key value pair set containing character string identifiers, and obtaining at least one first file path; traversing the file corresponding to the at least one first file path, and determining the resource character string corresponding to the character string identifier to obtain at least one first resource character string.
The processor also realizes the following steps when executing the program: querying in a resource string object set pre-constructed for a target item to obtain at least one first resource string object, wherein the obtaining comprises the following steps: when the query instruction contains code semantic information, determining a target language type of the code semantic information; determining a second resource character string key value pair set corresponding to the target language type to obtain a target second resource character string key value pair set; traversing the resource character string key value pairs in the target second resource character string key value pair set until the resource character string key value pairs corresponding to the code semantic information are determined, and obtaining at least one first resource character string key value pair; determining a file path corresponding to at least one first resource character string key value pair to obtain at least one second file path, traversing a file corresponding to the at least one second file path, and determining a resource character string corresponding to code semantic information to obtain at least one first resource character string.
The processor also realizes the following steps when executing the program: determining a second resource string key value pair set corresponding to the target language type, wherein the obtaining the target second resource string key value pair set comprises: determining character string identifiers of the resource character strings in the resource character string object set to obtain a character string identifier set; under the condition that the target language type does not belong to a first preset language, determining a second resource character string key value pair set corresponding to the first preset language to obtain a target second resource character string key value pair set, wherein the first preset language refers to English; determining at least one first resource character string according to the character string identification corresponding to the code semantic information under the condition that the target language type belongs to a first preset language and the character string identification set contains the code semantic information; and under the condition that the target language type belongs to a first preset language and the character string identification set does not contain code semantic information, determining a second resource character string key value pair set corresponding to the first preset language to obtain a target second resource character string key value pair set.
The processor also realizes the following steps when executing the program: the analyzing the resource string key value pairs in the target resource string file, and the obtaining the first resource string key value pair set comprises the following steps: analyzing each line of data of the target resource character string file to obtain a data line which does not contain a preset character string, and obtaining a data line set, wherein the preset character string represents a character string irrelevant to the resource character string; writing each row of data in the data row set into a file to obtain a first file; and separating the character string identifier in each row of data of the first file from the code file corresponding to the character string identifier to obtain a resource character string key value pair set.
The processor also realizes the following steps when executing the program: before receiving the replacement instruction for at least one character string identifier on the preset interface, the method further comprises: under the condition that a target object triggers a preset triggering condition, determining the project name of a running project in target equipment to obtain a project name set; acquiring a file path of a current processed file to obtain a third file path; determining the project names contained in the third file path according to the project names in the project name set to obtain target project names; and determining a target item according to the name of the target item, and triggering a replacement instruction aiming at least one character string identifier on a preset interface.
The device herein may be a server, PC, PAD, cell phone, etc.
The present application also provides a computer program product adapted to perform, when executed on a data processing device, a program initialized with the method steps of: receiving a query instruction of a resource character string aiming at a target item; responding to a query instruction, and querying in a resource character string object set pre-constructed for a target item to obtain at least one first resource character string object, wherein the resource character string object set comprises a plurality of resource character string objects, and code text of different resource character strings corresponding to the same code semantic information under different language types is different; and displaying the character string identification or the code text of at least one first resource character string object on a preset interface.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: the inquiry instruction comprises code semantic information of a resource character string; after displaying the character string identifier or the code text of the at least one first resource character string object on the preset interface, the method further comprises: receiving a replacement instruction aiming at least one character string identifier on a preset interface; and replacing the code semantic information in the query instruction with the target character string identifier acted by the replacement instruction.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: before displaying the character string identifier or the code document of the at least one first resource character string object on the preset interface, the method further comprises: identifying a file containing the resource character string in the file contained in the target item to obtain a target resource character string file; analyzing the resource character string key value pairs in the target resource character string file to obtain a first resource character string key value pair set, wherein the resource character string key value pairs at least comprise: character string identification and code document; dividing the first resource character string key value pair set into at least one second resource character string key value pair set according to the language type of the resource character string key value pair, and determining the language type of each second resource character string key value pair set; dividing each second resource character string key value pair set into at least one third resource character string key value pair set according to the file to which the resource character string key value pair belongs, and determining a file path corresponding to each third resource character string key value pair set; and respectively determining the resource character string key value pairs in the third resource character string key value pair set corresponding to each file path as resource character string objects to obtain a resource character string object set.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: querying in a resource string object set pre-constructed for a target item to obtain at least one first resource string object, wherein the obtaining comprises the following steps: when the query instruction contains the character string identifier, traversing the resource character string key value pairs contained in each third resource character string key value pair set in each second resource character string key value pair set in turn until the third resource character string key value pair set containing the character string identifier is determined; determining a file path corresponding to a third resource character string key value pair set containing character string identifiers, and obtaining at least one first file path; traversing the file corresponding to the at least one first file path, and determining the resource character string corresponding to the character string identifier to obtain at least one first resource character string.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: querying in a resource string object set pre-constructed for a target item to obtain at least one first resource string object, wherein the obtaining comprises the following steps: when the query instruction contains code semantic information, determining a target language type of the code semantic information; determining a second resource character string key value pair set corresponding to the target language type to obtain a target second resource character string key value pair set; traversing the resource character string key value pairs in the target second resource character string key value pair set until the resource character string key value pairs corresponding to the code semantic information are determined, and obtaining at least one first resource character string key value pair; determining a file path corresponding to at least one first resource character string key value pair to obtain at least one second file path, traversing a file corresponding to the at least one second file path, and determining a resource character string corresponding to code semantic information to obtain at least one first resource character string.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: determining a second resource string key value pair set corresponding to the target language type, wherein the obtaining the target second resource string key value pair set comprises: determining character string identifiers of the resource character strings in the resource character string object set to obtain a character string identifier set; under the condition that the target language type does not belong to a first preset language, determining a second resource character string key value pair set corresponding to the first preset language to obtain a target second resource character string key value pair set, wherein the first preset language refers to English; determining at least one first resource character string according to the character string identification corresponding to the code semantic information under the condition that the target language type belongs to a first preset language and the character string identification set contains the code semantic information; and under the condition that the target language type belongs to a first preset language and the character string identification set does not contain code semantic information, determining a second resource character string key value pair set corresponding to the first preset language to obtain a target second resource character string key value pair set.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: the analyzing the resource string key value pairs in the target resource string file, and the obtaining the first resource string key value pair set comprises the following steps: analyzing each line of data of the target resource character string file to obtain a data line which does not contain a preset character string, and obtaining a data line set, wherein the preset character string represents a character string irrelevant to the resource character string; writing each row of data in the data row set into a file to obtain a first file; and separating the character string identifier in each row of data of the first file from the code file corresponding to the character string identifier to obtain a resource character string key value pair set.
When executed on a data processing device, is further adapted to carry out a program initialized with the method steps of: before receiving the replacement instruction for at least one character string identifier on the preset interface, the method further comprises: under the condition that a target object triggers a preset triggering condition, determining the project name of a running project in target equipment to obtain a project name set; acquiring a file path of a current processed file to obtain a third file path; determining the project names contained in the third file path according to the project names in the project name set to obtain target project names; and determining a target item according to the name of the target item, and triggering a replacement instruction aiming at least one character string identifier on a preset interface.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.

Claims (10)

1. A method of operating a resource string, comprising:
receiving a query instruction of a resource character string aiming at a target item;
responding to the query instruction, and querying in a resource character string object set pre-constructed for the target item to obtain at least one first resource character string object, wherein the resource character string object set comprises a plurality of resource character string objects, and code text of different resource character strings corresponding to the same code semantic information under different language types is different;
and displaying the character string identification or the code text of at least one first resource character string object on a preset interface.
2. The method of claim 1, wherein the query instruction includes code semantic information for a resource string; after displaying the character string identifier or the code text of at least one of the first resource character string objects on a preset interface, the method further comprises:
receiving a replacement instruction aiming at least one character string identifier on the preset interface;
and replacing the code semantic information in the query instruction with a target resource character string identifier acted by the replacement instruction.
3. The method according to claim 1 or 2, wherein before displaying the string identification or code text of at least one of the first resource string objects on a preset interface, the method further comprises:
identifying a file containing the resource character string from the files contained in the target item to obtain a target resource character string file;
analyzing the resource string key value pairs in the target resource string file to obtain a first resource string key value pair set, wherein the resource string key value pairs at least comprise: character string identification and code document;
dividing the first resource character string key value pair set into at least one second resource character string key value pair set according to the language type of the resource character string key value pair, and determining the language type of each second resource character string key value pair set;
dividing each second resource string key value pair set into at least one third resource string key value pair set according to the file to which the resource string key value pair belongs, and determining a file path corresponding to each third resource string key value pair set;
and respectively determining the resource character string key value pairs in the third resource character string key value pair set corresponding to each file path as resource character string objects to obtain the resource character string object set.
4. The method of claim 3, wherein querying in a set of resource string objects pre-constructed for the target item to obtain at least one first resource string object comprises:
when the query instruction contains the character string identifier, traversing resource character string key value pairs contained in each third resource character string key value pair set in each second resource character string key value pair set in turn until a third resource character string key value pair set containing the character string identifier is determined;
determining a file path corresponding to a third resource character string key value pair set containing the character string identifier, and obtaining at least one first file path;
traversing the file corresponding to the at least one first file path, and determining the resource character string corresponding to the character string identifier to obtain the at least one first resource character string.
5. The method of claim 3, wherein querying in a set of resource string objects pre-constructed for the target item to obtain at least one first resource string object comprises:
when the query instruction contains the code semantic information, determining a target language type of the code semantic information;
Determining a second resource character string key value pair set corresponding to the target language type to obtain a target second resource character string key value pair set;
traversing the resource character string key value pairs in the target second resource character string key value pair set until the resource character string key value pairs corresponding to the code semantic information are determined, and obtaining at least one first resource character string key value pair;
determining a file path corresponding to the at least one first resource string key value pair to obtain at least one second file path, traversing a file corresponding to the at least one second file path, and determining a resource string corresponding to the code semantic information to obtain the at least one first resource string.
6. The method of claim 5, wherein determining the set of second resource string key-value pairs corresponding to the target language type, the set of second resource string key-value pairs comprising:
determining character string identifiers of the resource character strings in the resource character string object set to obtain a character string identifier set;
determining a second resource character string key value pair set corresponding to a first preset language under the condition that the target language type does not belong to the first preset language, and obtaining the target second resource character string key value pair set, wherein the first preset language refers to English;
Determining the at least one first resource character string according to the character string identifier corresponding to the code semantic information under the condition that the target language type belongs to the first preset language and the character string identifier set contains the code semantic information;
and under the condition that the target language type belongs to the first preset language and the character string identification set does not contain the code semantic information, determining a second resource character string key value pair set corresponding to the first preset language to obtain the target second resource character string key value pair set.
7. The method of claim 3, wherein parsing the resource string key pairs in the target resource string file to obtain the first set of resource string key pairs comprises:
analyzing each line of data of the target resource character string file to obtain a data line which does not contain a preset character string, and obtaining a data line set, wherein the preset character string represents a character string irrelevant to the resource character string;
writing each row of data in the data row set into a file to obtain a first file;
and separating the character string identifier from the code file corresponding to the character string identifier in each line of data of the first file to obtain the resource character string key value pair set.
8. The method of claim 2, wherein prior to receiving the replacement instruction for at least one string identification on the preset interface, the method further comprises:
under the condition that a target object triggers a preset triggering condition, determining the project name of a running project in target equipment to obtain a project name set;
acquiring a file path of a current processed file to obtain a third file path;
determining the project names contained in the third file path according to the project names in the project name set to obtain target project names;
and determining the target item according to the target item name, and triggering a replacement instruction aiming at least one character string identifier on the preset interface.
9. An operating device for a resource string, comprising:
the first receiving unit is used for receiving a query instruction of a resource character string aiming at a target item;
the query unit is used for responding to the query instruction, querying in a resource character string object set pre-constructed for the target item to obtain at least one first resource character string object, wherein the resource character string object set comprises a plurality of resource character string objects, and code text cases of different resource character strings corresponding to the same code semantic information under different language types are different;
And the display unit is used for displaying the character string identification or the code text of at least one first resource character string object on a preset interface.
10. An electronic device comprising one or more processors and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of operation of the resource string of any of claims 1-8.
CN202311788427.8A 2023-12-22 2023-12-22 Operation method and device of resource character string and electronic equipment Pending CN117708385A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311788427.8A CN117708385A (en) 2023-12-22 2023-12-22 Operation method and device of resource character string and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311788427.8A CN117708385A (en) 2023-12-22 2023-12-22 Operation method and device of resource character string and electronic equipment

Publications (1)

Publication Number Publication Date
CN117708385A true CN117708385A (en) 2024-03-15

Family

ID=90155113

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311788427.8A Pending CN117708385A (en) 2023-12-22 2023-12-22 Operation method and device of resource character string and electronic equipment

Country Status (1)

Country Link
CN (1) CN117708385A (en)

Similar Documents

Publication Publication Date Title
US10152488B2 (en) Static-analysis-assisted dynamic application crawling architecture
US10210240B2 (en) Systems and methods for code parsing and lineage detection
CN102804147A (en) Code inspection executing system for performing a code inspection of ABAP source codes
CN111367595B (en) Data processing method, program running method, device and processing equipment
US20130159828A1 (en) Method and Apparatus for Building Sales Tools by Mining Data from Websites
CN113688288A (en) Data association analysis method and device, computer equipment and storage medium
EP2951680B1 (en) Acquiring identification of an application lifecycle management entity associated with similar code
CN111083054B (en) Route configuration processing method and device, computer equipment and storage medium
CN107391528B (en) Front-end component dependent information searching method and equipment
CN111368167A (en) Chinese literature data automatic acquisition method based on web crawler technology
US10223086B2 (en) Systems and methods for code parsing and lineage detection
CN111984659B (en) Data updating method, device, computer equipment and storage medium
CN110489032B (en) Dictionary query method for electronic book and electronic equipment
US9286348B2 (en) Dynamic search system
US11580251B1 (en) Query-based database redaction
CN117708385A (en) Operation method and device of resource character string and electronic equipment
CN110968500A (en) Test case execution method and device
CN115033592A (en) SQL statement processing method, device, equipment and storage medium based on database
CN114281688A (en) Codeless or low-code automatic case management method and device
CN114185958A (en) Blood relationship generation method and device, computer equipment and storage medium
US9471569B1 (en) Integrating information sources to create context-specific documents
US10866993B2 (en) Managing online help information in a data center
CN111813749A (en) File filtering method and device, electronic equipment and storage medium
CN109948034B (en) Method and device for extracting page information based on filtering session
CN112883343A (en) Program code obfuscation method and device

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