A multilingual configuration file processing method and device, a storage medium and an equipment

By automatically identifying and flattening JavaScript configuration files, generating visual tables and exporting them to Excel, the problem of low efficiency in manual verification in multilingual software products is solved, achieving efficient and accurate multilingual configuration management.

CN122331940APending Publication Date: 2026-07-03SHANGHAI JIACHE INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANGHAI JIACHE INFORMATION TECH CO LTD
Filing Date
2026-03-25
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

In the front-end development of multilingual software products, the verification of JavaScript configuration files relies on manual checks, which is inefficient and prone to data deviations, and is affected by factors such as inconsistent file formats and complex nested structures.

Method used

By automatically identifying the definition format type of JavaScript configuration files, calling the corresponding parsing function to extract language identifiers and key-value pair configuration data, and flattening the nested structure to generate a visual table, the system can automate the processing of multilingual configuration files.

Benefits of technology

It improves the efficiency and accuracy of JavaScript configuration file verification, reduces the error rate of manual verification, and simplifies the data processing workflow through visual tables and Excel export functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122331940A_ABST
    Figure CN122331940A_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, storage medium, and device for processing multilingual configuration files. The method involves acquiring a JavaScript configuration file to be processed, automatically identifying its defined format type, calling a parsing function corresponding to the defined format type to parse the JavaScript configuration file, extracting language identifiers and key-value pair configuration data from the file, thereby achieving compatible parsing of configuration files with different formats and providing standardized object data for subsequent processing. After parsing the multilingual configuration data, the nested structure data within the multilingual configuration data is flattened, and a visual table is generated based on the flattened data. This achieves automated processing of JavaScript configuration files for multilingual software products, improving the efficiency and accuracy of JavaScript configuration file verification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software development technology, and more specifically, to a method, apparatus, storage medium, and device for processing multilingual configuration files. Background Technology

[0002] In the field of front-end development for multilingual software products, the industry commonly uses JavaScript configuration files to store language configuration information for different languages, such as Simplified Chinese, English, and Traditional Chinese. During product development, maintenance, and iterative upgrades, developers need to verify the JavaScript configuration files to ensure that the text content of the same configuration item corresponds consistently across languages. However, due to factors such as inconsistent file formats and complex nested structures, manual verification by developers is inefficient and prone to data discrepancies. Summary of the Invention

[0003] The purpose of this application is to provide a method, apparatus, storage medium and device for processing multilingual configuration files, which aims to solve the problem that the verification of JavaScript configuration files of multilingual software products in related technologies relies on manual labor, which is inefficient and prone to data deviation.

[0004] In a first aspect, this application provides a method for processing multilingual configuration files, comprising: obtaining a JavaScript configuration file to be processed; wherein the JavaScript configuration file stores language configuration information for at least two languages; identifying the definition format type of the JavaScript configuration file, calling a parsing function corresponding to the definition format type, extracting language identifiers and key-value pair configuration data from the JavaScript configuration file, and obtaining multilingual configuration data based on the language identifiers and the key-value pair configuration data; flattening the nested structure data in the multilingual configuration data, and generating a visual table based on the flattened multilingual configuration data.

[0005] In the above implementation process, the JavaScript configuration file to be processed is obtained, its defined format type is automatically identified, and the parsing function corresponding to the defined format type is called to parse the JavaScript configuration file, extracting the language identifier and key-value pair configuration data in the file, thereby achieving compatible parsing of configuration files of different formats and providing standardized object data for subsequent processing. After parsing the multilingual configuration data, the data containing nested structures in the multilingual configuration data is flattened, and a visual table is generated based on the flattened data. In this way, the JavaScript configuration file of multilingual software products is automatically processed, improving the efficiency and accuracy of JavaScript configuration file verification.

[0006] Furthermore, in some examples, obtaining the JavaScript configuration file to be processed includes: obtaining the file uploaded by the user through the file upload interface; identifying the format of the file to be processed; and if the format of the file to be processed is the target format, then determining that the file is the JavaScript configuration file to be processed.

[0007] In the above implementation process, a file upload interface was built for users to upload JavaScript configuration files to be processed. File upload validation logic was also added to restrict the uploaded file format to the target format, thereby preventing invalid files from interfering with the processing flow. This improves processing efficiency.

