A multi-language front-end resource automatic construction method and system based on a construction stage

By automatically identifying and translating text content during the front-end build phase, generating multilingual front-end resources and synchronously updating language packs, the high maintenance cost and low loading efficiency of multilingual processing in existing technologies are solved, realizing automated multilingual build and stable access for large-scale front-end applications.

CN121638279BActive Publication Date: 2026-06-02SHANGHAI FANFANLANG TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202610155073.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-02-04
Publication Date
2026-06-02
Estimated Expiration
2046-02-04

AI Technical Summary

Technical Problem

Existing runtime-based multilingual processing solutions for large-scale front-end applications suffer from problems such as high text maintenance costs, large language resource file sizes affecting loading efficiency, and difficulty in automatically identifying and processing text content changes during the build phase.

Method used

Configure the target language type set during the front-end build phase, generate multilingual front-end resources through text content recognition, annotation, translation and replacement, and update the language pack synchronously after the build is completed, reducing manual maintenance and language loading operations during the runtime phase.

Benefits of technology

It enables automated construction of multilingual front-end resources, reduces developer dependence, improves the automation level of the construction process and the accuracy of language updates, and enhances page loading stability and system maintainability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121638279B_ABST
    Figure CN121638279B_ABST
Patent Text Reader

Abstract

The application provides a kind of multilingual front-end resource automatic construction method and system based on construction stage, method includes: in front-end construction stage, configuration target language type set and main language type, and target language type set is executed cyclic construction processing to;In cyclic construction processing, when target language type is different from main language type, the text content in front-end source code is scanned and identified, generates and labels text mark, based on text mark, from target language type corresponding language package, target language text is obtained, and target language text is replaced with corresponding text content, and the text content that is not completed replacement processing is recorded as to-be-processed text;Call translation interface to execute translation processing to to-be-processed text, generate corresponding translation text, based on translation text, corresponding text content is executed replacement processing, and according to the text mark of to-be-processed text, translation text is added to target language type corresponding language package.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method and system for automatically building multilingual front-end resources based on the build phase. Background Technology

[0002] As the scale of Web / H5 applications continues to expand, the demand for multilingual capabilities in front-end systems is increasing for globalized businesses. Existing technologies typically employ runtime-based multilingual processing solutions, such as i18n (internationalization) technology. This involves introducing language identifiers into the front-end source code and loading the corresponding language resource files during system runtime to achieve multilingual display of page text.

[0003] This type of runtime-based multilingual solution has a certain degree of flexibility and versatility in small and medium-sized applications, but in actual production environments, especially in large-scale front-end applications with a large number of modules, complex page structures, and frequent version iterations, it still has certain objective limitations.

[0004] For example, on the one hand, the correspondence between multilingual text and front-end source code usually needs to be maintained manually. Adding or adjusting the text often requires developers to modify the language identifiers and corresponding language resources simultaneously, which is costly and can easily lead to display errors due to omissions or inconsistencies.

[0005] On the other hand, existing multilingual solutions typically focus on loading language resources during the runtime phase, lacking the ability to automatically identify and process changes in text content during the build phase. This makes it difficult to distinguish between newly added text and existing text, and also hinders the implementation of incremental updates based on differences.

[0006] Furthermore, as business functions continue to expand, the size of language resource files continues to grow. Loading complete language resources during runtime may have a certain impact on the efficiency of front-end resource loading, which is not conducive to improving page access performance.

[0007] Therefore, there is a need to provide a method and system for automatically building multilingual front-end resources based on the build phase to solve the above problems. Summary of the Invention

[0008] This invention addresses the problems and shortcomings of existing technologies by providing a method and system for automatically building multilingual front-end resources based on the build phase.

[0009] The present invention solves the above-mentioned technical problems through the following technical solution:

[0010] This invention provides an automatic construction method for multilingual front-end resources based on the build phase, the method comprising:

[0011] The configuration of multi-language build parameters and the control of loop build are as follows: During the front-end build phase, the target language type set and the main language type are configured, and loop build processing is performed on the front-end resources corresponding to each target language type in the target language type set;

