Method, device, medium and product for verifying internationalized translation key in real time based on construction tool and ESLint rule

By combining the build tool with ESLint rules, real-time verification of internationalization translation keys was achieved, solving the problem of translation key validity during the development phase and improving development efficiency as well as the integrity and consistency of multilingual files.

CN121503502AActive Publication Date: 2026-02-10BEIJING HUAXIACHUANGTONG TECH
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202511741026.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-25
Publication Date
2026-02-10
Estimated Expiration
2045-11-25

AI Technical Summary

Technical Problem

Existing internationalization solutions lack real-time verification during the development phase, resulting in the inability to verify the validity of translation keys in a timely manner, high debugging costs, difficulty in multilingual synchronization, and the verification process being independent of the development process, thus failing to provide immediate feedback.

Method used

The build tool plugin automatically scans and caches translation key information, combines ESLint custom rules to perform static analysis on the code, and verifies the validity of translation keys in real time, including missing keys, multilingual consistency, and spelling errors. The verification process is embedded in the build tool lifecycle.

Benefits of technology

Real-time validity verification of translation keys was implemented, which improved development efficiency, reduced debugging costs, and ensured the integrity of translation files and consistency across multiple languages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121503502A_ABST
    Figure CN121503502A_ABST
Patent Text Reader

Abstract

The invention discloses a construction tool and ESLint rule-based internationalized translation key real-time verification method and device, a medium and a product, and relates to the field of front-end application development, and the method comprises the following steps: constructing a translation key cache; monitoring the change of the internationalized language file by using a construction tool or an independent monitoring library, when the change of the internationalized language file is detected, re-analyzing the changed internationalized language file, and performing incremental updating on the translation key cache based on an analysis result; based on an ESLint custom verification rule, when static analysis is carried out on the project source code, a statement calling a translation function in the code is identified, and a translation key in the statement is extracted; comparing the extracted translation keys with the translation keys in the current translation key cache; and outputting verification information according to the comparison result. According to the method, the efficiency and accuracy in the front-end internationalization development process can be improved, the debugging cost is reduced, and the integrity of the translated file is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of front-end application development, and particularly to a method, device, medium and product for real-time verification of internationalization translation keys based on a build tool and ESLint rules. Background Art

[0002] With the increasing complexity of front-end projects and the growing demand for globalization, internationalization (i18n) has become a common requirement in modern Web application development. Internationalization generally refers to the process of making a product easily adaptable to various differences such as languages, regions, cultural customs, currencies, time zones, etc. in software development. For front-end development, "i18n" mainly refers to multi-language switching and translation support at the interface or text content level. Currently, the common practice is to define translation key-value pairs for different languages through JSON files, and then combine libraries such as react-i18next, vue-i18n, etc. to render according to the language environment at runtime. In multi-language (internationalization) development, the text to be displayed in the interface is usually abstracted into a series of unique identifiers corresponding to the same semantics in different language environments, and the corresponding text content in different languages is assigned in different language files. For example: (1) Translation key: "header.title"; (2) Chinese (zh) corresponding translation: "Home Page"; (3) English (en) corresponding translation: "Home"; (4) French (fr) corresponding translation: "Accueil"; These "keys" are usually strings in a hierarchical or dot-separated form (such as "header.title", "profile.user.info", etc.), which are used as cross-language indexes to help quickly obtain the translation text corresponding to different languages in the code logic. In this example, the translation key is the unique identifier corresponding to the same semantic text in a series of different language environments obtained by parsing all language files. The main processes for rendering according to the language environment at runtime include: (1) Define the same translation key in the multi-language JSON file, corresponding to the translation content in different languages respectively; (2) Call the translation function (such as t(), $t(), etc.) in the page or component, and use the specified translation key to obtain the corresponding text; (3) Load the corresponding language file during construction or runtime and replace the translation key with the corresponding text content.