[0008] Furthermore, in some examples, before identifying the definition format type of the JavaScript configuration file, the process includes: identifying comment information in the text content of the JavaScript configuration file using predefined regular expression matching rules; removing the identified comment information to obtain cleaned text; attempting to parse the cleaned text, and providing error information if a parsing error occurs.

[0009] In the above implementation process, corresponding regular expression matching rules are pre-defined for the comment information in the JavaScript configuration file. After the user uploads the JavaScript configuration file to be processed, the comment information is automatically identified through the regular expression matching rules. After removing the comment information, the program attempts to parse the cleaned text. If a parsing error occurs, an error message is immediately displayed; if the parsing is successful, the program proceeds to the next step. In this way, it is ensured that the processed text can be parsed normally by the program.

[0010] Furthermore, in some examples, the step of extracting language identifiers and key-value pair configuration data from the JavaScript configuration file, and obtaining multilingual configuration data based on the language identifiers and key-value pair configuration data, includes: traversing preset language identifiers, matching the text content of the JavaScript configuration file using corresponding regular expressions, and determining the starting position of the configuration object based on the matching position; based on the starting position, extracting the object text of the configuration object from the text content, and cleaning the object text to obtain processed object text; parsing the processed object text into a JavaScript object, extracting key-value pair configuration data from the JavaScript object; and classifying and storing the key-value pair configuration data by language according to the corresponding language identifier to obtain multilingual configuration data.

[0011] The above implementation process provides a specific method for parsing JavaScript configuration files.

[0012] Furthermore, in some examples, the flattening process for the multilingual configuration data containing nested structures includes: based on a recursive traversal algorithm, transforming the multilingual configuration data containing nested structures into a one-dimensional flat key-value pair structure to obtain the flattened multilingual configuration data; wherein, in the flattened multilingual configuration data, each configuration item corresponds to a unique flat key name, and the text value of the corresponding key name in each language is retained; the recursive traversal algorithm uses a recursive function to traverse each key-value pair of the nested object, if the value is a normal string, it returns directly, if the value is a nested object, it continues to call the recursive function, and concatenates the current key name to the parent key name.

[0013] In the above implementation process, for the nested key-value pair structure in the JavaScript configuration file, the nested object structure is parsed layer by layer through a recursive traversal algorithm to achieve accurate comparison of multilingual configuration items and solve the problem that nested structures cannot be directly compared.

[0014] Furthermore, in some examples, generating a visualization table based on the flattened multilingual configuration data includes: creating a visualization table based on the flattened multilingual configuration data; wherein the visualization table uses flat key names as the column name and cell content of the first column, and the language names as the column names of the remaining columns; traversing the flattened multilingual configuration data, filling the cells of the visualization table with the text values ​​of the same configuration item under different languages; traversing all cells, and if any cell has no content, or the corresponding text value is inconsistent with the text value of the same configuration item under other languages, highlighting the cell using a preset highlighting style.

[0015] In the above implementation process, when generating the visual table, a table container is first created, and the flat key name is used as the column name and cell content of the first column of the table as a unique identifier for the configuration item. The language name is used as the column name for the subsequent columns of the table. Then, the standardized flat key-value pair data is traversed, and the text value of the same configuration item under different languages ​​is filled into the corresponding cells. Then, all cells of the table are traversed. If a cell has no content or the text value is inconsistent across languages, the corresponding cell is marked with a preset highlighting style. In this way, the configuration problem is presented intuitively, making it easier for developers to quickly locate the problem.

[0016] Furthermore, in some examples, it also includes: in response to an export command, reading all data in the visualization table, converting the data into a binary stream of an Excel file, and saving the binary stream as an export file based on preset export rules; the export rules include cell formatting rules, column width setting rules, and file naming rules.

[0017] In the above implementation process, after generating the visualization table, in response to the export command, the data in the visualization table is exported as an Excel file based on the preset export rules. In this way, the parsed data is directly converted into an Excel file, which replaces the tedious process of manually organizing and entering data into Excel in related technologies and eliminates the bias of manual intervention in data flow.

[0018] Secondly, this application provides a multilingual configuration file processing device, comprising: an acquisition module for acquiring a JavaScript configuration file to be processed; wherein the JavaScript configuration file stores language configuration information for at least two languages; a parsing module for identifying the definition format type of the JavaScript configuration file, calling a parsing function corresponding to the definition format type, extracting language identifiers and key-value pair configuration data from the JavaScript configuration file, and obtaining multilingual configuration data based on the language identifiers and the key-value pair configuration data; and a generation module for flattening the nested structure data in the multilingual configuration data, and generating a visual table based on the flattened multilingual configuration data.