[0012] In the text content recognition and replacement process, when the target language type is different from the main language type, the text content in the front-end source code is scanned and recognized, and a text identifier corresponding to the text content is generated and labeled. Based on the text identifier, the target language text is obtained from the language pack corresponding to the target language type, and the target language text is used to replace the corresponding text content in the front-end source code. Text content that has not been replaced is recorded as text to be processed.

[0013] The process involves translating the text to be processed by calling a translation interface to generate translated text corresponding to the target language type. Based on the translated text, the corresponding text content in the front-end source code is replaced. And according to the text identifier of the text to be processed, the translated text is added to the language pack corresponding to the target language type.

[0014] Preferably, the configuration of the multilingual build parameters and the control of the loop build process include:

[0015] During the front-end building phase, the target language type set is configured to indicate the language types of the multilingual front-end resources to be generated;

[0016] The main language type is determined based on the original language type used in the front-end source code;

[0017] Perform a loop construction process on the target language type set, the loop construction process including:

[0018] Each target language type in the target language type set is iterated through one by one, and each target language type is compared with the main language type;

[0019] When the target language type is the same as the main language type, the build process is directly executed based on the front-end source code to generate the front-end resources corresponding to the main language type.

[0020] When the target language type is different from the main language type, a language pack corresponding to the target language type is obtained from the static resource server, and a build process is performed based on the language pack to generate front-end resources corresponding to the target language type.

[0021] Preferably, the text content recognition and replacement processing includes:

[0022] In the loop construction process, when the target language type is different from the main language type, the text content of the page files and component files in the front-end source code is scanned and identified, and text identifiers corresponding to the text content are generated and labeled.

[0023] The text identifier is matched with the text identifier in the language pack corresponding to the target language type;

[0024] When the language pack contains target language text corresponding to the text identifier, the target language text is used to replace the corresponding text content in the front-end source code.

[0025] When the target language text corresponding to the text identifier does not exist in the language pack, the corresponding text content in the front-end source code is recorded as the text to be processed.

[0026] Preferably, the translation of the text to be processed includes:

[0027] Add the text to be processed to the text set;

[0028] The translation interface is called in batches to perform translation processing on the texts in the set of texts to be processed, and the texts to be processed are translated into target language translated text.

[0029] When the translation process is successful, based on the text identifier, the target language translated text is saved as the translated text corresponding to the text to be processed to the translated text set;

[0030] When the translation process fails, the text to be processed is saved as the corresponding translated text to the translated text set based on the text identifier.

[0031] After all the text to be processed in the text to be processed set has been translated, the text to be processed set is traversed one by one, and the corresponding text content in the front-end source code is replaced with the translated text in the text to be processed set based on the text identifier;

[0032] Based on the text identifier, all translated texts in the translated text set are added to the language pack corresponding to the target language type.

[0033] Preferably, the automatic construction method further includes:

[0034] After the front-end construction phase is completed, the language packs corresponding to the target language type generated in the front-end construction phase are compared with the corresponding language packs stored in the static resource server, and the language packs in the static resource server are updated based on the comparison results.

[0035] Preferably, the text content recognition and replacement processing further includes:

[0036] Pre-defined special text content will not be replaced or translated. The special text content includes file names and text content marked as not requiring translation.

[0037] Preferably, the method generates independent front-end resources for each target language type in the target language type set, each corresponding to a different target language type.

[0038] During system operation, based on the current language type selection result, the system directly accesses the front-end resources corresponding to the current language type to present the front-end page corresponding to the current language type.

[0039] This invention also provides an automatic multilingual front-end resource building system based on the build phase, the system comprising:

[0040] The multi-language build parameter configuration and loop build control module configures the target language type set and the main language type during the front-end build phase, and performs loop build processing for the front-end resources corresponding to each target language type in the target language type set.

[0041] In the loop construction process, when the target language type is different from the main language type, the text content recognition and replacement processing module scans and recognizes the text content in the front-end source code, generates and marks the text identifier corresponding to the text content, obtains the target language text from the language pack corresponding to the target language type based on the text identifier, and replaces the corresponding text content in the front-end source code with the target language text. The text content that has not been replaced is recorded as text to be processed.

[0042] The translation module for the text to be processed calls the translation interface to perform translation processing on the text to be processed, generates translated text corresponding to the target language type, performs replacement processing on the corresponding text content in the front-end source code based on the translated text, and adds the translated text to the language pack corresponding to the target language type according to the text identifier of the text to be processed;

