Language switching method and device and storage medium

In response to the language switching request of the Lord's application, obtain and update the language version of the main application and sub -application pages, solve the problem of simultaneous switching of language versions in the existing technology, and realize real -time language switch between the main application and sub -application, improve the improvement User experience.

CN119336430AActive Publication Date: 2025-01-21ZHONGKE YUNGU TECH
View PDF 7 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the prior art, it is impossible to synchronous switching of language versions between the main application and the sub-application, resulting in too long language update time and affecting the user experience.

Method used

By responding to the language switching request of the main application, the language version of the main application page is obtained, the target language file is determined based on the language identifier, and the language version of the main application page is updated. At the same time, it is determined whether the sub-application has a corresponding language configuration, the language version of the sub-application page is obtained, and the language version of the sub-application page is updated through the target language file to make it consistent with the main application.

Benefits of technology

Real -time dynamic language switching between the main application and the sub -application has reduced the loading time of the language version and enhanced the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119336430A_ABST
    Figure CN119336430A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, in particular to a language switching method and device and a storage medium. Comprising the steps of responding to a language switching request for a main application; obtaining a first language version used by the page of the main application; determining a first target language file, and updating a language version used by a page of the main application; 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 language configuration corresponding to the language identifier; under the condition of determining that the sub-application has the language configuration corresponding to the language identifier, obtaining a second language version used by the page of the sub-application; the second target language file is determined, and the language version on the page of the sub-application is updated, so that the updated language version of the sub-application and the updated language version of the main application are kept consistent, state isolation between the main application and the sub-application is broken through, real-time dynamic language switching between the main application and the sub-application is achieved, the loading duration of the language version is shortened, and the user experience is improved. And user experience is improved.
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 language switching method, device and storage medium. Background Art

[0002] With the rapid development of mobile Internet, more and more applications have emerged, covering users all over the world. Due to the differences in language and culture between different countries and regions, the needs of global users for applications are also different. In order to meet the needs of different users, developers usually need to internationalize and translate applications into multiple languages.

[0003] The application includes the main application and sub-applications. All language files are loaded during initialization to achieve page language translation for the entire application. However, due to the state isolation between the main application and the sub-applications, it is impossible to achieve synchronous language switching between the main application and the sub-applications, and it is impossible for the main application and the sub-applications to independently control the language version of the page, resulting in a long update time and affecting the page browsing effect. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a method, device and storage medium for language switching, so as 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] In order to achieve the above-mentioned object, the first aspect of the present application provides a language switching method, which is applied to a micro-front-end language control device, and the method 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 through 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 whether the sub-application has a language configuration corresponding to the language identifier based on the real-time message;

[0011] When 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] 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 is consistent with the updated language version of the main application.

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

[0014] In an embodiment of the present application, 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 as to access the first access address through the loading module 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; when 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 page of the sub-application, 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.

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

[0018] In an embodiment of the present application, 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 access the second access address through the loading module to load the second target language file; when the loading module successfully loads the second target language file, directly obtaining the second target language file from the loading module; when 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-front-end 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; 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, including:

[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, on which instructions are stored, and the instructions are used to enable 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, a first language version used by a page of the main application is obtained; a first target language file corresponding to the language switching request is determined according to 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; a 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, a second language version used by the page of the sub-application is obtained; 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 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, the state isolation between the main application and the sub-application is opened up, the real-time dynamic language switching between the main application and the sub-application is realized, the loading time of the language version is reduced, and the user experience is improved.

[0025] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. 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 specific implementations, 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 schematic diagram of a flow chart of a language switching method according to an embodiment of the present application is schematically shown;

[0028] Figure 2 Another flow chart of a method for language switching 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] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme 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...), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication 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 used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0034] Figure 1 The following is a schematic diagram showing 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 through 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 carry a language identifier. The processor may obtain a first language version used by the page of the main application. After obtaining the first language version used by the page of the main application, the processor may 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 through 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 according to a first language version and a language identifier includes: determining a version rule of the first language version; generating a first access address according to the version rule of the first language version and the language identifier; and determining the first target language file according to the first access address.

[0040] The processor may determine the first target language file corresponding to the language switching request according to the first language version and the language identifier. Specifically, the processor may determine the version rules of the first language version, and the version rules 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 according to 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 according to the first access address.

[0041] In an embodiment of the present application, 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 as to access the first access address through the loading module 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; when 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-front-end language control device includes a loading module. The processor can determine the first target language file according to the first access address. Specifically, the processor can send the first access address to the loading module to load the first target language file by accessing the first access address through the loading module. The processor can determine whether the loading module successfully loads the first target language file. In the case where the loading target successfully loads the first target language file, the processor can directly obtain the first target language file from the loading module. In the case where the loading model 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-front-end 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; 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 page of the main application through the first target language file. Specifically, the processor may receive a call request from the main application, and based on the call request of the main application, call the loading module to load the first target language file to obtain 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 page of the main application through 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 page of the main application through the first target language file, the processor can determine the sub-application loaded by the main application. The processor can also 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. 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 message receiver of the sub-application in the message module to receive the real-time message sent by the main application through the message receiver in the message module, so as to realize the real-time communication between the main application and the sub-application, and open up the 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 a 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] When it is determined that the sub-application has a language configuration corresponding to the language identifier, the processor can obtain the second language version used by the sub-application page. After obtaining the second language version used by the sub-application page, the processor can 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 through the second target language file, so that the sub-application is consistent with the updated language version of the main application.