[0019] Thirdly, this application provides an electronic device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the method described in any of the first aspects.

[0020] Fourthly, this application provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the method described in any of the first aspects.

[0021] Fifthly, this application provides a computer program product that, when run on a computer, causes the computer to perform the method described in any of the first aspects.

[0022] Other features and advantages disclosed in this application will be set forth in the following description, or some features and advantages may be inferred from the description or determined without doubt, or may be learned by practicing the above-described technology disclosed in this application.

[0023] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0024] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 A flowchart illustrating a multilingual configuration file processing method provided in this application embodiment; Figure 2 A schematic diagram illustrating the workflow of an implementation scheme for a multilingual configuration table generation and export tool provided in this application embodiment; Figure 3 A block diagram of a multilingual configuration file processing device provided in this application embodiment; Figure 4 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0026] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0027] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0028] In the field of front-end development for multilingual software products, the industry commonly uses JavaScript configuration files to store language configuration information for different languages, such as Simplified Chinese, English, and Traditional Chinese. During the front-end development, maintenance, and iterative upgrades of multilingual software products, developers need to verify these JavaScript configuration files to ensure that the text content of the same configuration item corresponds consistently across languages. Currently, developers mainly rely on manual verification of JavaScript configuration files. However, due to factors such as inconsistent file formats and complex nested structures, manual verification is inefficient and prone to data discrepancies, failing to meet the efficient configuration management requirements in multilingual product development.

[0029] To address the aforementioned issues, this application provides a multilingual configuration file processing solution. It acquires the JavaScript configuration file to be processed, automatically identifies its defined format type, and calls the parsing function corresponding to the defined format type to parse the JavaScript configuration file. This extracts the language identifier and key-value pair configuration data from the file, thereby achieving compatible parsing of configuration files with different formats and providing standardized object data for subsequent processing. Furthermore, it flattens the nested key-value pair structure in the JavaScript configuration file and generates a visual table based on the flattened data. This automates the processing of JavaScript configuration files, improving efficiency and effectively reducing the error rate of manual verification.

[0030] The embodiments of this application will be described below: like Figure 1 As shown, Figure 1 This is a flowchart illustrating a multilingual configuration file processing method provided in an embodiment of this application. The method can be implemented as a multilingual configuration table generation tool. The method includes: Step 101: Obtain the JavaScript configuration file to be processed; wherein the JavaScript configuration file stores language configuration information for at least two languages; The JavaScript configuration file mentioned in this step can be the configuration file of any multilingual software product, i.e., a multilingual configuration file. This multilingual configuration file can store language configuration information for at least two of the multiple languages, such as Simplified Chinese, English, Traditional Chinese, French, and German. The configuration file uses key-value pairs as its core structure.

[0031] In some embodiments, obtaining the JavaScript configuration file to be processed mentioned in this step may include: obtaining the file uploaded by the user through a file upload interface; identifying the format of the file to be processed; and determining that the file is a JavaScript configuration file to be processed if its format matches the target format. In other words, a file upload interface can be built for users to upload JavaScript configuration files to be processed. Simultaneously, file upload validation logic can be added to limit the uploaded file format to the target format, such as .js. If the user uploads a .js file, it is determined that the file is a JavaScript configuration file to be processed, and the next step of processing is initiated. If the user uploads a non-.js file, a prompt box is displayed and the file is rejected, thereby preventing invalid files from interfering with the processing flow. This improves processing efficiency.

[0032] Step 102: Identify the definition format type of the JavaScript configuration file, call the parsing function corresponding to the definition format type, extract the language identifier and key-value pair configuration data from the JavaScript configuration file, and obtain multilingual configuration data based on the language identifier and the key-value pair configuration data; The key-value pair configuration data mentioned in this step is the core data of the JavaScript configuration file, which is a key-value pair configuration item of "unique key name + corresponding language display text". When verifying the JavaScript configuration file, it needs to be parsed to extract this core data. In practical applications, due to differences in development specifications, JavaScript configuration files have two mainstream definition formats: ES module specification and CommonJS module specification. The configuration file formats of different projects are not uniform, and existing tools cannot be compatible with parsing both mainstream definition formats. Developers need to develop separate processing logic for different formats, resulting in high development costs. Therefore, this application embodiment integrates a design that automatically identifies the definition format type of the JavaScript configuration file and calls the corresponding parsing function to perform parsing, achieving multi-format compatible parsing. This eliminates the need to develop separate parsing scripts for configuration files of different projects, reducing repetitive development work for developers and effectively lowering development costs.

