A method, apparatus, and storage medium for automated verification of the integrity of multilingual translations.
By establishing preset mapping relationships and using general interactive detection technology in the testing environment, the problems of high maintenance costs, high missed detection rates, and low recognition accuracy in front-end multilingual translation automated testing are solved, achieving efficient and accurate multilingual translation integrity detection.
Patent Information
- Application Number
- CN202611104772.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-24
- Publication Date
- 2026-11-10
AI Technical Summary
Existing technologies suffer from high maintenance costs, high missed detection rates, insufficient recognition accuracy, and poor test stability in automated testing of front-end multilingual translation integrity, making it difficult to effectively cover dynamic text content under complex interactions.
By establishing a preset mapping relationship in the test environment, the translated text is forcibly replaced with translation keys. Combined with general interactive detection technology, hover and click operations are performed to scan dynamic text content. The translation key format is matched using regular expressions to generate a detection report.
It achieves low-cost, high-coverage, and accurate multilingual translation integrity detection, effectively identifying untranslated text, reducing false alarm rates, and ensuring test stability and continuity.
Smart Images

Figure CN123070137A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software testing technology, specifically to a method, apparatus, and storage medium for automated verification of the integrity of multilingual translations. Background Technology
[0002] With the globalization of information technology, software products, especially SaaS platforms, typically need to support multiple languages to serve users in different countries and regions. Internationalization (i18n) of front-end applications is a crucial step in achieving multilingual support. Its core function is to replace hard-coded text in the interface with uniquely identified translation keys, and then dynamically map these translation keys to corresponding translated text based on the user's selected language environment at runtime.
[0003] During rapid product iteration, ensuring that all text on all front-end pages is correctly incorporated into the internationalization framework and that no untranslated text is omitted is a challenging quality assurance task. Traditional testing methods mainly rely on manual or traditional automated means. For example, testers manually switch between different language versions and visually inspect each page and element one by one. This approach is inefficient, time-consuming, and prone to oversights when dealing with large-scale applications.
[0004] To improve efficiency, the industry has also tried using UI automation test scripts (such as frameworks like Selenium and Playwright) for verification. Test engineers write scripts for specific page elements, using fixed locators (such as Cascading Style Sheets (CSS) selectors or XPath) to find the elements and assert their text content. However, this method is extremely costly to maintain. Once the front-end interface is redesigned or the Document Object Model (DOM) structure is adjusted, a large number of test scripts will become invalid, requiring significant effort to update them. In addition, some dynamic text hidden behind interactive behaviors (such as mouse hover, form submission, pop-ups, etc.) is difficult to effectively cover by writing general scripts.
[0005] In addition, there are some solutions based on image or text comparison. Screenshot comparison methods identify differences by comparing screenshots of different language versions of the page, but they are easily affected by dynamic business data such as time and order numbers, leading to a large number of false positives. Plain text comparison struggles to effectively distinguish between normal business data text (such as user-inputted Chinese names) and untranslated text that should have been translated but wasn't, resulting in low accuracy. In summary, existing technologies generally suffer from high maintenance costs, high false negative rates, insufficient accuracy, and poor stability under complex interactions. Summary of the Invention
[0006] To address the aforementioned technical problems, this invention provides an automated method, apparatus, and storage medium for verifying the integrity of multilingual translations, aiming to achieve low-cost, high-coverage, and high-accuracy automated detection of the integrity of front-end multilingual translations.
[0007] This invention provides an automated method for verifying the integrity of multilingual translations, comprising the following steps: In the test environment, the multilingual resources of the front-end application are preprocessed to establish a preset mapping relationship, so that when the application runs, the translated text obtained by the translation function is the corresponding translation key. Scan the front-end application interface to obtain the text to be tested. Based on the preset mapping relationship, verify the text to be tested to distinguish between translated text that conforms to the preset mapping relationship and untranslated text that does not conform to the preset mapping relationship. At least one type of preset general interaction detection is performed on the page elements on the front-end application interface to trigger and scan the dynamic text content generated by the interaction; wherein, when the general interaction detection is to perform a click operation on an interactive element, it monitors whether a predefined context change event is triggered, and when the context change event is detected, a state restoration operation is performed to restore the test context to the state before the click operation; The set of translation keys collected in all scanning steps and identified through the translated text is compared with the full list of translation keys for the project to identify uncovered keys that do not appear on the front-end application interface.
[0008] This method transforms ambiguous semantic judgments into precise format checks, and, combined with stable interactive probing, efficiently and accurately identifies translation omissions.
[0009] Furthermore, the step of validating the text to be tested based on the preset mapping relationship includes: matching the text to be tested using a predefined regular expression to determine whether its format conforms to the format of the translation key. This provides a reliable and automated technical means to distinguish between translated and untranslated text.
[0010] In one implementation, the general interaction detection includes hover detection, which involves identifying elements that may have hover tips, triggering their hover events, and scanning the text in newly appearing overlays. This solution can automatically discover and verify dynamic text hidden in hover interactions (such as tooltips and popovers), effectively improving the coverage depth of the test.
[0011] Furthermore, the method also includes: after a click operation, if a new pop-up window is detected, the area of the new pop-up window is locked for incremental scanning, and the new pop-up window is automatically closed after the scan is completed. This solution ensures comprehensive detection of the content of modal dialog boxes, drawers, and other pop-up windows, while automatically closing them restores the page state, ensuring the smooth progress of subsequent tests.
[0012] Optionally, before performing the scan, the method further includes: automatically scrolling down the page to trigger the loading of lazy-loaded content until the page content stops increasing. This step ensures that page content that requires scrolling to load can be fully scanned, avoiding missed detections due to the lazy-loading mechanism.
[0013] Furthermore, the method also includes: summarizing the untranslated text and uncovered keys found in all steps to generate a detection report containing the locations of untranslated text and a list of uncovered keys. This approach presents the detection results in a structured format, providing clear guidance for developers to locate and fix problems.
[0014] In another implementation, the general interaction detection includes state activation detection. The state activation detection method involves identifying components within the page whose states can be switched, and iterating through the components that trigger state switching to scan for dynamic text content triggered by state switching. This approach can cover text content that appears or changes due to changes in page state (such as activating a button after a checkbox is selected).
[0015] Specifically, the switchable state component is a tab component, and the state activation detection method is as follows: identify the tab components within the page, traverse and click each tab, and recursively execute the scanning and general interaction detection after the content of each tab is loaded. This solution can systematically traverse and detect the content of all subviews under the tab component, ensuring the completeness of testing under complex page layouts.
[0016] The present invention also provides an automated verification device for the integrity of multilingual translations, comprising: The preprocessing module is used to preprocess the multilingual resources of the front-end application in the test environment and establish a preset mapping relationship so that the translated text obtained by the translation function at application runtime is the corresponding translation key; The scanning and verification module is used to scan the front-end application interface to obtain the text to be tested, and to verify the text to be tested based on the preset mapping relationship, so as to distinguish the translated text that conforms to the preset mapping relationship and the untranslated text that does not conform to the preset mapping relationship. An interaction detection module is used to perform at least one type of preset general interaction detection on page elements on the front-end application interface to trigger and scan dynamic text content generated by the interaction; wherein, when the general interaction detection is to perform a click operation on an interactive element, the interaction detection module is also used to monitor whether a predefined context change event is triggered, and when the context change event is detected, to perform a state restoration operation to restore the test context to the state before the click operation; The comparison module is used to compare the set of translation keys collected in all scanning steps and identified through the translated text with the full list of translation keys for the project, in order to identify uncovered keys that do not appear on the front-end application interface.
[0017] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in any of the preceding claims.
[0018] Compared with the prior art, the present invention has the following beneficial effects: First, this invention boasts high accuracy and a very low false positive rate. By employing a technique that establishes a pre-defined mapping relationship, the translated text is forcibly replaced with the translation key itself, transforming the verification process from fuzzy semantic comparison to precise string format matching. In this environment, any natural language text that does not conform to the translation key format can be directly identified as untranslated text, fundamentally eliminating interference from dynamic business data.
[0019] Secondly, this invention achieves low cost and high coverage. By incorporating a universal set of interaction detection tools, it replaces the large number of user interface (UI) automation scripts that need to be written and maintained for specific business logic in traditional methods. Regardless of changes in the front-end interface structure, this invention can automatically identify interactive elements and trigger scanning, thereby achieving broad coverage of both static and dynamic content with extremely low maintenance costs.
[0020] Furthermore, this invention possesses deep dynamic content detection capabilities. Overcoming the limitations of traditional static scanning, it can automatically trigger and scan hidden content generated by interactive behaviors such as hovering, form validation, and state switching, including prompts, error messages, dynamic pop-ups, and content under tabs, significantly reducing the risk of missed detections.
[0021] Finally, this invention exhibits strong environmental robustness. By introducing a monitoring mechanism for context changes and a state recovery mechanism for click operations, it effectively prevents test interruptions or deviations from the main test flow caused by unexpected situations such as page jumps or opening new tabs, ensuring the continuity and stability of automated tasks in complex interactive environments. Attached Figure Description
[0022] Figure 1 This is an overall flowchart of an automated verification method for the integrity of multilingual translation provided in an embodiment of the present invention.
[0023] Figure 2 This is a system architecture block diagram of an automated verification device for the integrity of multilingual translation provided in an embodiment of the present invention.
[0024] Figure 3 This is a flowchart of a Tab recursive scan provided for an embodiment.
[0025] Figure 4 An example diagram of an aggregated detection report provided for an embodiment. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the present invention clearer, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.
[0027] This invention aims to address the core pain points of existing automated multilingual front-end testing, including high maintenance costs, high false negative rates due to complex interactions, and low accuracy in distinguishing between untranslated text and normal business data. To achieve this, the core of this invention lies in constructing a special testing environment where the multilingual resources of the front-end application are preprocessed, establishing a pre-defined mapping relationship. This ensures that all translated text obtained through translation functions is no longer the actual translated value, but rather the corresponding translation key itself. This approach transforms the originally ambiguous text verification problem, which requires semantic comparison, into a precise string verification problem based on format matching, thereby achieving self-proof of translation integrity.
[0028] In the context of this invention, some key terms have specific meanings. "Multilingual resources" refers to a dataset in the front-end application used for internationalization (i18n), containing translation keys and corresponding translation text mappings, typically in file format. "Preset mapping" specifically refers to a method in a testing environment where the translation text (Value) in the multilingual resources is forcibly replaced with the corresponding translation key (Key) itself, causing the translation function to return the key instead of the value. "Translation key" is a string used to uniquely identify a piece of text to be translated within the multilingual framework, typically with a specific naming format. "Translated text" is the text displayed on the front-end interface that conforms to the translation key format under the aforementioned preset mapping environment, indicating that the text has been correctly processed by the multilingual framework. "Untranslated text" is natural language text displayed on the front-end interface under the same environment that does not conform to the translation key format; it is typically text not included in the multilingual system.
[0029] Furthermore, "general interaction detection" refers to a set of preset automated interaction strategies that do not depend on specific business logic, used to trigger dynamic content on the page that can only be displayed through user interaction. "Context change events" refer to events that cause the test focus to deviate from the current page during automated interaction, such as page route redirection or opening a new browser tab. "State restoration operation" is the operation that restores the browser state (such as URL, page) to the state before the interaction after detecting a context change event. Through the combination of the above technical means, this invention can achieve high coverage and deep dynamic content detection of the complete multilingual translation of front-end applications with extremely low false positive rates and maintenance costs, while ensuring the robustness of automated tasks.
[0030] This invention provides an automated method for verifying the integrity of multilingual translations, such as... Figure 1 As shown, it includes the following steps: Step S101: In the test environment, preprocess the multilingual resources of the front-end application and establish a preset mapping relationship so that when the application runs, the translated text obtained by the translation function is a translation key with a preset mapping relationship with the translated text.
[0031] Step S102: Scan the front-end application interface to obtain the text to be tested. Based on the preset mapping relationship, verify the text to be tested to distinguish between translated text that conforms to the preset mapping relationship and untranslated text that does not conform to the preset mapping relationship.
[0032] Step S103: Perform at least one type of preset general interaction detection on the page elements on the front-end application interface to trigger and scan the dynamic text content generated by the interaction; wherein, when the general interaction detection is to perform a click operation on an interactive element, monitor whether a predefined context change event is triggered, and when a context change event is detected, perform a state restoration operation to restore the test context to the state before the click operation.
[0033] Step S104: Compare the set of translation keys collected in all scanning steps and identified through the translated text with the full list of translation keys in the project to identify uncovered keys that do not appear on the front-end application interface.
[0034] In a preferred embodiment, to improve the accuracy and flexibility of the verification, the step of verifying the text to be tested based on the preset mapping relationship specifically includes: matching the text to be tested using a predefined regular expression to determine whether its format conforms to the format of the translation key. For example, a regular expression can be defined such as ' / ^[a-zA-Z][a-zA-Z0-9_](\.[a-zA-Z][a-zA-Z0-9_]){1,}$ / ', which matches identifier strings that begin with a letter, are separated by periods, and contain at least two segments. Through configurable regular expressions, this method can adapt to the naming conventions of different project teams for translation keys, enhancing the versatility of the solution.
[0035] To improve coverage of hidden content, the general interaction detection can include hover detection. Hover detection specifically involves: first, identifying elements on the page that may have hover tips, such as elements with a 'title' attribute, elements with a 'aria-haspopup' attribute, or elements whose text content displays an ellipsis due to overflow; then, an automated program triggers their hover events (such as 'mouseenter'); finally, after waiting for a preset time (e.g., 500 milliseconds to 2000 milliseconds), scanning the text in newly appearing overlays (such as tooltips or popovers). This design allows tooltips that would otherwise require manual hovering to be seen to be automatically included in the validation scope.
[0036] When a click operation is performed, the page often pops up new views such as modal dialog boxes or drawers. To handle this situation, this method further includes: after a click operation, if a new pop-up is detected, the DOM area of the new pop-up is locked for incremental scanning, and the new pop-up is automatically closed after the scan is complete. This "scan first, close later" strategy ensures that multilingual text within the pop-up is not missed, and by automatically performing state restoration operations, subsequent general interaction probing can continue in the original page context, ensuring the integrity of the traversal.
[0037] Modern front-end applications commonly employ lazy loading to optimize initial screen performance, meaning page content is dynamically loaded as the user scrolls. To ensure the completeness of the scan, this method includes a preprocessing step before execution: automatically scrolling the page downwards to trigger the loading of lazy-loaded content until no more content is added. Specifically, scrolling downwards in increments of 80% of the viewport height, checking the number of DOM nodes after each scroll, until the bottom of the page is reached. This step ensures that all scrollable content is presented in the DOM before the actual scan begins, avoiding missed detections due to lazy loading.
[0038] To provide users with clear and actionable feedback, this method also includes: summarizing the untranslated text and uncovered keys found in all steps to generate a detection report containing a list of untranslated text locations and uncovered keys. Figure 4 As shown, this report can include coverage statistics for translated keys, a detailed list of uncovered keys (grouped by module), and a list of untranslated text, along with its specific DOM location on the page (e.g., XPath). Such reports provide developers with direct guidance for quickly locating and fixing problems.
[0039] In addition to hover detection, the general interaction detection can also include state activation detection. State activation detection involves identifying components within the page whose states can be toggled (such as checkboxes, radio buttons, switches, etc.) and iterating through the components that trigger state toggling to scan dynamic text content triggered by state toggling. For example, by automatically checking certain checkboxes in a list, a "bulk delete" button that was originally disabled can be activated, allowing its text to be scanned and verified. This strategy effectively covers elements that depend on specific page states to be displayed or activated.
[0040] As a specific and important application scenario of state activation detection, when the switchable state component is a tab component, the state activation detection specifically manifests as: identifying tab components within the page and iterating through and clicking each tab. For example... Figure 3 As shown, after the content of each tab is loaded, the scan and the general interaction probe are recursively performed. This recursive scanning mechanism ensures that the content of all subviews in the multi-view interface is fully covered. To prevent infinite recursion, a maximum recursion depth can be set, such as 10 levels.
[0041] Accordingly, the present invention also provides an automated verification device for the integrity of multilingual translations. For example... Figure 2As shown, the device includes a preprocessing module 101, a scanning verification module 102, an interactive detection module 103, and a comparison module 104. These modules work together to implement the aforementioned method.
[0042] Specifically, the preprocessing module 101 is used to preprocess the multilingual resources of the front-end application in the test environment, establishing a preset mapping relationship so that the translated text obtained through the translation function at application runtime is the corresponding translation key. The scanning and verification module 102 is connected to the preprocessing module 101 and is used to scan the front-end application interface to obtain the text to be tested, and to verify the text to be tested based on the preset mapping relationship, so as to distinguish the translated text that conforms to the preset mapping relationship and the untranslated text that does not conform to the preset mapping relationship. The interaction detection module 103 is used to perform at least one type of preset general interaction detection on the page elements on the front-end application interface to trigger and scan the dynamic text content generated by the interaction. When the general interaction detection is to perform a click operation on an interactive element, the interaction detection module 103 is also used to monitor whether a predefined context change event is triggered, and when the context change event is detected, a state restoration operation is performed to restore the test context to the state before the click operation. Finally, the comparison module 104 is used to compare the set of translation keys collected in all scanning steps and identified through the translated text with the full list of translation keys of the project, in order to identify uncovered keys that do not appear on the front-end application interface.
[0043] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in the foregoing embodiments. The medium can be any electronic, magnetic, optical, or other physical device capable of storing program code, such as a read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0044] To more clearly illustrate the technical solution of the present invention, a detailed description is provided below with reference to specific embodiments. A specific method embodiment may include the following steps.
[0045] First, step S1 is executed to build the key-value injection test environment. The core of this step is to change the mapping relationship of multilingual resources, i.e., to establish a pre-defined mapping relationship. For example, an original multilingual resource file might contain the mapping '{'btn.submit': 'Submit'}'. Through this step, this mapping relationship is dynamically modified in the test environment to '{'btn.submit': 'btn.submit'}'. This modification can be achieved in several ways, such as directly modifying the output file during the front-end bundling and building phase (e.g., Webpack's loader), or overriding the i18n framework's translation function at browser runtime using a "monkey patch" to make it directly return the passed-in key. After processing, the "Submit" button that should have been displayed on the page will now display its translated key "btn.submit". If there is unprocessed text on the page, such as "Delete Permissions", it will remain displayed as is, becoming untranslated text. This contrast eliminates the need for complex semantic judgments in subsequent validation. For example, when detecting a confirmation delete pop-up, the pop-up title is correctly displayed as the translated key 'spBsMain.order.list.confirm_delete', but the pop-up also contains the text "delete permission". Since this text does not conform to the translated key format, the system can directly determine it as untranslated text, thus achieving the ability to detect both translated and untranslated text on the same page.
[0046] Next, step S2 initializes the smart scan controller. This step aims to create a stable and ready environment for automated scanning. Specifically, the controller launches an automated browser instance (such as Playwright or Puppeteer) and loads the target page. Then, it performs a page stabilization wait, the criteria of which can be a combination of conditions, such as: the DOMContentLoaded event has been triggered, there have been no new network requests for 2 consecutive seconds, the document's 'readyState' is 'complete', and loading animation elements (such as spinners) on the page have disappeared. The page is considered stable only after all conditions are met. In addition, the controller also implements a lazy loading automatic scrolling mechanism, scrolling down from the top of the page in steps of 80% of the viewport height, waiting 300 milliseconds after each scroll until the number of DOM nodes stops increasing, ensuring that all lazy-loaded content has been loaded. At the same time, a maximum recursive scan depth, such as 10 layers, can be set to prevent subsequent steps from getting stuck in an infinite loop.
[0047] Next, step S3 performs a full scan of the static content. After the page stabilizes, this step begins traversing the current page's DOM tree to extract all potential text content. This includes not only visible text nodes, but also the 'placeholder' attribute of input fields, accessibility text such as the 'aria-label' attribute, and text within the 'title' and 'alt' attributes. During extraction, the specific strategy for filtering invisible elements is as follows: elements with 'display: none' or 'visibility: hidden' are excluded; elements with zero width and height are excluded; however, elements with 'aria-hidden="true"' are retained because they may contain accessibility text that requires validation. For each extracted text segment, a predefined regular expression is used for format matching. Successfully matched text is identified as translated text, and its content (i.e., the translation key) is collected in the overridden key set; unmatched natural language text is recorded as untranslated text.
[0048] Next, step S4 executes feature-based intelligent interaction. This step involves general interaction detection, designed to trigger dynamic content by simulating user interaction. Specifically, it can be divided into several detection strategies. The first is hover detection, which identifies and triggers the 'mouseenter' event of elements on the page and employs a dynamic waiting strategy: after triggering, it waits 100 milliseconds to check if a new overlay element appears in the DOM; if not, it continues to wait for up to 2 seconds (checking every 200 milliseconds). The criteria for overlay detection are that the newly appearing element has the 'role="tooltip"' attribute, belongs to a common overlay container class (such as '.ant-tooltip'), or has a high 'z-index' value. The second is form triggering, where abnormal input is applied to form input controls to trigger validation logic. It identifies input controls and triggers validation rules through a series of operations, such as: for text input boxes, entering special character combinations (such as '!@#$%^'); for numeric input boxes, entering non-numeric characters; for required fields, clearing the content and defocusing. Then, it scans dynamically generated error message text. The third type is state activation, which identifies and clicks checkboxes or radio buttons on the page to activate associated, previously disabled elements and scans for newly appearing text on these elements. To avoid uncontrollable page states, when there are more than 10 similar controls on the same page, a pseudo-random sampling strategy can be used to select a subset (e.g., 5) to perform click operations.
[0049] After static scanning and basic interaction, step S5 performs a deep click traversal without redirection. This step explores deeper interactions by systematically clicking all interactive elements on the page (such as buttons and links). Before each click, a state snapshot step is performed, recording information such as the current page URL, scroll position, and number of visible pop-ups, forming a state snapshot data structure, such as '{"url": "...", "scrollY": ..., "modalCount": ...}'. Then, the action execution and listening step is performed, i.e., clicking an element while simultaneously listening for context change events. Finally, in the rollback and scanning steps, the processing is based on the monitoring results: if the URL changes (i.e., a context change event occurs), a state restoration operation (such as browser rollback) is immediately performed to restore the current state; if a new pop-up is detected by comparing the number and identifiers of DOM elements before and after the click, the new pop-up is locked for incremental scanning, and then an attempt is made to close it using a multi-level rollback scheme, for example: first click the close button in the pop-up, then click the overlay, and then try to send the ESC keyboard event; if all fail, browser rollback is performed; if there is no change, the process continues to the next element. This mechanism ensures that the scanning task always focuses on the current page and will not be interrupted by unexpected redirects.
[0050] For complex pages containing multiple views, step S6, recursive scanning of the multiple view tabs, also needs to be performed. For example... Figure 3 As shown, this step specifically handles the tab components. It first identifies the tab components on the page, then iterates through and clicks on each tab option. After each switch, the system waits for the content panel corresponding to the new tab to finish rendering using a rendering confirmation mechanism. For example, it uses 'MutationObserver' to detect DOM stability (no node changes for 500 consecutive milliseconds), then treats that content panel as an independent "child page" and recursively calls the complete scanning logic from steps S3 to S5. In this way, it ensures that all different view content displayed during tab switching is fully validated.
[0051] Finally, step S7 generates an aggregated detection report. This step summarizes the results of all the preceding scanning activities. It compares the collected set of covered translation keys with the full list of translation keys in the project, calculating the translation key coverage rate using the formula: Translation Key Coverage Rate = (Number of Covered Keys / Total Number of Keys in All Multilingual Resources) × 100%. Figure 4As shown, the final generated report clearly displays coverage statistics, a list of uncovered keys grouped by module, and a list of untranslated text and their locations in the DOM. The report can also include a list of JavaScript runtime errors captured during the scan and screenshots of abnormal pages, providing developers with comprehensive quality feedback. For suspected untranslated text, confidence levels can be assigned based on its length; for example, natural language sentences longer than 10 characters are marked as high confidence.
[0052] The following is combined Figure 2 An embodiment of the device of the present invention will be described. Based on the foregoing embodiments, the device may further include an input module and an output module.
[0053] The input module provides a configuration management interface, supporting the input of test parameters via configuration files (such as JSON / YAML format) or command-line arguments. These parameters include, but are not limited to: a list of Uniform Resource Locators (URLs) for the page to be tested, paths to multilingual resource files, a blacklist of URLs or element selectors to prevent destructive operations, maximum recursion depth, and page stability timeout.
[0054] The preprocessing module 101 receives the configuration from the input module and internally includes a key-value injection submodule and a browser initialization submodule. The key-value injection submodule reads the original multilingual resource package, performs key-value replacement as described in step S1, and generates the injected resource package file or runtime interception script. The browser initialization submodule starts the corresponding automated browser engine (such as Chromium) according to the configuration, configures the browser context (such as window size and language), and loads the target page.
[0055] The scanning and verification module 102 is responsible for scanning the interface to obtain text and performing verification. It encapsulates DOM traversal logic and translation key matching logic. Internally, it maintains a set of covered keys (such as a Set data structure) for deduplication and a list of untranslated text, recording the content, DOM path (XPath), and confidence level of each text segment.
[0056] The interaction detection module 103 is responsible for performing general interaction detection. It integrates an interaction scheduler and a click processor. The interaction scheduler includes hover triggers, form triggers, and state activation triggers, which execute various basic interaction strategies and manage the execution order to avoid concurrency conflicts. The click processor performs anti-jump deep click traversal, and internally includes a state snapshot submodule (for capturing the page state before a click), an action listening submodule (for listening to events such as route changes and pop-up creation after a click), and a back submodule (for performing state restoration operations such as browser back and closing pop-ups based on the listening results). In addition, the device includes a recursive scan controller for identifying tab components, maintaining a recursion depth counter, and coordinating the interaction detection module to perform a complete scan process for each subview.
[0057] The comparison module 104 is responsible for performing a difference operation between the set of covered translation keys collected by the scan verification module 102 in all scanning steps and the list of full translation keys of the project obtained from the input module, in order to identify the uncovered keys that do not appear on the interface.
[0058] The output module summarizes all untranslated text and uncovered keys found in all steps, generating a detection report containing the locations of untranslated text and a list of uncovered keys. The report supports multiple formats such as HTML and JSON, can include visual coverage charts, and automatically saves screenshots of pages where issues were found, providing developers with clear remediation guidance.
[0059] It should be understood that the scope of protection of this invention is not limited to the above embodiments. Without departing from the spirit and scope of this invention, those skilled in the art can make various modifications and variations to the above embodiments. For example, in addition to build-time replacement and runtime interception, the implementation of establishing the preset mapping relationship in step S1 can also use Service Worker to intercept HTTP requests to dynamically replace multilingual resource files, or replace the translation method of the global i18n instance before page loading through Mock data injection.
[0060] Similarly, the browser engine used to perform automated operations can be any of the major browser automation tools besides Playwright, such as Puppeteer, Selenium WebDriver, or Cypress. These tools provide similar underlying capabilities that can be used to implement the core logic of this invention.
[0061] For the general interactive probe in step S4, there are several alternative implementations. For example, hover probes can be implemented by directly dispatching the JavaScript event 'element.dispatchEvent(new MouseEvent('mouseenter'))' instead of simulating physical mouse movement; form triggers can be implemented by directly calling the HTML5 'reportValidity()' application programming interface (API) to trigger the browser's built-in validation prompts.
[0062] Regarding the state restoration mechanism in step S5, in addition to using browser history to go back, you can also consider using 'history.pushState' for more granular state management, or isolate the click operation in a separate 'iframe' to avoid any impact on the main page state.
[0063] Finally, the regular expression used to match the translation key is not fixed; it can be configured to allow users to customize it according to their project's specific naming conventions (such as camelCase, underscore, etc.), which makes the method and apparatus of this invention more widely applicable. All these equivalent modifications and variations should be included within the scope of protection of this invention.
[0064] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for automated verification of the integrity of multilingual translations, characterized in that, Includes the following steps: In the test environment, the multilingual resources of the front-end application are preprocessed so that when the application runs, the translated text obtained by the translation function is a translation key with a preset mapping relationship with the translated text; Scan the front-end application interface to obtain the text to be tested; Based on the preset mapping relationship, the text to be tested is verified to distinguish between translated text that conforms to the preset mapping relationship and untranslated text that does not conform to the preset mapping relationship; At least one type of preset general interaction detection is performed on the page elements on the front-end application interface to trigger and scan the dynamic text content generated by the interaction; wherein, when the general interaction detection is to perform a click operation on an interactive element, it monitors whether a predefined context change event is triggered, and when the context change event is detected, a state restoration operation is performed to restore the test context to the state before the click operation; The set of translation keys collected in all scanning steps and identified through the translated text is compared with the full list of translation keys for the project to identify uncovered keys that do not appear on the front-end application interface.
2. The automated verification method for the integrity of multilingual translation according to claim 1, characterized in that, The step of validating the text to be tested based on the preset mapping relationship includes: matching the text to be tested using a predefined regular expression to determine whether its format conforms to the format of the translation key.
3. The automated verification method for the integrity of multilingual translation according to claim 1, characterized in that, The general interactive detection includes hover detection, which is performed by identifying elements that may have hover prompts, triggering their hover events, and scanning the text in newly appearing overlays.
4. The automated verification method for the integrity of multilingual translation according to claim 1, characterized in that, The method further includes: after a click operation is performed, if a new pop-up window is detected, the area of the new pop-up window is locked for incremental scanning, and the new pop-up window is automatically closed after the scanning is completed.
5. The automated verification method for the integrity of multilingual translation according to claim 1, characterized in that, Before performing the scan, the method further includes: automatically scrolling the page down to trigger the loading of lazy-loaded content until the page content no longer increases.
6. The automated verification method for the integrity of multilingual translation according to claim 1, characterized in that, The method further includes: summarizing the untranslated text and the uncovered keys found in all steps, and generating a detection report containing the locations of untranslated text and a list of uncovered keys.
7. The automated verification method for the integrity of multilingual translation according to claim 1, characterized in that, The general interaction detection includes state activation detection. The detection method of state activation detection is as follows: identify components with switchable states within the page, and traverse the state switching that triggers the components to scan the dynamic text content triggered by the state switching.
8. The automated verification method for the integrity of multilingual translation according to claim 7, characterized in that, The switchable state component is a tab component. The detection method of the state activation detection is as follows: identify the tab component in the page, and traverse and click each tab. After the content of each tab is loaded, recursively execute the scanning and the general interaction detection.
9. An automated verification device for the integrity of multilingual translations, characterized in that, include: The preprocessing module is used to preprocess the multilingual resources of the front-end application in the test environment, so that when the application runs, the translated text obtained by the translation function is a translation key with a preset mapping relationship with the translated text; The scanning and verification module is used to scan the front-end application interface to obtain the text to be tested, and to verify the text to be tested based on the preset mapping relationship, so as to distinguish the translated text that conforms to the preset mapping relationship and the untranslated text that does not conform to the preset mapping relationship. An interaction detection module is used to perform at least one type of preset general interaction detection on page elements on the front-end application interface to trigger and scan dynamic text content generated by the interaction; wherein, when the general interaction detection is to perform a click operation on an interactive element, the interaction detection module is also used to monitor whether a predefined context change event is triggered, and when the context change event is detected, to perform a state restoration operation to restore the test context to the state before the click operation; The comparison module is used to compare the set of translation keys collected in all scanning steps and identified through the translated text with the full list of translation keys for the project, in order to identify uncovered keys that do not appear on the front-end application interface.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 8.