[0043] After the front-end construction phase is completed, the language pack update module compares the language pack corresponding to the target language type generated in the front-end construction phase with the corresponding language pack stored in the static resource server, and performs add / update processing on the language pack in the static resource server based on the comparison results.

[0044] Compared with the prior art, the technical solution of the embodiments of the present invention has the following beneficial effects:

[0045] This invention provides an automatic multilingual front-end resource construction method and system based on the build phase. This method identifies, matches, and translates multilingual text content during the front-end construction phase, and completes text replacement and language pack supplementation during the construction process, enabling the automatic generation of multilingual front-end resources during the construction phase. Compared with existing technologies that rely on loading language resources during the runtime phase and require developers to manually maintain text and language identifiers, this invention reduces the intrusion of multilingual processing on business code, avoids the problem of frequent code modifications due to text adjustments, thereby reducing the dependence of multilingual text maintenance on developers and improving the automation level of the multilingual construction process. It is suitable for large-scale H5 projects with many pages, complex modules, and frequent iterations.

[0046] Furthermore, this invention generates build artifacts for front-end resources corresponding to different languages ​​by configuring a set of target language types and performing a cyclical build process. Through a text identification mechanism, it achieves automatic matching and difference recognition of text content, performing translation processing only on newly added or unmatched text, and incrementally supplementing the translation results into the corresponding language pack. Simultaneously, after the build is completed, the language pack is updated and synchronized to ensure that the language resources remain consistent with the build result. This approach avoids the problems of overall language pack reconstruction, manual comparison, and repeated maintenance in existing technologies, improves the accuracy and timeliness of multilingual updates, and reduces runtime language loading and replacement operations by directly accessing the front-end resources of the corresponding language during system operation, thus improving page loading stability.

[0047] Furthermore, this invention modularizes functional modules such as multilingual build parameter configuration, text content recognition and replacement, text translation, and language pack updates, enabling unified management and execution of the multilingual processing workflow at the system level. The system has a clear structure and well-defined functions, facilitating integration and deployment within existing front-end build systems, reducing the impact of multilingual capabilities on existing business systems, and improving the overall system's maintainability and scalability. Attached Figure Description

[0048] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0049] Figure 1 A flowchart illustrating an embodiment of the present invention for an automatic multilingual front-end resource construction method based on the construction phase;

[0050] Figure 2 This is a schematic diagram of the structure of an automatic multilingual front-end resource building system based on the build phase, provided as an embodiment of the present invention.

[0051] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0052] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0053] This invention provides a method and system for automatically building multilingual front-end resources based on the build phase, which is suitable for multilingual build scenarios of large-scale H5 projects.

[0054] This invention automatically generates multilingual front-end resources by automatically identifying the text content in page and component files during the front-end construction phase, and combining it with difference recognition, automatic translation, and incremental language pack update mechanisms. This solves the problems in existing technologies, such as the heavy reliance on developers for multilingual copy maintenance, the need to modify code for copy updates, the high cost of manual language pack maintenance, and the impact of loading language resources on access performance during runtime. Without increasing the burden on front-end development, this invention achieves automated construction and stable access to multilingual pages.

[0055] Based on the problems existing in the current technology, such as Figure 1 As shown, this invention provides an automatic construction method for multilingual front-end resources based on the construction phase, the method comprising:

[0056] Step S101: Configuration of multi-language build parameters and control of loop build. In the front-end build stage, configure the target language type set and the main language type, and perform loop build processing for the front-end resources corresponding to each target language type in the target language type set.

[0057] This step involves configuring multilingual build parameters and controlling loop builds, including:

[0058] During the front-end build phase, the target language type set is configured to indicate the language types of the multilingual front-end resources to be generated. The target language type set includes, for example, Chinese [zh], English [en0], Traditional Chinese [zh-CHT], Indonesian [id], etc.

[0059] It should be noted that the front-end build phase refers to the stage after the front-end source code is written and before the page is deployed and accessible to clients. During this stage, the front-end build system parses and processes the front-end source code to generate front-end resource files that can be directly loaded by the browser.

[0060] The main language type is determined based on the original language type used in the front-end source code.

[0061] Perform a loop construction process on the target language type set, the loop construction process including:

[0062] Each target language type in the target language type set is iterated through one by one, and each target language type is compared with the main language type.

[0063] When the target language type is the same as the main language type, the build process is directly executed based on the front-end source code to generate the front-end resources corresponding to the main language type.

[0064] It should be noted that when the target language type is the same as the main language type, directly performing the build process means that without performing language pack matching, text content replacement and translation, the front-end source code is built according to the preset front-end build process to generate the front-end resources corresponding to the main language type.

[0065] When the target language type is different from the main language type, a language pack corresponding to the target language type is obtained from the static resource server, and a build process is performed based on the language pack to generate front-end resources corresponding to the target language type.

[0066] In practice, when the target language type differs from the primary language type, a static JSON language pack (LanguagePack) from the static resource server (CDN server) is downloaded to the local machine to replace the corresponding text content in the front-end source code. Each language pack corresponding to the target language type contains a map: {originWord:translateWord}.

[0067] Step S102: Text content recognition and replacement processing. In the loop construction process, when the target language type is different from the main language type, the text content in the front-end source code is scanned and recognized, and a text identifier corresponding to the text content is generated and labeled. Based on the text identifier, the target language text is obtained from the language pack corresponding to the target language type, and the target language text is used to replace the corresponding text content in the front-end source code. The text content that has not been replaced is recorded as text to be processed.

[0068] In this step, text content recognition and replacement processing includes:

[0069] In the loop-based build process, when the target language type differs from the main language type, the text content of page files and component files in the front-end source code is scanned and identified, generating and labeling text identifiers corresponding to the text content. These text identifiers are unique within the same front-end build process and are used to distinguish different text content.

[0070] The text identifier is matched with the text identifier in the language pack corresponding to the target language type.

[0071] When the language pack contains target language text corresponding to the text identifier, the target language text is used to replace the corresponding text content in the front-end source code.

[0072] When the target language text corresponding to the text identifier does not exist in the language pack, the corresponding text content in the front-end source code is recorded as the text to be processed.

[0073] This step also includes not performing replacement or translation processing on preset special text content, which includes file names and text content marked as not requiring translation.

[0074] For example, text content containing image filenames such as "image_name1.png" and "image_name2.jpg" will not be replaced.

[0075] During the translation of the text to be processed, if some content does not need to be translated, then the comment " / / language-ignore" needs to be added. When the text content containing this content is scanned, it will not be translated.

[0076] Step S103: Translation of the text to be processed. The translation interface is called to perform translation processing on the text to be processed, generating translated text corresponding to the target language type. Based on the translated text, the corresponding text content in the front-end source code is replaced. According to the text identifier of the text to be processed, the translated text is added to the language pack corresponding to the target language type.

[0077] In this step, the translation of the text to be processed includes:

[0078] Add the text to be processed to the text set.

[0079] The translation interface is called in batches to perform translation processing on the texts in the set of texts to be processed, and the texts to be processed are translated into target language translated text.

[0080] It should be noted that when translating the text to be processed, the translation interface has a limit on the number of texts that can be processed in a single call. Therefore, the text to be processed is divided into batches according to a preset capacity limit, and each batch of text to be processed is sent to the translation interface for translation. The order and quantity of the text to be translated in each batch are consistent with the order and quantity of the text to be processed, so that the translated text can accurately correspond to and replace the corresponding text content in the front-end source code.

[0081] When the translation process is successful, based on the text identifier, the target language translated text is saved as the translated text corresponding to the text to be processed to the translated text set.

[0082] When the translation process fails, the text to be processed is saved as the corresponding translated text to the translation text collection based on the text identifier. It should be noted that saving the text content of the text to be processed as translated text to the translation text collection in the event of translation failure is intended to ensure that the front-end building process can continue to execute when the translation interface is abnormal or unavailable, thus avoiding interruption of the front-end building process due to translation failure.

[0083] Once all texts in the text set to be processed have been translated, the translated text set is iterated through one by one, and based on the text identifier, the translated texts in the translated text set are used to replace the corresponding text content in the front-end source code.

[0084] Based on the text identifier, all translated texts in the translated text set are added to the language pack corresponding to the target language type to complete the local language pack update.