[0003] While existing internationalization solutions can render multiple languages, they have the following shortcomings during the development phase: (1) Lack of real-time verification: When writing internationalization keys in the editor, the validity of translation keys cannot be verified in real time, and developers may use keys that do not exist. (2) Delayed error detection: It is usually necessary to run the application or execute additional scripts to find missing keys or spelling errors, which is costly to debug. (3) Cumbersome verification process: Currently, most solutions collect all translation keys through scripts and then perform Abstract Syntax Tree (AST) analysis on the code to compare whether the key values ​​are missing or redundant, which is highly manual or semi-automatic. (2) Limitations of static analysis: The script scanning method may not be able to handle some dynamically generated translation keys, resulting in missed detections. (3) Lack of integration: The verification process and development process are relatively independent, requiring additional script execution for checking, and it is impossible to get immediate feedback when writing code. (4) Difficulty in multilingual synchronization: When translation keys for some languages ​​are missing or spelling is inconsistent, it is difficult to detect and update them in a timely manner. Based on the above problems, there is an urgent need to provide a method or system for real-time verification of internationalization translation keys based on build tools and ESLint rules, so as to improve the efficiency and accuracy of the front-end internationalization development process, reduce debugging costs, and ensure the integrity of translation files. Summary of the Invention

[0004] The purpose of this application is to provide a method, device, medium, and product for real-time verification of internationalization translation keys based on build tools and ESLint rules, which can improve the efficiency and accuracy of front-end internationalization development, reduce debugging costs, and ensure the integrity of translation files.

[0005] To achieve the above objectives, this application provides the following solution: Firstly, this application provides a method for real-time verification of internationalization translation keys based on build tools and ESLint rules, the method comprising: When the project starts, the build tool plugin automatically scans all internationalized language files under the project's set path, parses and collects all translation keys and related information, and builds a translation key cache; the related information includes the corresponding values ​​of translation keys in different language files, file names, timestamps, and hierarchical structure information; The internationalized language file is monitored using the aforementioned build tool or independent monitoring library. When a change in the internationalized language file is detected, the changed internationalized language file is re-parsed, and the translation key cache is incrementally updated based on the parsing results. Changes in the internationalized language file include: file addition, modification, or deletion operations. Based on ESLint's custom validation rules, when performing static analysis on the project's source code, the system identifies statements that call translation functions and extracts the translation keys from those statements. The extracted translation key is compared with the translation key in the current translation key cache; and the verification information is output according to the comparison result to realize the real-time verification of the validity of the translation key.

[0006] Optionally, the build tool is webpack or vite; the internationalization language file includes language files in JSON, JS, or YAML format.

[0007] Optionally, the ESLint custom validation rules include: Determine the name of the translation function to be tested; Define cache access methods; these methods include referencing shared memory objects, calling APIs, or reading JSON files. Configure the verification logic and the prompt level.

[0008] Optionally, the verification logic includes: translation key missing verification, multilingual consistency verification, spelling error verification, and key name format verification; the prompt level includes: error, warning, or only marking.

[0009] Optionally, the step of using the build tool or independent monitoring library to monitor changes to the internationalized language file, and when a change is detected, re-parses the changed internationalized language file and incrementally updates the translation key cache based on the parsing result, further includes: When the translation key cache is updated, the ESLint plugin is notified to refresh the cache via inter-process communication or file state change, and the translation key is verified based on the updated translation key cache during the next verification.

[0010] Optionally, the method for real-time verification of internationalization translation keys based on build tools and ESLint rules further includes: Embed the real-time validation of translation keys into the lifecycle of the build tool using webpack-plugin or vite-plugin; During the development phase, maintain real-time monitoring and verification; During the production build phase, a full verification is performed; if a critical translation key is missing or multiple languages ​​are out of sync, the build is interrupted.

[0011] Secondly, this application provides a real-time verification device for internationalization translation keys based on build tools and ESLint rules, the device comprising: The translation key cache building module is used to automatically scan all internationalized language files under the project's designated path when the project starts, through the build tool plugin, parse and collect all translation keys and related information, and build a translation key cache; the related information includes the corresponding values ​​of translation keys in different language files, file names, timestamps, and hierarchical structure information; The change monitoring module is used to monitor changes to the internationalized language file using the build tool or an independent monitoring library. When a change to the internationalized language file is detected, the changed internationalized language file is re-parsed, and the translation key cache is incrementally updated based on the parsing results. Changes to the internationalized language file include: file addition, modification, or deletion operations. The static analysis module is used to identify statements that call translation functions in the code and extract translation keys from the statements when performing static analysis on the project source code based on ESLint custom verification rules. The real-time verification module compares the extracted translation key with the translation key in the current translation key cache; and outputs verification information based on the comparison result to realize real-time verification of the validity of the translation key.

[0012] Thirdly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the aforementioned method for real-time verification of internationalization translation keys based on build tools and ESLint rules.

[0013] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned method for real-time verification of internationalization translation keys based on build tools and ESLint rules.