[0033] Specifically, the definition format type of a JavaScript configuration file can be determined through characteristic character matching. If the text content of the JavaScript configuration file contains the characteristic character "const language identifier = {", then the definition format type of the JavaScript configuration file is determined to be the ES module specification. If the text content of the JavaScript configuration file contains the characteristic character "module.exports = { lang: {", then the definition format type of the JavaScript configuration file is determined to be the CommonJS module specification. Alternatively, a format selection drop-down box can be added to the file upload interface, allowing users to select the definition format type when uploading a file. The tool provided in this application embodiment can integrate two sets of parsing functions, each set of parsing functions corresponding to a mainstream definition format. After identifying the definition format type of the JavaScript configuration file, the corresponding parsing function is called to parse it and extract the core data from the file.

[0034] In some embodiments, the step of extracting language identifiers and key-value pair configuration data from the JavaScript configuration file and obtaining multilingual configuration data based on the language identifiers and key-value pair configuration data may include: traversing preset language identifiers, matching the text content of the JavaScript configuration file using corresponding regular expressions, and determining the starting position of the configuration object based on the matching position; based on the starting position, extracting the object text of the configuration object from the text content, and cleaning the object text to obtain processed object text; parsing the processed object text into a JavaScript object, and extracting key-value pair configuration data from the JavaScript object; and classifying and storing the key-value pair configuration data by language according to the corresponding language identifier to obtain multilingual configuration data.

[0035] In other words, during parsing, the predefined language identifiers can be traversed first, such as "en" for English, "zhCN" for Simplified Chinese, or "zhTW" for Traditional Chinese. The corresponding regular expressions are used to match the text content of the JavaScript configuration file to locate the starting position of the configuration object. Then, a string extraction function, such as `extractObjectString`, is called. Starting from this starting position (the left parenthesis of the configuration object), the text is traversed using a bracket counting method: incrementing the count when encountering `{` and decrementing the count when encountering `}`, until the count reaches zero. This extracts the complete configuration object text within that range. The extracted object text is then cleaned, such as removing leading and trailing spaces and replacing extra commas at the end, to avoid syntax errors that could cause parsing failures. Finally, since the object text uses JavaScript object syntax, `new` can be used preferentially. The `Function` function parses the data. If parsing fails, it calls `JSON.parse()` to re-parse, ensuring parsing compatibility. After parsing the object text into a JavaScript object, invalid content is filtered out, retaining only key-value pairs ("key name - text content") for configuration data. Finally, the extracted core data is categorized by language and stored in a global `langData` object, resulting in multilingual configuration data. This precise parsing of core data in the JavaScript configuration file improves the efficiency and accuracy of verification.

[0036] Furthermore, some JavaScript configuration files contain single-line and multi-line comments. Directly parsing files containing comments can easily lead to syntax errors and parsing failures. Manually cleaning up comments is time-consuming and prone to omissions. Therefore, in some embodiments, this step may precede: identifying comment information in the text content of the JavaScript configuration file using predefined regular expression matching rules; removing the identified comment information to obtain cleaned text; attempting to parse the cleaned text, and providing error information if parsing errors occur. In other words, corresponding regular expression matching rules can be set for single-line and multi-line comments in the JavaScript configuration file. After the user uploads the JavaScript configuration file to be processed, the text content of the uploaded file can be traversed and read, and all comment information can be automatically identified and removed through regular expression replacement operations. Then, a try-catch statement is used to attempt to parse the cleaned text. If parsing errors occur, error information is immediately provided; if parsing is successful, the next step is initiated. This ensures that the processed text can be parsed correctly by the program. In other embodiments, a JavaScript parser can be used to clean up comments. Specifically, a JavaScript parser such as acorn can be introduced to parse the text content of the JavaScript configuration file into an abstract syntax tree. Then, the abstract syntax tree is traversed and comment nodes are removed. Finally, the processed abstract syntax tree is restored to JavaScript text to achieve comment cleanup.

[0037] Step 103: Flatten the nested structure data in the multilingual configuration data, and generate a visualization table based on the flattened multilingual configuration data.