[0085] Step S104: Language pack update. After the front-end construction phase is completed, the language pack corresponding to the target language type generated in the front-end construction phase is compared with the corresponding language pack stored in the static resource server, and the language pack in the static resource server is updated based on the comparison result.

[0086] In this step, since the language pack corresponding to the target language type has already been downloaded to the local machine from the static resource server (CDN server) during the front-end build phase, and the translated text corresponding to the text to be processed is continuously added to the local language pack during the front-end build process, differences will arise between the local language pack and the language pack on the static resource server. Therefore, it is necessary to synchronize and update the language pack on the static resource server. Specifically:

[0087] After the front-end build phase is completed, the updated local language packs will be used as the first language pack set.

[0088] Again, download the language packs corresponding to each target language type in the target language type set from the static resource server (CDN server) to the local to form a second language pack set;

[0089] Based on the diff algorithm, compare the first language pack set with the corresponding second language pack set. Among them, the diff algorithm uses the text content in the language pack as the key and the corresponding translated text as the value, for example {"Chinese": "Chinese"};

[0090] Traverse each language pack in the second language pack set one by one, and compare it with the text content key and translation content value of the corresponding language pack in the first language pack. According to the comparison result, perform an addition process on the content of the language packs in the second language pack set;

[0091] Synchronize the updated second language pack set to the static resource server (CDN server) to complete the synchronous update of the local language pack and the language pack in the static resource server.

[0092] It should be noted that for each target language type in the target language type set of this application, independent front-end resources corresponding to different target language types are generated;

[0093] During the system operation stage, according to the current language type selection result, directly access the front-end resources corresponding to the current language type to present the front-end page corresponding to the current language type. Among them, the system operation stage refers to the stage after the front-end resources are built and deployed, and external access and use are provided. In this stage, no front-end build or multi-language processing is performed on the front-end source code.

[0094] The current language type refers to the language type selected and used during the system operation and use, and is used to determine which language-corresponding front-end resources to load for display.

[0095] The present invention also provides a multi-language front-end resource automatic construction system based on the construction stage, as Figure 2 shown. The multi-language front-end resource automatic construction system 200 includes:

[0096] The configuration and loop construction control module 210 of multi-language construction parameters configures the target language type set and the main language type during the front-end construction stage, and performs loop construction processing on the front-end resources corresponding to each target language type in the target language type set.

[0097] In the loop construction process, the text content recognition and replacement processing module 220 scans and recognizes the text content in the front-end source code when the target language type is different from the main language type, generates and marks the text identifier corresponding to the text content, obtains the target language text from the language pack corresponding to the target language type based on the text identifier, and replaces the corresponding text content in the front-end source code with the target language text, and records the text content that has not been replaced as text to be processed.

[0098] The translation module 230 for the text to be processed calls the translation interface to perform translation processing on the text to be processed, generates translated text corresponding to the target language type, performs replacement processing on the corresponding text content in the front-end source code based on the translated text, and adds the translated text to the language pack corresponding to the target language type according to the text identifier of the text to be processed.

[0099] After the front-end construction phase is completed, the language pack update module 240 compares the language pack corresponding to the target language type generated in the front-end construction phase with the corresponding language pack stored in the static resource server, and performs an update process on the language pack in the static resource server based on the comparison result.

[0100] In summary, the multilingual front-end resource automatic construction method and system based on the build phase provided by this invention automatically generates multilingual front-end resources during the build phase by recognizing, matching, and translating multilingual text content during the front-end construction phase, and completing text replacement and language pack supplementation during the construction process. Compared with the prior art, which relies on loading language resources during the runtime phase and requires developers to manually maintain the text and language identifiers, this invention reduces the intrusion of multilingual processing on business code, avoids the problem of frequent code modifications due to text adjustments, thereby reducing the dependence of multilingual text maintenance on developers, improving the automation level of the multilingual construction process, and is suitable for large-scale H5 projects with many pages, complex modules, and frequent iterations.

[0101] Furthermore, this invention generates build artifacts for front-end resources corresponding to different languages ​​by configuring a set of target language types and performing a cyclical build process. Through a text identification mechanism, it achieves automatic matching and difference recognition of text content, performing translation processing only on newly added or unmatched text, and incrementally supplementing the translation results into the corresponding language pack. Simultaneously, after the build is completed, the language pack is updated and synchronized to ensure that the language resources remain consistent with the build result. This approach avoids the problems of overall language pack reconstruction, manual comparison, and repeated maintenance in existing technologies, improves the accuracy and timeliness of multilingual updates, and reduces runtime language loading and replacement operations by directly accessing the front-end resources of the corresponding language during system operation, thus improving page loading stability.