[0014] Fifthly, this application provides a computer program product, including a computer program, characterized in that, when the computer program is executed by a processor, it implements the aforementioned method for real-time verification of internationalization translation keys based on build tools and ESLint rules.

[0015] According to the specific embodiments provided in this application, this application has the following technical effects: This application provides a method, device, medium, and product for real-time verification of internationalization translation keys based on build tools and ESLint rules, aiming to solve the problems of lack of real-time verification, low efficiency, and difficulty in maintaining multi-language synchronization in existing technologies during the development phase. By automatically scanning all internationalization files at project startup and caching their key-value information in memory or persistent storage, and then combining this with customizable configurable static code analysis tools (ECMAScript / JavaScript Lint, ESLint) rules, the translation keys in the code are verified in real time. This application can achieve real-time validity verification of translation keys, multi-language consistency verification, and incremental updates; it can improve the efficiency and accuracy of front-end internationalization development, reduce debugging costs, and ensure the integrity of translation files; thus, it can greatly improve the developer experience and guarantee the usability and consistency of translation keys. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 This is a schematic diagram of a method for real-time verification of internationalization translation keys based on a build tool and ESLint rules in one embodiment of this application; Figure 2 This is a schematic diagram illustrating the principle of real-time verification of internationalization translation keys based on a construction tool and ESLint rules in one embodiment of this application. Detailed Implementation

[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0019] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0020] In one exemplary embodiment, such as Figure 1 and Figure 2 As shown, a method for real-time verification of internationalization translation keys based on build tools and ESLint rules is provided. This method includes the following steps S101 to S104. Wherein: S101, when the project starts, the build tool plugin (webpack-plugin or vite-plugin) automatically scans all internationalized language files under the project's set path, parses and collects all translation keys and related information, and builds a translation key cache; the related information includes the corresponding value of the translation key in different language files, file name, timestamp, and hierarchical structure information; the timestamp is used to determine subsequent incremental updates; The build tool is webpack or vite; the internationalization language files include language files in JSON, JS, or YAML formats.

[0021] S102, the build tool (Watch function) or independent monitoring library (such as chokidar) is used to monitor changes to the internationalized language file. When a change to the internationalized language file is detected, the changed internationalized language file is re-parsed, and the translation key cache is incrementally updated based on the parsing result. Changes to the internationalized language file include: file addition, modification, or deletion operations. To ensure the real-time nature and accuracy of the prompts, S102 and beyond also include: When the translation key cache is updated, the ESLint plugin is notified to refresh the cache via inter-process communication or file state change, and the translation key is verified based on the updated translation key cache during the next verification.

[0022] S103, based on ESLint custom validation rules, when performing static analysis on project source code, identifies statements in the code that call translation functions and extracts the translation keys in those statements; The ESLint custom validation rules include: (1) Determine the name of the translation function to be tested; For example, translation function names might use t(...), $t(...), or i18n.t(...); language files might be .json, .js, .yaml, etc.; and even different places within the same project might generate translation keys in different ways. (2) Define cache access methods; the cache access methods include referencing shared memory objects, calling APIs, or reading JSON files; (3) Set the verification logic and prompt levels. The verification logic includes: translation key missing verification, multilingual consistency verification, spelling error verification and key name format verification; the prompt levels include: error, warning or only mark.

[0023] ESLint rules primarily focus on code style and syntax errors. The validity of internationalization translation keys or multilingual synchronization are not common requirements, so the official documentation does not include corresponding rules.

[0024] As a specific example, the processing procedure for ESLint's custom validation rules is as follows: (1) Create an ESLint plugin project Use the official yeoman generator-eslint or create your own directory such as "eslint-plugin-i18n-check"; configure the plugin information and declare the dependency on ESLint in package.json.

[0025] (2) Writing rule documents For example, write the rule logic in rules / check-translation-keys.js; this rule file needs to export an object containing the create(context) function. create(context) will be called when ESLint analyzes the code to intercept specific AST nodes and perform validation.

[0026] (3) Implement AST detection in the rules In `create(context)`, an object is returned specifying the type of node to listen to (e.g., `CallExpression`). When ESLint iterates through a function call expression, if the function name matches the translation function (`t`, `$t`, or others), its first argument (commonly the translation key string) is read. The existence and consistency of this translation key are then compared with the "translation key cache" in the multilingual files.