[0053] In an embodiment of the present application, the method further includes: after obtaining the second language version used by the page of the sub-application, 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.

[0054] After obtaining the second language version used by the page of the sub-application, the processor may receive a call request of 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 according to a second language version and a language identifier includes: determining a version rule of the second language version; generating a second access address according to the version rule and the language identifier of the second language version; and determining the second target language file according to the second access address.

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

[0057] In an embodiment of the present application, 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 access the second access address through the loading module to load the second target language file; when the loading module successfully loads the second target language file, directly obtaining the second target language file from the loading module; when 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-front-end language control device includes a loading module. The processor can determine the second target language file according to the second access address. Specifically, the processor can send the second access address to the loading module to load the second target language file by accessing the second access address through the loading module. The processor can determine whether the loading module successfully loads the second target language file. In the case where the loading module successfully loads the second target language file, the processor can directly obtain the second target language file from the loading module. In the case where 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 the 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 A language 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 A language file, B language file, C language 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 the sub-application. In the case where the main application loads the sub-application, the control module registers the message receiver of the sub-application 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 through the message receiver, the control module can call the configuration module to detect the sub-application to determine whether there is a language configuration supporting the language identifier in the sub-application. In the case where there is a language configuration supporting the language identifier in the sub-application, the message module pushes the real-time message including the language identifier to the sub-application, the sub-application receives the real-time message, and parses the language identifier in the real-time message through the control module. The control module obtains the second language version used by the page of the sub-application, and generates a second access address according to the version rule and language identifier of the second language version. The control module sends the second access address to the loading module to load the second target language file by accessing the second access address through the loading module. In the case where 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 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 versions of the main application and the sub-application are consistent.

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

[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. Moreover, 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 also provides a language switching device, including:

[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-frontend language control device 300 is provided, and the micro-frontend 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 pass the language identifier to the sub-application in real time, and to open 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 of application languages. The loading module 303, as a loading module for language files, is used to enable the application to load the corresponding language file according to the language identifier, and the loaded language files are also cached in the loading module 303. The file module 304, as a management module for language files, 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, on which instructions are stored, and the instructions are used to enable 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 through 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 through 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 those shown in the figure, or combine certain components, or have a different arrangement of components.

[0070] An embodiment of the present application provides a device, the device includes 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 according to the first language version and the language identifier, and updating the language version used by the page of the main application through 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 according to the second language version and the language identifier, and updating the language version on the page of the sub-application through 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 according to a first language version and a language identifier includes: determining a version rule of the first language version; generating a first access address according to the version rule of the first language version and the language identifier; and determining the first target language file according to the first access address.

[0072] In one embodiment, 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 as to access the first access address through the loading module 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; when 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 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.

[0074] In one embodiment, the method further includes: after obtaining the second language version used by the page of the sub-application, 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 according to the second language version and the language identifier includes: determining a version rule of the second language version; generating a second access address according to the version rule of the second language version and the language identifier; and determining the second target language file according to the second access address.

[0076] In one embodiment, 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 access the second access address through the loading module to load the second target language file; when the loading module successfully loads the second target language file, directly obtaining the second target language file from the loading module; when 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 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; updating the language version used by the page of the main application 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 suitable for executing 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 may be provided as methods, systems or computer program products. Therefore, the present application may 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 may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to 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 generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. 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 capable of directing a computer or other programmable data processing device to operate 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 A 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 operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0083] In a typical configuration, a computing device includes one or more processors (CPU), 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 include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. 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 disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape 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 temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0086] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0087] The above are only 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 modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A method for language switching, characterized in that: Applied to a micro-front-end language control device, the method includes: Responding to a language switching request for the main application, wherein the language switching request carries a language identifier; Obtaining a first language version used by a page of the main application; 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 through 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; When 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 page of the sub-application is updated using the second target language file, so that the sub-application is consistent with the updated language version of the main application.

2. The method for language switching according to claim 1, characterized in that: 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 method for language switching according to claim 2, characterized in that: 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 as to load the first target language file by accessing the first access address through the loading module; When the loading module successfully loads the first target language file, directly acquiring 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 method for language switching according to claim 1, characterized in that: 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 method for language switching according to claim 1, characterized in that: The method further comprises: After acquiring the second language version used by the page of the sub-application, 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 method for language switching 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 method for language switching 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; In the case that 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 method for language switching according to claim 1, characterized in that: The micro-front-end 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 of the main application, and calling the loading module to load the first target language file based on the call request of 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, which are used to enable 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

  • Multi-language switching method and device for application program and electronic equipment

    CN117873624A

  • Cross-process development method, cross-process data processing method, vehicle, device and product

    CN118227133A

  • Screen reader language switching for user interface

    US11656886B1