[0102] Furthermore, this invention modularizes functional modules such as multilingual build parameter configuration, text content recognition and replacement, text translation, and language pack updates, enabling unified management and execution of the multilingual processing workflow at the system level. The system has a clear structure and well-defined functions, facilitating integration and deployment within existing front-end build systems, reducing the impact of multilingual capabilities on existing business systems, and improving the overall system's maintainability and scalability.

[0103] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the foregoing claims.

[0104] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope.

Claims

1. A method for automatically building multilingual front-end resources based on the build phase, characterized in that, The method includes: The configuration of multi-language build parameters and the control of loop build are as follows: During the front-end build phase, the target language type set and the main language type are configured, and loop build processing is performed on the front-end resources corresponding to each target language type in the target language type set; In the text content recognition and replacement process, when the target language type is different from the main language type, the text content in the front-end source code is scanned and recognized, and a text identifier corresponding to the text content is generated and labeled. Based on the text identifier, the target language text is obtained from the language pack corresponding to the target language type, and the target language text is used to replace the corresponding text content in the front-end source code. Text content that has not been replaced is recorded as text to be processed. The process involves translating the text to be processed by calling a translation interface to perform translation processing on the text to be processed, generating translated text corresponding to the target language type, replacing the corresponding text content in the front-end source code based on the translated text, and adding the translated text to the language pack corresponding to the target language type according to the text identifier of the text to be processed. After the front-end building phase is completed, the language packs corresponding to the target language type generated in the front-end building phase are compared with the corresponding language packs stored in the static resource server, and the language packs in the static resource server are updated based on the comparison results. The text content recognition and replacement process includes: In the loop construction process, when the target language type is different from the main language type, the text content of the page files and component files in the front-end source code is scanned and identified, and text identifiers corresponding to the text content are generated and labeled. The text identifier is matched with the text identifier in the language pack corresponding to the target language type; When the language pack contains target language text corresponding to the text identifier, the target language text is used to replace the corresponding text content in the front-end source code. When the target language text corresponding to the text identifier does not exist in the language pack, the corresponding text content in the front-end source code is recorded as the text to be processed; When performing loop build processing, if the target language type is different from the main language type, the static JSON language package from the static resource server is downloaded to the local machine to replace the corresponding text content in the front-end source code; After the front-end build phase is completed, the updated local language packs will be used as the first language pack set. Download the language packs corresponding to each target language type from the static resource server to the local machine again to form a second language pack set; Based on the diff algorithm, the first language pack set is compared with the corresponding second language pack set. The diff algorithm uses the text content in the language pack as the key and the corresponding translated text as the translated content value. Iterate through each language pack in the second language pack set one by one, and compare it with the text content key and translation content value of the corresponding language pack in the first language pack. Based on the comparison results, add new content to the language pack in the second language pack set. The updated second language pack set is synchronized to the static resource server to complete the synchronization update between the local language pack and the language pack in the static resource server; When translating the text to be processed, the text is processed in batches according to a preset size limit, and each batch of text to be processed is sent to the translation interface for translation; the order and number of texts to be translated in each batch are consistent with the order and number of texts to be processed.

2. The automatic construction method for multilingual front-end resources based on the construction phase according to claim 1, characterized in that, The configuration of the multilingual build parameters and the control of the loop build process include: During the front-end building phase, the target language type set is configured to indicate the language types of the multilingual front-end resources to be generated; The main language type is determined based on the original language type used in the front-end source code; Perform a loop construction process on the target language type set, the loop construction process including: Each target language type in the target language type set is iterated through one by one, and each target language type is compared with the main language type; When the target language type is the same as the main language type, the build process is directly executed based on the front-end source code to generate the front-end resources corresponding to the main language type. When the target language type is different from the main language type, a language pack corresponding to the target language type is obtained from the static resource server, and a build process is performed based on the language pack to generate front-end resources corresponding to the target language type.