[0038] In practical applications, JavaScript configuration files often employ nested key-value pair structures for categorized management of configuration items. These nested key-value pair structures cannot be directly cross-language checked, requiring developers to manually expand and organize the configuration items, resulting in extremely low efficiency and a high risk of matching errors. Therefore, the tool in this application addresses this issue by recursively flattening the nested key-value pair structure in JavaScript configuration files, transforming it into one-dimensional flat key-value pairs. This enables precise association of the same configuration item across different languages, improving processing efficiency and eliminating matching errors caused by manual collation.

[0039] In some embodiments, the flattening process of the multilingual configuration data containing nested structures mentioned in this step may include: based on a recursive traversal algorithm, converting the multilingual configuration data containing nested structures into a one-dimensional flat key-value pair structure to obtain the flattened multilingual configuration data; wherein, in the flattened multilingual configuration data, each configuration item corresponds to a unique flat key name, and the text value of the corresponding key name in each language is retained; the recursive traversal algorithm uses a recursive function to traverse each key-value pair of the nested object, if the value is a normal string, it returns directly, if the value is a nested object, it continues to call the recursive function, and concatenates the current key name to the parent key name. In other words, a recursive traversal algorithm can be used to parse nested object structures layer by layer. The recursive function takes two parameters: the nested object and the parent key name. It traverses each key-value pair of the nested object. If the value is a regular string, it returns directly. If the value is a nested object, the recursive function is called, and the current key name is appended to the parent key name to form the form "parent key name + separator + current key name". This recursive traversal algorithm transforms multi-layered, multi-dimensional nested data into a one-dimensional flat key-value pair structure, allowing each configuration item to correspond to a unique flat key name. At the same time, the text value of the corresponding key name in each language is retained, thereby achieving accurate matching of multi-language configuration items and solving the problem that nested structures cannot be directly matched.

[0040] In other embodiments, an iterative traversal algorithm can be used to flatten the nested structure data in the multilingual configuration data. Specifically, a while loop combined with a stack structure can be used to store the nested objects to be traversed and the parent key name. The nested objects are traversed layer by layer and the key name is concatenated to achieve structural flattening. This can avoid the stack overflow problem that occurs when the recursive traversal is extremely deep, thereby further improving the robustness of the tool.

[0041] For verifying JavaScript configuration files in multilingual software products, there is a lack of convenient visual verification tools in related technologies. Developers need to manually check line by line, which results in a high error rate. Therefore, this application's embodiment generates a visual table based on the flattened multilingual configuration data, enabling visual verification and reducing the error rate.

[0042] In some embodiments, generating a visualization table based on the flattened multilingual configuration data mentioned in this step may include: creating a visualization table based on the flattened multilingual configuration data; wherein the visualization table uses flat key names as the column names and cell contents of the first column, and the names of each language as the column names of the remaining columns; traversing the flattened multilingual configuration data, filling the cells of the visualization table with the text values ​​of the same configuration item under different languages; traversing all cells, and if any cell has no content, or the corresponding text value is inconsistent with the text value of the same configuration item under other languages, marking the cell using a preset highlighting style. In other words, when generating a visual table, you can first create a table container, using flat key names as the column name and cell content of the first column of the table as unique identifiers for configuration items, and using the language names as the column names for subsequent columns. Then, iterate through the standardized flat key-value pair data, filling the corresponding cells with the text values ​​of the same configuration item in different languages. Next, iterate through all cells of the table, comparing the cross-language text values ​​of the same row, i.e., the same configuration item. If a cell is empty (configuration item is missing), or if the cross-language text values ​​are inconsistent, then use a preset highlighting style to mark the corresponding cell, such as setting it to a red highlighting style. This makes configuration problems visually apparent, making it easier for developers to quickly locate the problem.

[0043] In some scenarios, developers need to verify JavaScript configuration files and then export the data from these files to Excel format for cross-departmental collaboration or archiving. In related technologies, the parsed configuration data cannot be directly exported to a standardized Excel file; it requires manual processing and data entry into Excel, which is cumbersome and prone to data entry errors. Therefore, some embodiments may further include: responding to an export command, reading all data from the visualized table, converting the data into a binary stream of an Excel file, and saving the binary stream as an export file based on preset export rules; the export rules include cell formatting rules, column width setting rules, and file naming rules. In other words, after generating the visual table, if the user issues an export command, the xlsx.js library (a JavaScript library that supports reading and generating Excel files) can be called to read all the data in the table's DOM (Document Object Model) nodes, convert the data into a binary stream of an Excel file, and then obtain the exported Excel file based on preset export rules, such as automatically setting the cell format to text, automatically setting column widths to adapt to the content length, and using "Multilingual Configuration Comparison Table_Current Timestamp.xlsx" as the exported file name. This achieves direct conversion of parsed data into an Excel file, replacing the tedious process of manually organizing and entering data into Excel files in related technologies, and eliminating human intervention bias in data flow. Alternatively, an assisted export method using a backend interface can be used to export Excel files. Specifically, the flattened configuration data parsed by the frontend is sent to the backend server via AJAX (Asynchronous JavaScript and XML). The backend receives the data and generates an Excel file using frameworks such as Apache POI and EasyExcel. The frontend obtains the Excel file generated by the backend through a download interface and downloads it. This method can reduce the performance consumption of the frontend page and is suitable for exporting large configuration files.