[0027] (4) Access the "Translation Key Cache" According to the "plugin" on the build tool, the translation keys will be scanned and collected and stored in memory, files, or IPC (inter-process communication) shared space; ESLint custom validation rules can be processed in the following three ways: (1) directly referencing the shared memory object; (2) calling an API; (3) reading the generated JSON file to obtain the latest data. Once the internationalization language file changes, the build plugin will incrementally update the cache and notify the ESLint plugin of the update.

[0028] (5) Prompt information and level If the translation key does not exist in the cache at all, context.report will show an error indicating "This translation key cannot be used"; if it is only missing or inconsistent in some languages, it can be configured as a warning; this can prompt developers to add the translation as soon as possible without blocking compilation.

[0029] (6) Enable this rule in the project Declare the plugin name in the project's eslintrc or package.json and enable the corresponding rules; configure the error level, such as "error" or "warn"; when developers write and save code, the ESLint plugin runs the rules in real time to perform checks.

[0030] When developers save code in the editor, the ESLint plugin immediately provides feedback on missing or inconsistent information, helping developers to correct errors in a timely manner and add or modify corresponding keys synchronously in other language files.

[0031] By leveraging the real-time suggestions provided by the ESLint plugin, inconsistencies in multilingual files can be quickly identified and fixed. S104: Compare the extracted translation key with the translation key in the current translation key cache; and output verification information based on the comparison result to realize real-time verification of the validity of the translation key.

[0032] The information to be compared includes: (1) Determine how to report errors or issue warnings based on different needs such as missing keys, inconsistencies between multiple languages, and spelling errors; (2) Check the suffix, prefix, naming conventions, and even the key value content (if there are specific format requirements); The verification information can be customized with prompts for error scenarios (such as "The translation key 'xxx' exists in the English file, but is missing in the Chinese file"), allowing developers to more intuitively locate the problem.

[0033] As a specific example, when the translation key is missing, a real-time ESLint error or warning is given; when the translation key is missing or the format is inconsistent in some language files, the developer can also be notified; when the content or spelling of the translation key is inconsistent across different languages, prompts can also be given as needed.

[0034] As a specific embodiment, this application integrates a caching and monitoring mechanism into build tools such as Webpack or Vite to achieve real-time validity verification of translation keys, multilingual consistency verification, and incremental updates; the specific integration process includes: S1 embeds the real-time validation of translation keys into the lifecycle of the build tool through webpack-plugin or vite-plugin. S2 maintains real-time monitoring and verification during the development phase; S3 performs a full check during the production build phase; if a critical translation key is missing or multiple languages ​​are out of sync, the build is interrupted.

[0035] Applying real-time validation to the development and build phases of a project's lifecycle allows developers to be alerted to errors in real time during development, while also providing safeguards during the build phase to ensure the project is built correctly.

[0036] The following specific embodiment illustrates the process of the real-time verification method for internationalization translation keys based on build tools and ESLint rules provided in this application: (1) Initialize translation key cache 1) When the project starts (after webpack / vite's run or compile mode is enabled), the plugin will automatically scan all internationalized language files in the preset paths (such as the default "src / locales / "). "Table of contents); 2) Parse each language file, collect translation keys and their corresponding text, and store them in the cache; 3) Record the modification timestamps of each language file to facilitate subsequent monitoring and incremental updates.

[0037] (2) File monitoring and cache update 1) Monitor changes to all language files; 2) If a file update is detected, the file is re-parsed and compared with the corresponding record in the cache: 1. Delete keys that no longer exist or have been modified; 2. Add new keys; 3) Update the timestamps, translation keys, and other information in the cache; 4) Notify the ESLint plugin to refresh the cache via build tools or event dispatch.

[0038] (3) ESLint custom rules 1) When ESLint inspects the source code of a project, it scans the AST of the front-end code using custom rules. 2) Once a call to a translation function (t(), $t(), etc.) is detected, extract the translation key used; 3) Retrieve the translation key from the cache: 1. If it does not exist, report an error or issue a warning; 2. If it exists but the translation for the specified language file is missing, issue a warning; 3. If the multilingual texts are inconsistent, the warning level can be configured according to requirements (generally a warning).

[0039] 4) Once the cache is updated, ESLint will obtain the latest translation key information and provide a prompt during the next check.

[0040] (4) Build tool integration 1) Incorporate the above logic into the corresponding hooks in the build process using webpack-plugin or vite-plugin; 2) Maintain real-time monitoring and verification in development mode; 3) In production mode, a full scan and verification will be performed, and the build process can be interrupted directly if a critical problem is found.

