Language switching method, device and storage medium

Real-time dynamic language switching of the main application and sub-applications is achieved through the micro-frontend language control device, which solves the problem of long language version update time between the main application and sub-applications and improves the user experience.

CN119336430BActive Publication Date: 2025-09-26ZHONGKE YUNGU TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411385907.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2025-09-26
Estimated Expiration
2044-09-30

AI Technical Summary

Technical Problem

The language switching between the main application and sub-applications cannot be achieved synchronously, resulting in a long time for language version updates, affecting the page browsing effect.

Method used

Through the micro-frontend language control device, respond to the language switching request of the main application, obtain and update the language version of the main application, and determine whether the sub-application has the corresponding language configuration through real-time messages, thereby realizing real-time dynamic language switching between the main application and the sub-application.

Benefits of technology

It has opened up the state isolation between the main application and sub-applications, reduced the loading time of the language version, and improved the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336430B_ABST
    Figure CN119336430B_ABST
Patent Text Reader

Abstract

The present application relates to the field of computer technology, and in particular to a method, device, and storage medium for language switching. The method comprises: responding to a language switching request for a main application; obtaining a first language version used by the main application's page; determining a first target language file and updating the language version used by the main application's page; determining a sub-application loaded by the main application; receiving a real-time message sent by the main application and determining whether the sub-application has a language configuration corresponding to the language identifier; obtaining a second language version used by the sub-application's page if it is determined that the sub-application has a language configuration corresponding to the language identifier; determining a second target language file and updating the language version on the sub-application's page, so that the sub-application is consistent with the updated language version of the main application, thus opening up the state isolation between the main application and the sub-application, realizing real-time dynamic language switching between the main application and the sub-application, reducing the loading time of the language version, and improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, and storage medium for language switching. Background Art

[0002] With the rapid development of the mobile internet, more and more applications have emerged, reaching users around the world. Due to language and cultural differences across countries and regions, global users' application needs vary. To meet the needs of diverse users, developers often need to internationalize their applications and manage translations.

[0003] The application consists of a main application and sub-applications. During initialization, all language files are loaded to translate the entire application's pages. However, due to the state isolation between the main application and sub-applications, synchronous language switching between the main application and sub-applications is impossible, and the main application and sub-applications cannot independently control the language version of the page. This results in long update times and affects page browsing quality. Summary of the Invention

[0004] The purpose of the embodiments of the present application is to provide a language switching method, device and storage medium to solve the problem in the prior art that the language versions of the main application and the sub-application cannot be switched synchronously.

[0005] To achieve the above objectives, the present application provides, in a first aspect, a language switching method, which is applied to a micro-front-end language control device, and includes:

[0006] Responding to a language switching request for the main application, wherein the language switching request carries a language identifier;

[0007] Get the first language version used by the main application page;

[0008] Determine a first target language file corresponding to the language switching request according to the first language version and the language identifier, and update the language version used by the page of the main application using the first target language file;

[0009] Determine the sub-application loaded by the main application;

[0010] receiving a real-time message sent by the main application, and determining, based on the real-time message, whether the sub-application has a language configuration corresponding to the language identifier;

[0011] If it is determined that the sub-application has a language configuration corresponding to the language identifier, obtaining a second language version used by the page of the sub-application;

[0012] The second target language file corresponding to the language switching request is determined according to the second language version and the language identifier, and the language version on the sub-application page is updated using the second target language file, so that the sub-application and the main application have the same updated language version.

[0013] In an embodiment of the present application, determining a first target language file corresponding to a language switching request based on a first language version and a language identifier includes: determining a version rule of the first language version; generating a first access address based on the version rule of the first language version and the language identifier; and determining the first target language file based on the first access address.

[0014] In an embodiment of the present application, the micro-frontend language control device includes a loading module, and determining the first target language file according to the first access address includes: sending the first access address to the loading module, so that the loading module accesses the first access address to load the first target language file; if the loading module successfully loads the first target language file, directly obtaining the first target language file from the loading module; if the loading module fails to successfully load the first target language file, accessing the first access address to load the first target language file.