[0044] In this embodiment, a JavaScript configuration file to be processed is obtained, its defined format type is automatically identified, and a parsing function corresponding to the defined format type is called to parse the JavaScript configuration file, extracting language identifiers and key-value pair configuration data from the file. This achieves compatible parsing of configuration files with different formats, providing standardized object data for subsequent processing. After parsing the multilingual configuration data, the nested structure data in the multilingual configuration data is flattened, and a visual table is generated based on the flattened data. In this way, the automated processing of JavaScript configuration files is achieved, improving the efficiency and accuracy of JavaScript configuration file verification.

[0045] To provide a more detailed explanation of the solution in this application, a specific embodiment is described below: This embodiment provides an implementation scheme for a multilingual configuration table generation and export tool. This scheme uses HTML (Hypertext Markup Language) as the carrier and JavaScript as the core development language, through methods such as... Figure 2 The workflow shown automates and standardizes the entire process of parsing and exporting JavaScript configuration files.

[0046] The workflow includes: S201, JavaScript configuration file upload; Specifically, an HTML-based file upload interface is built, supporting single-file / multiple-file batch uploads and limiting file uploads to .js format. JavaScript is used to listen for file upload events, obtaining the file's binary stream and file name to prepare data for subsequent processing. File upload validation logic is also added; if a non-.js format file is uploaded, a prompt box will pop up immediately and the file will be rejected to prevent invalid files from interfering with the processing flow. S202. Automatic cleanup of configuration file comments; Specifically, regular expression matching and parsing logic is written in JavaScript, with dedicated regular expression matching rules set for single-line comments and multi-line comments in the JavaScript configuration file. For example, the regular expression matching rule " / \ / \ / .* / g" matches single-line comments, and the regular expression matching rule " / \ / \*[\s\S]*?\*\ / / g" matches multi-line comments. The text content of the uploaded file is traversed and read, and all comment information is automatically identified and removed through regular expression replacement, retaining only the core key-value pair structure and content. After the comment cleanup is completed, syntax validation logic is added. The cleaned text is attempted to be parsed using a try-catch statement. If a parsing error occurs, the error message is immediately fed back. If the parsing is successful, the next step is performed to ensure that the processed text can be parsed by the program normally. S203, multi-format compatible parsing; Specifically, for the two mainstream JavaScript configuration file definition formats in the industry, the tool pre-sets format recognition and adaptation parsing logic: First, it determines the definition format type by matching characteristic characters. If the text contains the characteristic character "const language identifier = {", then the JavaScript configuration file definition format type is determined to be ES module specification. If the text contains the characteristic character "module.exports = { lang: {", then the JavaScript configuration file definition format type is determined to be CommonJS module specification. Then, it calls the parsing function corresponding to the identified definition format type, and extracts the language identifier and key-value pair configuration data in the file through operations such as string truncation and JSON.parse() parsing. The parsed data is then stored in a JavaScript object to achieve compatible parsing of different configuration file formats. S204, Flattening of nested key-value pair structures; Specifically, for the nested key-value pair structure in JavaScript configuration files, a recursive traversal algorithm was written to parse the nested object structure layer by layer through function self-calling. In the implementation, the recursive function is set to accept two parameters: the nested object and the parent key name. It traverses each key-value pair of the nested object. If the value is a normal string, it is returned directly. If the value is a nested object, the recursive function is called again, and the current key name is concatenated to the parent key name to form the form "parent key name.current key name". This algorithm transforms multi-layered nested multi-dimensional data into a one-dimensional flat key-value pair structure, so that each configuration item corresponds to a unique flat key name, while retaining the text value of the corresponding key name in each language, thus standardizing the data for multilingual comparison. S205, Multilingual configuration visualization table generation; Specifically, based on the flattened multilingual configuration data, a front-end visual table is dynamically generated using JavaScript combined with DOM manipulation. In implementation, a table container is created in the HTML page, using the flat key name as the column name and cell content of the first column as a unique identifier for the configuration item, and then using the language name as the column name for subsequent columns. The standardized flat key-value pair data is traversed, and the text value of the same configuration item under different languages ​​is accurately filled into the corresponding cells. At the same time, a logic for highlighting problematic data is added, that is, traversing all cells of the table and comparing the cross-language text values ​​in the same row. If a cell in a certain language has no content or the cross-language text values ​​are inconsistent, the corresponding cell is set to a red style, so that configuration problems are presented intuitively and visual verification is achieved. S206, Standardized Excel file export; Specifically, the xlsx.js library is integrated into JavaScript. The library's `utils.table_to_book()` method reads all data from the table's DOM nodes, preserving the column names, configuration items, and multilingual text mappings. The `utils.book_to_xlsx()` method converts the data into a binary stream for an Excel file, automatically setting the Excel cell format to text and adjusting column widths to adapt to content length. A file naming convention is added, using "Multilingual Configuration Reference Table_Current Timestamp.xlsx" as the exported file name. Users can export with a single click, and the exported Excel file is in the universal .xlsx format, which can be directly opened by office software without manual processing.