[0041] For example, suppose there is a Vue project that needs to support three languages: Chinese, English, and French. The "Header.vue" component uses translation keys such as "$t('header.logo')" and "$t('header.menu.home')". If the Chinese language file is missing the "header.menu.home" key value, the ESLint plugin will detect its absence in the Chinese language file through custom rules after the service is started during development and will provide a prompt.

[0042] When the developer adds the key-value pair "header.menu.home" to "zh / common.json" and saves it, the file listener in this application immediately detects the file update and performs an incremental update to the cache. At the same time, it notifies the ESLint plugin to re-validate, thereby eliminating the error message.

[0043] The technical solution provided in this application has the following effects: (1) Real-time verification By using custom ESLint rules, developers can know in real time whether translation keys are available when writing internationalized code, which greatly reduces debugging workload and runtime errors.

[0044] (2) Improved developer experience Integrating internationalization validation into the daily development process eliminates the tedious process of repeatedly executing validation scripts, improving coding efficiency and accuracy.

[0045] (3) High efficiency and low cost By employing incremental updates and caching mechanisms, partial updates are performed only when files change, eliminating the need for repeated full scans of internationalized files and effectively reducing system resource consumption.

[0046] (4) Coverage of multiple languages ​​with consistency Automatically compares the corresponding translation keys in each language file, promptly identifies the risk of missing or outdated language translations, and improves the overall consistency of multilingual translation files.

[0047] (5) Adaptable to multiple build tools It can be integrated into mainstream tools such as webpack or vite as a plugin, and can also be extended to other build environments according to actual needs, with good portability and extensibility.

[0048] As a specific example, when the project is large, initialization can be selectively performed after the build tool's initial compilation or delayed to reduce startup overhead.

[0049] As a specific implementation example, databases, file systems, and other formats can also be considered. The approach can be flexible and adapted to the specific project scale and team habits.

[0050] As a specific implementation, you can use the Watch mode that comes with webpack / vite, or combine it with a separate file monitoring library, such as chokidar, and configure debouncing or batch update processing logic.

[0051] As a specific example, functions such as detecting missing translation keys and verifying multilingual consistency can be broken down into multiple ESLint rules, which can be enabled as needed at different project stages or by different teams.

[0052] As a specific example, in some scenarios, a process can also run independently to monitor the translation files in real time without being strongly bound to the build system; the final result can still be prompted through ESLint.

[0053] Based on the same inventive concept, this application also provides a device for real-time verification of internationalization translation keys based on build tools and ESLint rules, used to implement the aforementioned method for real-time verification of internationalization translation keys based on build tools and ESLint rules. The solution provided by this device is similar to the implementation described in the above method. Therefore, the specific limitations of one or more embodiments of the device for real-time verification of internationalization translation keys based on build tools and ESLint rules provided below can be found in the limitations of the method for real-time verification of internationalization translation keys based on build tools and ESLint rules described above, and will not be repeated here.

[0054] In one exemplary embodiment, a device for real-time verification of internationalization translation keys based on build tools and ESLint rules is provided, comprising: The translation key cache building module is used to automatically scan all internationalized language files under the project's designated path when the project starts, through the build tool plugin, parse and collect all translation keys and related information, and build a translation key cache; the related information includes the corresponding values ​​of translation keys in different language files, file names, timestamps, and hierarchical structure information; The change monitoring module is used to monitor changes to the internationalized language file using the build tool or an independent monitoring library. When a change to the internationalized language file is detected, the changed internationalized language file is re-parsed, and the translation key cache is incrementally updated based on the parsing results. Changes to the internationalized language file include: file addition, modification, or deletion operations. The static analysis module is used to identify statements that call translation functions in the code and extract translation keys from the statements when performing static analysis on the project source code based on ESLint custom verification rules. The real-time verification module compares the extracted translation key with the translation key in the current translation key cache; and outputs verification information based on the comparison result to realize real-time verification of the validity of the translation key.

[0055] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal. The computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is connected to the system bus via the I / O interfaces. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The I / O interfaces of the computer device are used for exchanging information between the processor and external devices. The communication interface of the computer device is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for real-time verification of internationalization translation keys based on build tools and ESLint rules.

[0056] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0057] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0058] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0059] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0060] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).

[0061] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0062] In this application, all actions to acquire signals, information, or data are carried out in compliance with the relevant data protection laws and policies of the country where the location is situated, and with the authorization granted by the owner of the relevant device.