[0015] In an embodiment of the present application, the micro-front-end language control device includes a message module, and the method also includes: after determining the sub-application loaded by the main application, registering a message receiver for the sub-application in the message module to receive real-time messages sent by the main application through the message receiver in the message module.

[0016] In an embodiment of the present application, the method further includes: after obtaining the second language version used by the sub-application page, receiving a call request from the sub-application, and parsing the real-time message based on the call request of the sub-application to obtain a language identifier.

[0017] In an embodiment of the present application, determining a second target language file corresponding to a language switching request based on a second language version and a language identifier includes: determining a version rule of the second language version; generating a second access address based on the version rule of the second language version and the language identifier; and determining the second target language file based on the second access address.

[0018] In an embodiment of the present application, the micro-frontend language control device includes a loading module, and determining the second target language file according to the second access address includes: sending the second access address to the loading module, so that the loading module accesses the second access address to load the second target language file; if the loading module successfully loads the second target language file, directly obtaining the second target language file from the loading module; if the loading module fails to successfully load the second target language file, accessing the second access address to load the second target language file.

[0019] In an embodiment of the present application, the micro-frontend language control device includes a loading module, and updating the language version used by the page of the main application through the first target language file includes: receiving a call request from the main application, and calling the loading module to load the first target language file based on the call request of the main application; and updating the language version used by the page of the main application through the first target language file loaded by the loading module.

[0020] A second aspect of the present application provides a language switching device, comprising:

[0021] a memory configured to store instructions;

[0022] The processor is configured to call instructions from a memory and implement the above-mentioned language switching method when executing the instructions.

[0023] A third aspect of the present application provides a machine-readable storage medium having stored thereon instructions for causing a machine to execute the above-mentioned language switching method.

[0024] Through the above technical solution, in response to a language switching request for a main application, the first language version used by the page of the main application is obtained; the first target language file corresponding to the language switching request is determined based on the first language version and the language identifier, and the language version used by the page of the main application is updated through the first target language file; the sub-application loaded by the main application is determined; a real-time message sent by the main application is received, and based on the real-time message, it is determined whether the sub-application has a language configuration corresponding to the language identifier; if it is determined that the sub-application has a language configuration corresponding to the language identifier, the second language version used by the page of the sub-application is obtained; the second target language file corresponding to the language switching request is determined based on the second language version and the language identifier, and the language version on the page of the sub-application is updated through the second target language file, so that the sub-application is consistent with the updated language version of the main application, thus breaking through the state isolation between the main application and the sub-application, realizing real-time dynamic language switching between the main application and the sub-application, reducing the loading time of the language version, and improving the user experience.

[0025] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following detailed description, they are used to explain the embodiments of the present application but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:

[0027] Figure 1 A flow chart of a method for language switching according to an embodiment of the present application is schematically shown;

[0028] Figure 2 Another flowchart of a language switching method according to an embodiment of the present application is schematically shown;

[0029] Figure 3 A schematic diagram of a micro-front-end language control device according to an embodiment of the present application is schematically shown;

[0030] Figure 4 The internal structure diagram of a computer device according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0031] To make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0032] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the various components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indications will also change accordingly.

[0033] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of such features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the fact that they can be implemented by ordinary technicians in this field. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0034] Figure 1 The following schematically shows a flow chart of a method for language switching according to an embodiment of the present application. Figure 1 As shown, an embodiment of the present application provides a language switching method, which is applied to a micro-front-end language control device. The method may include the following steps.

[0035] Step 101: responding to a language switching request for a main application, wherein the language switching request carries a language identifier.

[0036] Step 102: Obtain the first language version used by the page of the main application.

[0037] Step 103: Determine a first target language file corresponding to the language switching request according to the first language version and the language identifier, and update the language version used by the page of the main application using the first target language file.

[0038] The processor may respond to a language switching request for the main application, wherein the language switching request may include a language identifier. The processor may obtain a first language version used by the main application's page. After obtaining the first language version used by the main application's page, the processor may determine a first target language file corresponding to the language switching request based on the first language version and the language identifier, and update the language version used by the main application's page using the first target language file.