[0047] This embodiment automates the entire process of cleaning, parsing, organizing, verifying, and exporting multilingual configuration files. The entire operation can be completed in just two steps: "upload file → one-click export," replacing the tedious manual operations in related technologies and effectively improving the overall efficiency of multilingual configuration management. At the same time, from the parsed flat data structure to the visual table and the Excel export file, a unified standard is formed, providing a benchmark for the entire process of multilingual configuration development, maintenance, and collaboration. Therefore, it is applicable to all front-end development projects that use JavaScript format to store multilingual configurations.

[0048] Corresponding to the embodiments of the aforementioned methods, this application also provides embodiments of a multilingual configuration file processing device and a terminal for its application: like Figure 3 As shown, Figure 3 This is a block diagram of a multilingual configuration file processing device provided in an embodiment of this application. The device includes: The acquisition module 31 is used to acquire the JavaScript configuration file to be processed; wherein the JavaScript configuration file stores language configuration information for at least two languages; Parsing module 32 is used to identify the definition format type of the JavaScript configuration file, call the parsing function corresponding to the definition format type, extract the language identifier and key-value pair configuration data from the JavaScript configuration file, and obtain multilingual configuration data based on the language identifier and the key-value pair configuration data; The generation module 33 is used to flatten the nested structure data in the multilingual configuration data and generate a visual table based on the flattened multilingual configuration data.

[0049] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.

[0050] This application also provides an electronic device, please refer to [link to application]. Figure 4 , Figure 4 This is a structural block diagram of an electronic device provided in an embodiment of this application. The electronic device may include a processor 410, a communication interface 420, a memory 430, and at least one communication bus 440. The communication bus 440 is used to enable direct communication between these components. In this embodiment, the communication interface 420 of the electronic device is used for signaling or data communication with other node devices. The processor 410 may be an integrated circuit chip with signal processing capabilities.

[0051] The processor 410 described above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor, or the processor 410 can be any conventional processor.

[0052] The memory 430 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc. The memory 430 stores computer-readable instructions. When these computer-readable instructions are executed by the processor 410, the electronic device can perform the aforementioned operations. Figure 1 The various steps involved in the method implementation examples.

[0053] Alternatively, the electronic device may also include a storage controller and an input / output unit.

[0054] The memory 430, storage controller, processor 410, peripheral interface, and input / output unit are electrically connected directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses 440. The processor 410 is used to execute executable modules stored in the memory 430, such as software function modules or computer programs included in electronic devices.

[0055] The input / output unit is used to provide users with the ability to create tasks and to set optional start periods or preset execution times for those tasks, thereby enabling user-server interaction. The input / output unit may be, but is not limited to, a mouse and keyboard.

[0056] Understandable. Figure 4 The structure shown is for illustrative purposes only; the electronic device may also include components that are more advanced than those shown. Figure 4 The more or fewer components shown, or having the same Figure 4 The different configurations shown. Figure 4 The components shown can be implemented using hardware, software, or a combination thereof.