[0063] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0064] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for real-time verification of internationalization translation keys based on build tools and ESLint rules, characterized in that, The method for real-time verification of internationalization translation keys based on build tools and ESLint rules includes: When the project starts, the build tool plugin automatically scans all internationalized language files under the project's set path, parses and collects all translation keys and related information, and builds a translation key cache; the related information includes the corresponding values ​​of translation keys in different language files, file names, timestamps, and hierarchical structure information; The internationalized language file is monitored using the aforementioned build tool or independent monitoring library. When a change in the internationalized language file is detected, the changed internationalized language file is re-parsed, and the translation key cache is incrementally updated based on the parsing results. Changes in the internationalized language file include: file addition, modification, or deletion operations. Based on ESLint's custom validation rules, when performing static analysis on the project's source code, the system identifies statements that call translation functions and extracts the translation keys from those statements. The extracted translation key is compared with the translation key in the current translation key cache; and the verification information is output according to the comparison result to realize the real-time verification of the validity of the translation key.

2. The method for real-time verification of internationalization translation keys based on build tools and ESLint rules according to claim 1, characterized in that, The build tool is either webpack or vite; The internationalized language files include language files in JSON, JS, or YAML formats.

3. The method for real-time verification of internationalization translation keys based on build tools and ESLint rules according to claim 1, characterized in that, The ESLint custom validation rules include: Determine the name of the translation function to be tested; Define cache access methods; these methods include referencing shared memory objects, calling APIs, or reading JSON files. Configure the verification logic and the prompt level.

4. The method for real-time verification of internationalization translation keys based on build tools and ESLint rules according to claim 3, characterized in that, The verification logic includes: translation key missing verification, multilingual consistency verification, spelling error verification, and key name format verification; the prompt levels include: error, warning, or only marking.

5. The method for real-time verification of internationalization translation keys based on build tools and ESLint rules according to claim 1, characterized in that, The process involves using the aforementioned build tool or independent monitoring library to monitor changes to the internationalized language file. When a change is detected, the modified internationalized language file is re-parsed, and the translation key cache is incrementally updated based on the parsing results. This process further includes: When the translation key cache is updated, the ESLint plugin is notified to refresh the cache via inter-process communication or file state change, and the translation key is verified based on the updated translation key cache during the next verification.

6. The method for real-time verification of internationalization translation keys based on build tools and ESLint rules according to claim 1, characterized in that, The method for real-time verification of internationalization translation keys based on build tools and ESLint rules also includes: Embed the real-time validation of translation keys into the lifecycle of the build tool using webpack-plugin or vite-plugin; During the development phase, maintain real-time monitoring and verification; During the production build phase, a full verification is performed; if a critical translation key is missing or multiple languages ​​are out of sync, the build is interrupted.

7. A device for real-time verification of internationalization translation keys based on build tools and ESLint rules, characterized in that, The device for real-time verification of internationalization translation keys based on build tools and ESLint rules includes: The translation key cache building module is used to automatically scan all internationalized language files under the project's designated path when the project starts, through the build tool plugin, parse and collect all translation keys and related information, and build a translation key cache; the related information includes the corresponding values ​​of translation keys in different language files, file names, timestamps, and hierarchical structure information; The change monitoring module is used to monitor changes to the internationalized language file using the build tool or an independent monitoring library. When a change to the internationalized language file is detected, the changed internationalized language file is re-parsed, and the translation key cache is incrementally updated based on the parsing results. Changes to the internationalized language file include: file addition, modification, or deletion operations. The static analysis module is used to identify statements that call translation functions in the code and extract translation keys from the statements when performing static analysis on the project source code based on ESLint custom verification rules. The real-time verification module compares the extracted translation key with the translation key in the current translation key cache; and outputs verification information based on the comparison result to realize real-time verification of the validity of the translation key.

8. A computer device, comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that the processor executes the computer program to implement the method for real-time verification of internationalization translation keys based on build tools and ESLint rules as described in any one of claims 1-6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the method for real-time verification of internationalization translation keys based on build tools and ESLint rules as described in any one of claims 1-6.

10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the method for real-time verification of internationalization translation keys based on build tools and ESLint rules as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Language processing method and device, equipment and storage medium

    CN114398912A

  • System model construction method for formalized verification of interlocking software

    CN115562669A

  • Code interception detection method and device, equipment and storage medium

    CN117421232A

  • International code repair method and device, equipment and program product

    CN118113290A

  • Front-end component detection method, system and equipment and storage medium

    CN118567758A