[0039] In an embodiment of the present application, determining a first target language file corresponding to a language switching request based on a first language version and a language identifier includes: determining a version rule of the first language version; generating a first access address based on the version rule of the first language version and the language identifier; and determining the first target language file based on the first access address.

[0040] The processor may determine the first target language file corresponding to the language switch request based on the first language version and the language identifier. Specifically, the processor may determine the version rules of the first language version, which may include language generation rules, conversion rules, modification rules, etc. After determining the version rules of the first language version, the processor may generate a first access address based on the version rules of the first language version and the language identifier. After obtaining the first access address, the processor may determine the first target language file based on the first access address.

[0041] In an embodiment of the present application, the micro-frontend language control device includes a loading module, and determining the first target language file according to the first access address includes: sending the first access address to the loading module, so that the loading module accesses the first access address to load the first target language file; if the loading module successfully loads the first target language file, directly obtaining the first target language file from the loading module; if the loading module fails to successfully load the first target language file, accessing the first access address to load the first target language file.

[0042] The micro-frontend language control device includes a loading module. A processor can determine a first target language file based on a first access address. Specifically, the processor can send the first access address to the loading module, so that the loading module accesses the first access address to load the first target language file. The processor can determine whether the loading module successfully loaded the first target language file. If the loading module successfully loaded the first target language file, the processor can directly obtain the first target language file from the loading module. If the loading module fails to successfully load the first target language file, the processor can access the first access address to load the first target language file.

[0043] In an embodiment of the present application, the micro-frontend language control device includes a loading module, and updating the language version used by the page of the main application through the first target language file includes: receiving a call request from the main application, and calling the loading module to load the first target language file based on the call request of the main application; and updating the language version used by the page of the main application through the first target language file loaded by the loading module.

[0044] The micro-frontend language control device may include a loading module. The processor may update the language version used by the main application's page using a first target language file. Specifically, the processor may receive a call request from the main application and, based on the call request from the main application, call the loading module to load the first target language file, thereby obtaining the first target language file loaded by the loading module. After obtaining the first target language file loaded by the loading module, the processor may update the language version used by the main application's page using the first target language file loaded by the loading module.

[0045] Step 104: Determine the sub-application loaded by the main application.

[0046] Step 105: Receive a real-time message sent by the main application, and determine whether the sub-application has a language configuration corresponding to the language identifier based on the real-time message.

[0047] After updating the language version used by the main application's pages using the first target language file, the processor can determine the sub-application loaded by the main application. The processor can also receive real-time messages sent by the main application and, based on the real-time messages, determine whether the sub-application has a language configuration corresponding to the language identifier. The language configuration can include language environment configuration, format configuration, plug-in configuration, etc.

[0048] In an embodiment of the present application, the micro-front-end language control device includes a message module, and the method also includes: after determining the sub-application loaded by the main application, registering a message receiver for the sub-application in the message module to receive real-time messages sent by the main application through the message receiver in the message module.

[0049] The micro-frontend language control device may include a message module. After determining the sub-application loaded by the main application, the processor may register the sub-application's message receiver in the message module to receive real-time messages sent by the main application through the message receiver in the message module, thereby enabling real-time communication between the main application and the sub-application, and achieving state isolation between the applications.

[0050] Step 106: When it is determined that the sub-application has a language configuration corresponding to the language identifier, obtain a second language version used by the page of the sub-application.

[0051] Step 107: Determine the second target language file corresponding to the language switching request according to the second language version and the language identifier, and update the language version on the sub-application page using the second target language file so that the sub-application and the main application have the same updated language version.

[0052] If it is determined that the sub-application has a language configuration corresponding to the language identifier, the processor may obtain the second language version used by the sub-application's page. After obtaining the second language version used by the sub-application's page, the processor may determine a second target language file corresponding to the language switch request based on the second language version and the language identifier, and update the language version on the sub-application's page using the second target language file, so that the sub-application maintains the same updated language version as the main application.