3. The automatic construction method for multilingual front-end resources based on the construction phase according to claim 1, characterized in that, The translation of the text to be processed includes: Add the text to be processed to the text set; The translation interface is called in batches to perform translation processing on the texts in the set of texts to be processed, and the texts to be processed are translated into target language translated text. When the translation process is successful, based on the text identifier, the target language translated text is saved as the translated text corresponding to the text to be processed to the translated text set; When the translation process fails, the text to be processed is saved as the corresponding translated text to the translated text set based on the text identifier. After all the text to be processed in the text to be processed set has been translated, the text to be processed set is traversed one by one, and the corresponding text content in the front-end source code is replaced with the translated text in the text to be processed set based on the text identifier; Based on the text identifier, all translated texts in the translated text set are added to the language pack corresponding to the target language type.

4. The automatic construction method for multilingual front-end resources based on the construction phase according to claim 1, characterized in that, The text content recognition and replacement process also includes: Pre-defined special text content will not be replaced or translated. The special text content includes file names and text content marked as not requiring translation.

5. The method for automatically building multilingual front-end resources based on the build phase according to claim 1, characterized in that, The method generates independent front-end resources for each target language type in the target language type set, each corresponding to a different target language type. During system operation, based on the current language type selection result, the system directly accesses the front-end resources corresponding to the current language type to present the front-end page corresponding to the current language type.

6. A multilingual front-end resource automatic construction system based on the build phase, characterized in that, The system includes: The multi-language build parameter configuration and loop build control module configures the target language type set and the main language type during the front-end build phase, and performs loop build processing for the front-end resources corresponding to each target language type in the target language type set. In the loop construction process, when the target language type is different from the main language type, the text content recognition and replacement processing module scans and recognizes the text content in the front-end source code, generates and marks the text identifier corresponding to the text content, obtains the target language text from the language pack corresponding to the target language type based on the text identifier, and replaces the corresponding text content in the front-end source code with the target language text. The text content that has not been replaced is recorded as text to be processed. The translation module for the text to be processed calls the translation interface to perform translation processing on the text to be processed, generates translated text corresponding to the target language type, performs replacement processing on the corresponding text content in the front-end source code based on the translated text, and adds the translated text to the language pack corresponding to the target language type according to the text identifier of the text to be processed; The language pack update module compares the language packs corresponding to the target language type generated in the front-end construction phase with the corresponding language packs stored in the static resource server after the front-end construction phase is completed, and performs add / update processing on the language packs in the static resource server based on the comparison results. The text content recognition and replacement process includes: In the loop construction process, when the target language type is different from the main language type, the text content of the page files and component files in the front-end source code is scanned and identified, and text identifiers corresponding to the text content are generated and labeled. The text identifier is matched with the text identifier in the language pack corresponding to the target language type; When the language pack contains target language text corresponding to the text identifier, the target language text is used to replace the corresponding text content in the front-end source code. When the target language text corresponding to the text identifier does not exist in the language pack, the corresponding text content in the front-end source code is recorded as the text to be processed; When performing loop build processing, if the target language type is different from the main language type, the static JSON language package from the static resource server is downloaded to the local machine to replace the corresponding text content in the front-end source code; After the front-end build phase is completed, the updated local language packs will be used as the first language pack set. Download the language packs corresponding to each target language type from the static resource server to the local machine again to form a second language pack set; Based on the diff algorithm, the first language pack set is compared with the corresponding second language pack set. The diff algorithm uses the text content in the language pack as the key and the corresponding translated text as the translated content value. Iterate through each language pack in the second language pack set one by one, and compare it with the text content key and translation content value of the corresponding language pack in the first language pack. Based on the comparison results, add new content to the language pack in the second language pack set. The updated second language pack set is synchronized to the static resource server to complete the synchronization update between the local language pack and the language pack in the static resource server; When translating the text to be processed, the text is processed in batches according to a preset size limit, and each batch of text to be processed is sent to the translation interface for translation; the order and number of texts to be translated in each batch are consistent with the order and number of texts to be processed.

Citation Information

Patent Citations

  • Page display method and device, computer equipment and storage medium

    CN113900762A

  • Response code internationalization method based on Spring Cloud Gateway

    CN119135746A

  • Front-end universal multi-language switching method, device and equipment and medium

    CN120631494A