[0057] This application also provides a storage medium storing instructions. When the instructions are run on a computer, the computer program is executed by a processor to implement the method described in the method embodiment. To avoid repetition, the method will not be described again here.

[0058] This application also provides a computer program product that, when run on a computer, causes the computer to perform the method described in the method embodiment.

[0059] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0060] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0061] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0062] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0063] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0064] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A method for processing multilingual configuration files, characterized in that, include: Obtain the JavaScript configuration file to be processed; wherein the JavaScript configuration file stores language configuration information for at least two languages; Identify the definition format type of the JavaScript configuration file, call the parsing function corresponding to the definition format type, extract the language identifier and key-value pair configuration data from the JavaScript configuration file, and obtain multilingual configuration data based on the language identifier and the key-value pair configuration data; The nested structure of the multilingual configuration data is flattened, and a visualization table is generated based on the flattened multilingual configuration data.

2. The method according to claim 1, characterized in that, The process of obtaining the JavaScript configuration file to be processed includes: Obtain the user-uploaded files to be processed through the file upload interface; Identify the format of the file to be processed; If the format of the file to be processed is the target format, then the file is determined to be a JavaScript configuration file to be processed.

3. The method according to claim 1, characterized in that, Before identifying the definition format type of the JavaScript configuration file, the following is included: Comment information in the text content of the JavaScript configuration file is identified using predefined regular expression matching rules; The identified annotation information is removed to obtain the cleaned text; Attempt to parse the cleaned text, and return an error message if a parsing error occurs.

4. The method according to claim 1, characterized in that, The step of extracting language identifiers and key-value pair configuration data from the JavaScript configuration file, and obtaining multilingual configuration data based on the language identifiers and key-value pair configuration data, includes: Traverse the preset language identifiers, match the text content of the JavaScript configuration file using the corresponding regular expressions, and determine the starting position of the configuration object based on the matching position; Based on the starting position, the object text of the configuration object is extracted from the text content, and the object text is cleaned to obtain the processed object text; The processed object text is parsed into a JavaScript object, and key-value pair configuration data is extracted from the JavaScript object; Based on the corresponding language identifier, the key-value pair configuration data is classified and stored according to language to obtain multilingual configuration data.

5. The method according to claim 1, characterized in that, The flattening process for nested data in the multilingual configuration data includes: Based on the recursive traversal algorithm, the nested structure data in the multilingual configuration data is transformed into a one-dimensional flat key-value pair structure to obtain the flattened multilingual configuration data. In the flattened multilingual configuration data, each configuration item corresponds to a unique flat key name, and the text value of the corresponding key name in each language is retained; the recursive traversal algorithm uses a recursive function to traverse each key-value pair of the nested object. If the value is a normal string, it is returned directly; if the value is a nested object, the recursive function is called again, and the current key name is appended to the parent key name.

6. The method according to claim 5, characterized in that, The process of generating a visual table based on the flattened multilingual configuration data includes: A visualization table is created based on the multilingual configuration data after flattening; wherein, the visualization table uses flat key names as the column name and cell content of the first column, and the names of each language as the column names of the remaining columns; Traverse the flattened multilingual configuration data and fill the cells of the visualization table with the text values ​​of the same configuration item in different languages; Iterate through all cells, and if any cell has no content, or if the corresponding text value is inconsistent with the text value of the same configuration item in other languages, mark the cell using a preset highlighting style.

7. The method according to claim 6, characterized in that, Also includes: In response to the export command, all data in the visualization table is read, the data is converted into a binary stream of an Excel file, and the binary stream is saved as an export file based on preset export rules; the export rules include cell formatting rules, column width setting rules, and file naming rules.

8. A multilingual configuration file processing device, characterized in that, include: An acquisition module is used to acquire a JavaScript configuration file to be processed; wherein the JavaScript configuration file stores language configuration information for at least two languages; The parsing module is used to identify the definition format type of the JavaScript configuration file, call the parsing function corresponding to the definition format type, extract the language identifier and key-value pair configuration data from the JavaScript configuration file, and obtain multilingual configuration data based on the language identifier and the key-value pair configuration data; The generation module is used to flatten the nested structure data in the multilingual configuration data and generate a visual table based on the flattened multilingual configuration data.

9. A computer-readable storage medium, characterized in that, It stores a computer program thereon, which, when executed by a processor, implements the method as described in any one of claims 1 to 7.

10. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method as described in any one of claims 1 to 7.