[0053] In an embodiment of the present application, the method further includes: after obtaining the second language version used by the sub-application page, receiving a call request from the sub-application, and parsing the real-time message based on the call request of the sub-application to obtain a language identifier.

[0054] After obtaining the second language version used by the sub-application page, the processor may receive a call request from the sub-application and parse the real-time message with the call request of the sub-application to obtain a language identifier.

[0055] In an embodiment of the present application, determining a second target language file corresponding to a language switching request based on a second language version and a language identifier includes: determining a version rule of the second language version; generating a second access address based on the version rule of the second language version and the language identifier; and determining the second target language file based on the second access address.

[0056] The processor may determine the second target language file corresponding to the language switch request based on the second language version and the language identifier. Specifically, the processor may determine the version rules of the second language version. After determining the version rules of the second language version, the processor may generate a second access address based on the version rules of the second language version and the language identifier. After obtaining the second access address, the processor may determine the second target language file based on the second access address.

[0057] In an embodiment of the present application, the micro-frontend language control device includes a loading module, and determining the second target language file according to the second access address includes: sending the second access address to the loading module, so that the loading module accesses the second access address to load the second target language file; if the loading module successfully loads the second target language file, directly obtaining the second target language file from the loading module; if the loading module fails to successfully load the second target language file, accessing the second access address to load the second target language file.

[0058] The micro-frontend language control device includes a loading module. The processor can determine a second target language file based on a second access address. Specifically, the processor can send the second access address to the loading module, so that the loading module accesses the second access address to load the second target language file. The processor can determine whether the loading module successfully loaded the second target language file. If the loading module successfully loaded the second target language file, the processor can directly obtain the second target language file from the loading module. If the loading module fails to successfully load the second target language file, the processor can access the second access address to load the second target language file.

[0059] In an embodiment of the present application, the micro-front-end language control device is mainly used for version control and file caching, and can be initialized with a control module, a message module, a configuration module, a loading module and a file module. After the configuration module is initialized, language entries, translation texts and language configurations are entered. The control module initializes the main application to obtain the first language version used by the page of the main application. The control module detects the user's language switching request for the main application, wherein the language switching request carries a language identifier, and the language identifier is language A. The control module generates a first access address according to the version rules and language identifier of the first language version, and accesses the first access address through the loading module. When the loading module successfully loads the first target language file, that is, the language A file, by accessing the first access address, the first target language file is directly obtained from the loading module. When the loading module fails to successfully load the first target language file by accessing the first access address, the control module accesses the first access address to obtain the first target language file from the file module, and the file module is initialized with the language A file, the language B file, the language C file, etc. The control module calls the loading module to load the first target language file to update the language version used by the page of the main application, so that the language version used by the page of the main application is converted into the language version corresponding to the user switching request.

[0060] The control module determines whether the main application loads a sub-application. If the main application loads a sub-application, the control module registers the sub-application's message receiver in the message module to establish real-time communication between the main application and the sub-application. The main application can generate a real-time message with the language identifier and the loaded sub-application identifier and push it to the message module. After the message module receives the real-time message via the message receiver, the control module can call the configuration module to detect whether the sub-application has a language configuration that supports the language identifier. If the sub-application has a language configuration that supports the language identifier, the message module pushes a real-time message including the language identifier to the sub-application. The sub-application receives the real-time message and, through the control module, parses the language identifier from the real-time message. The control module obtains the second language version used by the sub-application's page and generates a second access address based on the version rules of the second language version and the language identifier. The control module sends the second access address to the loading module, which then accesses the second access address to load the second target language file. If the loading module successfully loads the second target language file, the control module can directly obtain the second target language file from the loading module. If the loading module fails to successfully load the second target language file, the control module can access the second access address to obtain the second target language file from the file module. The sub-application calls the loading module to load the second target language file to update the language version used by the sub-application page, so that the updated language version of the main application and the sub-application remain consistent.

[0061] Through the above technical solution, the state isolation between the main application and the sub-application is achieved, and real-time dynamic language switching between the main application and the sub-application is realized, which reduces the loading time of the language version and improves the user experience.

[0062] Figure 1 and Figure 2 FIG. 1 is a flow chart of a method for language switching in one embodiment. It should be understood that although Figure 1 and Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 1 and Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0063] The embodiment of the present application further provides a language switching device, comprising:

[0064] a memory configured to store instructions;

[0065] The processor is configured to call instructions from a memory and implement the above-mentioned language switching method when executing the instructions.

[0066] The present application also provides a micro-front-end language control device, such as Figure 3 As shown, a micro-front-end language control device 300 is provided. The micro-front-end language control device 300 may include a message module 301, a configuration module 302, a loading module 303, a file module 304, and a control module 305. Among them, the message module 301, as a message communication module between the main application and the sub-application, is used to enable the main application to transmit the language identifier to the sub-application in real time, thereby opening up the state isolation between the applications. The configuration module 302, as a language configuration module for the main application and the sub-application, is used to enter language entries, translate texts, generate language configurations, and version control the application language. The loading module 303, as a language file loading module, is used to enable the application to load the corresponding language file according to the language identifier. The loaded language file is also cached in the loading module 303. The file module 304, as a language file management module, is used for uploading, storing and classifying language files, and provides access addresses for language documents. The control module 305 is used to execute the above-mentioned language switching method.

[0067] An embodiment of the present application further provides a machine-readable storage medium having stored thereon instructions for causing a machine to execute the above-mentioned language switching method.

[0068] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor A01, a network interface A02, a memory (not shown in the figure) and a database (not shown in the figure) connected via a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02 and a database (not shown in the figure). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A04. The database of the computer device is used to store data such as a first language version, a first target language file, a second language version, a second target language file, etc. The network interface A02 of the computer device is used to communicate with an external terminal via a network connection. When the computer program B02 is executed by the processor A01, a method for language switching is implemented.

[0069] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0070] An embodiment of the present application provides a device, comprising a processor, a memory, and a program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the program: responding to a language switching request for a main application, wherein the language switching request carries a language identifier; obtaining a first language version used by a page of the main application; determining a first target language file corresponding to the language switching request based on the first language version and the language identifier, and updating the language version used by the page of the main application using the first target language file; determining a sub-application loaded by the main application; receiving a real-time message sent by the main application, and determining whether the sub-application has a language configuration corresponding to the language identifier based on the real-time message; if it is determined that the sub-application has a language configuration corresponding to the language identifier, obtaining a second language version used by the page of the sub-application; determining a second target language file corresponding to the language switching request based on the second language version and the language identifier, and updating the language version on the page of the sub-application using the second target language file, so that the sub-application is consistent with the updated language version of the main application.

[0071] In one embodiment, determining a first target language file corresponding to a language switching request based on a first language version and a language identifier includes: determining a version rule of the first language version; generating a first access address based on the version rule of the first language version and the language identifier; and determining the first target language file based on the first access address.

[0072] In one embodiment, the micro-frontend language control device includes a loading module, and determining the first target language file according to the first access address includes: sending the first access address to the loading module, so that the loading module accesses the first access address to load the first target language file; if the loading module successfully loads the first target language file, directly obtaining the first target language file from the loading module; if the loading module fails to successfully load the first target language file, accessing the first access address to load the first target language file.

[0073] In one embodiment, the micro-frontend language control device includes a message module, and the method further includes: after determining the sub-application loaded by the main application, registering a message receiver for the sub-application in the message module to receive real-time messages sent by the main application through the message receiver in the message module.

[0074] In one embodiment, the method further includes: after obtaining the second language version used by the sub-application page, receiving a call request of the sub-application, and parsing the real-time message based on the call request of the sub-application to obtain a language identifier.

[0075] In one embodiment, determining the second target language file corresponding to the language switching request based on the second language version and the language identifier includes: determining a version rule of the second language version; generating a second access address based on the version rule of the second language version and the language identifier; and determining the second target language file based on the second access address.

[0076] In one embodiment, the micro-frontend language control device includes a loading module, and determining the second target language file according to the second access address includes: sending the second access address to the loading module, so that the loading module accesses the second access address to load the second target language file; if the loading module successfully loads the second target language file, directly obtaining the second target language file from the loading module; if the loading module fails to successfully load the second target language file, accessing the second access address to load the second target language file.

[0077] In one embodiment, the micro-frontend language control device includes a loading module, and updating the language version used by the main application page through the first target language file includes: receiving a call request from the main application, and calling the loading module to load the first target language file based on the call request of the main application; and updating the language version used by the main application page through the first target language file loaded by the loading module.

[0078] The present application also provides a computer program product, which, when executed on a data processing device, is adapted to execute the program of the method steps of initializing language switching.

[0079] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0080] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0081] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0082] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0083] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0084] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0085] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0086] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0087] The above are merely embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A language switching method, characterized in that: Applied to a micro-front-end language control device, the method includes: Responding to a language switching request for a primary application, wherein the language switching request carries a language identifier; Obtaining a first language version used by the page of the main application; Determining a first target language file corresponding to the language switching request according to the first language version and the language identifier, and updating the language version used by the page of the main application using the first target language file; Determining a sub-application loaded by the main application; receiving a real-time message sent by the main application, and determining, based on the real-time message, whether the sub-application has a language configuration corresponding to the language identifier; If it is determined that the sub-application has a language configuration corresponding to the language identifier, obtaining a second language version used by the page of the sub-application; A second target language file corresponding to the language switching request is determined according to the second language version and the language identifier, and the language version on the sub-application page is updated using the second target language file, so that the sub-application and the main application have the same updated language version.

2. The language switching method according to claim 1, wherein: Determining a first target language file corresponding to the language switching request according to the first language version and the language identifier includes: determining a version rule for the first language version; generating a first access address according to the version rule of the first language version and the language identifier; The first target language file is determined according to the first access address.

3. The language switching method according to claim 2, wherein: The micro-front-end language control device includes a loading module, and determining the first target language file according to the first access address includes: Sending the first access address to the loading module, so that the loading module accesses the first access address to load the first target language file; When the loading module successfully loads the first target language file, directly obtaining the first target language file from the loading module; If the loading module fails to load the first target language file, the first access address is accessed to load the first target language file.

4. The language switching method according to claim 1, wherein: The micro-front-end language control device includes a message module, and the method further includes: After determining the sub-application loaded by the main application, a message receiver for the sub-application is registered in the message module, so as to receive the real-time message sent by the main application through the message receiver in the message module.

5. The language switching method according to claim 1, wherein: The method further comprises: After obtaining the second language version used by the sub-application page, a call request of the sub-application is received, and the real-time message is parsed based on the call request of the sub-application to obtain the language identifier.

6. The language switching method according to claim 5, characterized in that: Determining the second target language file corresponding to the language switching request according to the second language version and the language identifier includes: determining a version rule for the second language version; generating a second access address according to the version rule of the second language version and the language identifier; The second target language file is determined according to the second access address.

7. The language switching method according to claim 6, characterized in that: The micro-front-end language control device includes a loading module, and determining the second target language file according to the second access address includes: Sending the second access address to the loading module, so as to load the second target language file by accessing the second access address through the loading module; When the loading module successfully loads the second target language file, directly obtaining the second target language file from the loading module; If the loading module fails to load the second target language file, the second access address is accessed to load the second target language file.

8. The language switching method according to claim 1, wherein: The micro-frontend language control device includes a loading module, and updating the language version used by the page of the main application through the first target language file includes: receiving a call request from the main application, and calling the loading module to load the first target language file based on the call request from the main application; The language version used by the page of the main application is updated by using the first target language file loaded by the loading module.

9. A language switching device, characterized in that: include: a memory configured to store instructions; A processor is configured to call the instructions from the memory and implement the language switching method according to any one of claims 1 to 8 when executing the instructions.

10. A machine-readable storage medium, characterized in that The machine-readable storage medium stores instructions for causing a machine to execute the language switching method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Program running method and device, electronic equipment and storage medium

    CN113918214A

  • Language conversion method and device, computer equipment and computer readable storage medium

    CN116796759A