Multilingual front-end page implementation methods, devices, media, and electronic devices
By setting source text sets and target language text sets in the front-end page, and automatically extracting and assigning identifiers, the problem of manually setting text codes in multilingual development is solved, which simplifies the development and makes the project code more efficient to maintain, thus improving development and maintenance efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- LUCKY COFFEE INFORMATION TECH (XIAMEN) CO LTD
- Filing Date
- 2026-03-26
- Publication Date
- 2026-06-30
Smart Images

Figure CN122309009A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to front-end page display technology, and in particular to a multilingual front-end page implementation method, a multilingual front-end page implementation device, a storage medium, and an electronic device. Background Technology
[0002] A front-end page (such as a web front-end page) refers to a visual interface that is directly visible to the user and interactive (allowing users to perform interactive operations such as input, swiping, zooming, and closing). With the internationalization of software products, there is also a growing demand for diverse language support for front-end pages.
[0003] In the process of enabling front-end pages to support multiple languages, the development cycle, implementation complexity, and maintenance costs of display front-end pages are technical issues that deserve attention. Summary of the Invention
[0004] To address the aforementioned technical problems, this disclosure is proposed. Embodiments of this disclosure provide a method for implementing multilingual front-end pages, an apparatus for implementing multilingual front-end pages, a storage medium, and an electronic device.
[0005] According to a first aspect of the embodiments of this disclosure, a method for implementing a multilingual front-end page is provided. The method includes a source text set and at least one target language text set. The source text set stores correspondence information between source text identifiers and source texts. The target language text set stores correspondence information between source text identifiers and target language texts. The source texts in the source text set are extracted from project code used to implement the front-end page. The source text identifiers in the source text set and the target language text set are automatically assigned to the source texts. The method... The process includes the following steps: obtaining the currently selected target language, the set of source texts, and the set of target language texts corresponding to the currently selected target language; determining the identifier of the source text to be translated in the front-end page based on the set of source texts; determining the target language text corresponding to the identifier of the source text to be translated based on the identifier of the source text to be translated and the set of target language texts corresponding to the currently selected target language; and performing front-end page rendering processing based on the target language text corresponding to the identifier of the source text to be translated to generate a front-end page based on the currently selected target language.
[0006] According to a second aspect of the present disclosure, a multilingual front-end page implementation apparatus is provided, comprising: a storage module for storing a pre-set set of source text and at least one set of target language text, wherein the source text set stores correspondence information between source text identifiers and source texts, and the target language text set stores correspondence information between source text identifiers and target language texts; the source texts in the source text set are extracted from project code used to implement the front-end page, and the source text identifiers in the source text set and the target language text set are automatically assigned to the extracted source texts; and an acquisition module for acquiring... The system comprises: a current target language, the set of source texts, and the set of target language texts corresponding to the currently selected target language; an identifier determination module, used to determine the identifier of the source text to be translated in the front-end page based on the set of source texts; a target language text determination module, used to determine the target language text corresponding to the identifier of the source text to be translated based on the identifier of the source text to be translated and the set of target language texts corresponding to the currently selected target language; and a rendering module, used to perform front-end page rendering processing based on the target language text corresponding to the identifier of the source text to be translated, generating a front-end page based on the currently selected target language.
[0007] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, the storage medium storing a computer program for implementing any of the methods described above.
[0008] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; the processor being configured to read the executable instructions from the memory and execute the instructions to implement any of the methods described above.
[0009] Based on the multilingual front-end page implementation method, apparatus, storage medium, and electronic device provided in the above embodiments of this disclosure, by distinguishing all languages supported by the front-end page, one language is designated as the source text language, and other languages or all languages are designated as the target language text language. The source text is then directly used in the project code. This not only makes the project code more intuitive, clearer, and more in line with the writing and reading habits of those responsible for the project code, but also enables the automatic extraction of all source texts involved in the project code using appropriate tools (such as command-line tools), and the automatic assignment of source text identifiers to the extracted source texts. This avoids the tedious, time-consuming, and error-prone manual setting of source text identifiers in the project code, and also reduces the difficulty and complexity of project code development and maintenance. For example, it facilitates quick troubleshooting during project code development and maintenance. Furthermore, when modifying a source text in the project code, this method can be reused. The disclosed technical solution automatically extracts and assigns source text identifiers to the project code, thus helping to avoid the problem that modifications to source text in one part of the project code by developers and maintainers will lead to modifications to other source text in the project code. By using source text identifiers and source text to set up a source text set, it is easy to obtain the source text identifier to be translated corresponding to the source text to be translated in the front-end page. By using source text identifiers and target language text to set up a target language set, it is easy to obtain the target language text corresponding to the source text identifier to be translated. In this way, during the rendering process, the obtained target language text can be conveniently used to generate a front-end page based on the user-specified language. In addition, in the face of the complex situation where all languages are used as the target language text, this disclosure can flexibly modify the corresponding text content in the front-end page by modifying the target language text in the corresponding relationship in the target language text set corresponding to the language of the source text, when it is inconvenient to modify the project code or when it is necessary to keep the project code. Therefore, the technical solution provided in this disclosure not only helps ensure the reliability of project code, but also simplifies the development and maintenance of project code, thereby improving the efficiency of project code development and maintenance, and consequently reducing the implementation cost of project code development and maintenance.
[0010] The technical solutions of this disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0011] The above and other objects, features, and advantages of this disclosure will become more apparent from the more detailed description of the embodiments thereof in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of this disclosure and form part of the specification. They are used together with the embodiments of this disclosure to explain the disclosure and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same components or steps.
[0012] Figure 1 This is a flowchart of an embodiment of the multilingual front-end page implementation method disclosed herein;
[0013] Figure 2 A flowchart of another embodiment of the multilingual front-end page implementation method disclosed herein is provided;
[0014] Figure 3 This is a schematic diagram of the structure of an embodiment of the multilingual front-end page implementation device disclosed herein;
[0015] Figure 4 This is a structural diagram of an electronic device provided in an exemplary embodiment of this disclosure. Detailed Implementation
[0016] Example embodiments according to this disclosure will now be described in detail with reference to the accompanying drawings. It is obvious that the described embodiments are merely some embodiments of this disclosure, and not all embodiments of this disclosure, and it should be understood that this disclosure is not limited to the example embodiments described herein.
[0017] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of this disclosure.
[0018] Those skilled in the art will understand that the terms "first," "second," etc., in the embodiments of this disclosure are only used to distinguish different steps, devices, or modules, and do not represent any specific technical meaning, nor do they indicate a necessary logical order between them.
[0019] It should also be understood that in the embodiments disclosed herein, "a plurality of" may refer to two or more, and "at least one" may refer to one, two or more.
[0020] It should also be understood that any component, data or structure mentioned in the embodiments of this disclosure can generally be understood as one or more unless expressly defined or given to the contrary in the context.
[0021] Furthermore, the term "and / or" in this disclosure is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this disclosure generally indicates that the preceding and following related objects have an "or" relationship.
[0022] It should also be understood that the description of the various embodiments in this disclosure emphasizes the differences between the various embodiments, and the similarities or similarities can be referred to each other. For the sake of brevity, they will not be described in detail.
[0023] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.
[0024] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit this disclosure or its application or use.
[0025] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.
[0026] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0027] The embodiments of this disclosure can be applied to electronic devices such as terminal devices, computer systems, and servers, and can operate with a wide range of other general-purpose or special-purpose computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments, and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, or servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments that include any of the above systems, etc.
[0028] Electronic devices such as terminal devices, computer systems, and servers can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in a distributed cloud computing environment. In a distributed cloud computing environment, tasks can be performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can reside on local or remote computing system storage media, including storage devices.
[0029] This disclosure outlines
[0030] In the process of realizing this disclosure, the inventors discovered that if the front-end page needs to support multiple languages, the project code manager often needs to manually set text codes for the text that should appear on the front-end page. For example, the project code manager manually sets text codes for each text based on the attribute characteristics of each text on the front-end page (such as the text name and path). Then, the project code manager needs to set multilingual text for each text code and store the correspondence information between each text code and the corresponding text for each language. In this way, the project code manager will use text codes to represent the text on the front-end page in the project code. Thus, when generating the front-end page using the project code, the corresponding text for the text code in the project code can be obtained from the correspondence information corresponding to the language selected by the user, and finally, the front-end page based on the user's selected language is presented to the user.
[0031] The aforementioned methods of implementing front-end pages increase the difficulty and complexity of project code development and maintenance. For example, manually setting text codes is tedious and time-consuming. Furthermore, if a text code is used in multiple places, and the project code manager (such as developers or maintainers) deems a particular text usage on the front-end page inappropriate and needs to modify the corresponding text in the collection, a change may lead to multiple changes, meaning that the text corresponding to other places using the same text code in the project code will also be modified, potentially resulting in inappropriate wording on the front-end page after the modification. Additionally, multiple text codes may correspond to the same text, increasing the difficulty of maintaining the text-to-text code correspondence information. Moreover, during project code troubleshooting, the project code manager often needs to first use the text code in the project code to find its corresponding text in the corresponding correspondence information, and then use the found text to further determine if a problem exists; this process is not conducive to rapid problem localization.
[0032] Using text directly in the project code instead of text codes not only better suits the writing and reading habits of the project code owner, making the project code clearer and easier to understand, thus reducing the difficulty of development and maintenance (for example, facilitating troubleshooting during development and maintenance), but also allows for the automatic extraction of all relevant text from the project code. This makes it possible to automatically establish the correspondence between text and text tags, avoiding the tedious and time-consuming process of manually setting text codes, reducing the difficulty of maintaining the correspondence between text and text tags, and preventing changes to text in one part of the front-end page from affecting other parts of the text.
[0033] Exemplary Overview
[0034] The technical solution for multilingual front-end page implementation disclosed herein can be applied to a variety of application scenarios, such as software development and maintenance application scenarios in electronic devices such as desktop computers, laptop computers, mobile phones and tablet computers.
[0035] A concrete example is the development of a browser client application for desktop and laptop computers. Assume the browser client supports N (N is an integer greater than 1) languages (such as Chinese, English, French, and German). Developers can use text from one language as the source text and text from other languages or all languages as the target language text. Developers can use the source text while writing the browser client's project code. After the initial writing of the browser client's project code is completed, this disclosure can use appropriate tools to scan and extract the project code, thereby obtaining all the source text used in the project code. Then, this disclosure can use appropriate tools to automatically classify all the source text. By assigning source text identifiers, different source texts will have different source text identifiers. This disclosure can also utilize appropriate tools to set target language texts for all source texts. For example, this disclosure can provide all source texts to a translation platform, and then obtain the target language texts for all source texts by receiving the results returned by the translation platform. In this way, this disclosure can store the correspondence information between source text identifiers and source texts as a source text set, and store the correspondence information between source text identifiers and target language texts as a target language text set (Note: different target language text sets are set for different languages). After successfully setting the source text set and N target language text sets, a Web (World Wide Web) based on the user's currently selected target language is formed on the browser client. In the process of creating a front-end page for the Wide Web (WWW), the browser client first uses the correspondence information in the source text set to determine the source text identifier to be translated in the front-end page. Then, it uses the correspondence information in the set of source text identifiers and the target language currently selected by the user to determine the target language text corresponding to the source text identifier. Thus, it can use the currently obtained target language text to perform rendering processing and form the front-end page of the browser client to be displayed to the user.
[0036] Another concrete example is in the development of an App for mobile phones or tablets. Suppose the App supports N languages (N being an integer greater than 1) (such as Chinese, English, French, and German). Developers can use the text in one language as the source text and the text in other languages or all languages as the target language text. Developers can use the source text while writing the App's project code. After the initial writing of the project code is completed, this disclosure can use appropriate tools to scan and extract the App's project code, thereby obtaining all the source text used in the project code. Then, this disclosure can use appropriate tools to automatically assign source text identifiers to all source texts, ensuring that different source texts have different source text identifiers. This disclosure can also use appropriate tools to set target language text for all source texts. For example, this disclosure can provide all source texts to a translator. The app uses a translation platform to obtain the target language texts of all source texts by receiving the results returned by the translation platform. Thus, this disclosure allows the storage of the correspondence between source text identifiers and source texts as a source text set, and the storage of the correspondence between source text identifiers and target language texts as a target language text set (note: different target language text sets are set for different languages). After successfully setting the source text set and all target language text sets, during the process of the app forming the app front-end page based on the user's currently selected target language, the app first uses the correspondence information in the source text set to determine the source text identifier to be translated, and then uses the correspondence information in the set corresponding to the source text identifier to be translated and the currently selected target language to determine the target language text corresponding to the source text identifier to be translated. Therefore, the app can use the currently obtained target language texts to perform rendering processing to form the app front-end page to be displayed to the user.
[0037] Another concrete example is a scenario where a mini-program (i.e., a lightweight application that runs on a parent platform (such as WeChat, Alipay, or Douyin) and does not require separate download and installation by the user) is developed for mobile phones or tablets. Assuming the mini-program supports N (N is an integer greater than 1) languages (such as Chinese, English, French, and German), developers can use the text in one language as the source text and the text in other languages or all languages as the target language text. Developers can use the source text while writing the mini-program's project code. After the initial writing of the project code is completed, this disclosure can use appropriate tools to scan and extract the mini-program's project code to obtain all the source text used in the project code. Then, this disclosure can use appropriate tools to automatically assign source text identifiers to all source texts, ensuring that different source texts have different source text identifiers. This disclosure can also use appropriate tools to set target language texts for each source text, for example... This disclosure allows all source texts to be provided to a translation platform, thereby obtaining the target language texts of all source texts by receiving the results returned by the translation platform. In this way, this disclosure can store the correspondence information between source text identifiers and source texts as a source text set, and store the correspondence information between source text identifiers and target language texts as a target language text set (Note: different target language text sets are set for different languages). After successfully setting the source text set and all target language text sets, in the process of the mini-program forming a front-end page based on the user's currently selected target language, the mini-program first uses the correspondence information in the source text set to determine the source text identifier to be translated, and then uses the correspondence information between the source text identifier to be translated and the set corresponding to the currently selected target language to determine the target language text corresponding to the source text identifier to be translated. Thus, the currently obtained target language text can be used to perform rendering processing to form a mini-program front-end page for display to the user.
[0038] Exemplary methods
[0039] The multilingual front-end page implementation method disclosed herein requires the pre-setting of a source text set and one or more target language text sets. The pre-setting in this disclosure includes the initial setting and the update setting after the initial setting.
[0040] In one example, the initial setup of the source copy set and the target language copy set can be done after the initial coding of a project is completed.
[0041] In another example, a source text set and a target language text set already exist before the initial code of a project is completed. After the initial code is completed, these existing sets can be updated. Specifically, these existing sets can be formed from initialization sets; for example, the initialization set contains a small number of commonly used source texts and their corresponding source text identifiers, and the initialization set contains a small number of commonly used source texts and their corresponding source text identifiers and their corresponding target language identifiers. Alternatively, these sets can be formed based on code from other projects. For example, a system may be divided into multiple modules. After developing code for one module, a source text set and multiple target language text sets are formed. During the development of code for other modules, these existing sets can be updated (e.g., incrementally).
[0042] In another example, if maintaining a project's code involves modifying the source text within that project's code, this disclosure allows for updating the existing set of source text and the target language text set (e.g., incrementally) after the project's code has been maintained.
[0043] In this disclosure, project code refers to program code used to implement front-end pages. For example, project code can be program code for a web-based browser client, app-based program code, or mini-program-based program code. This disclosure does not limit the specific form of the project code.
[0044] In this disclosure, source text refers to text created for a front-end page using a language supported by the front-end page. The language used in the source text can be determined by the project code manager. For example, the project code developers can choose English or Chinese as the language for the source text according to their habits.
[0045] The target language copy in this disclosure also refers to the copy created for the front-end page in a language supported by the front-end page. However, in one example, the language used in the target language copy may be different from the language used in the source copy. For example, if the project code developers use Chinese as the language of the source copy, the language used in the target language copy may be English, German, or French. In another example, the language used in the target language copy may be the same as the language used in the source copy. For example, if the project code developers use Chinese as the language of the source copy, the language used in the target language copy may be Chinese, English, German, or French.
[0046] The copywriting mentioned above refers to the text content that needs to be displayed on the front-end page. For example, the copywriting in this disclosure can be the text content on buttons on the front-end page, the text content on each menu item in the drop-down menu on the front-end page, and the text content in the theme bar of the front-end page, etc. This disclosure does not limit the language used in the source copywriting, the language used in the target language copywriting, the specific content of the copywriting, or the form in which the copywriting is presented on the front-end page.
[0047] The number of target language copy sets pre-set in this disclosure is usually related to the number of languages supported by the front-end page. For example, if the front-end page supports N (N is an integer greater than 1) languages, one language is used as the language used in the source copy, and the other languages are used as the languages used in the target language copy. Therefore, the number of target language copy sets pre-set in this disclosure is N-1. As another example, if the front-end page supports N (N is an integer greater than 1) languages, one language is used as the language used in the source copy, and all languages are used as the languages used in the target language copy. Therefore, the number of target language copy sets pre-set in this disclosure is N.
[0048] The source text collection in this disclosure is used to store the correspondence information between source text identifiers and source texts. The source text collection can be implemented using a file based on a lightweight text data exchange format. For example, the source text collection can be implemented using a JSON (JavaScript Object Notation) file, that is, the correspondence information between source text identifiers and source texts is stored in a JSON file in a predetermined format.
[0049] The target language copy set in this disclosure is used to store the correspondence information between source copy identifiers and target language copy. The target language copy set can also be implemented using a file based on a lightweight text data exchange format. For example, the target language copy set can also be implemented using a JSON file. That is, for any target language, the correspondence information between source copy identifiers and target language copy is stored in a JSON file in a predetermined format.
[0050] In one example, some or all of the source text in the source text set of this disclosure are automatically extracted from the project code used to implement the front-end page, and some or all of the source text identifiers in the source text set of this disclosure are assigned to the source text using an automatic allocation method. That is to say, this disclosure allows the direct use of source text in the project code, instead of using manually set codes for the text by the project code developers. This makes the project code more intuitive, clear, and easy to read, thus facilitating the development and maintenance of the project code. Moreover, by automatically extracting source text from the project code and automatically assigning source text identifiers to the extracted source text, it helps avoid human errors during the manual coding process for the source text and facilitates the efficient setting of the source text set and the target language text set.
[0051] In one example, this disclosure can use preset rules to scan project code (such as line-by-line sequential scanning), thereby automatically extracting source text that conforms to the preset rules from the project code. Then, source text identifiers can be automatically assigned to all the source texts obtained so as to establish the correspondence between source texts and source text identifiers. This correspondence information can be stored in the source text collection.
[0052] In one example, the aforementioned preset rule can be a preset regular expression. That is, this disclosure can use a preset regular expression to scan the project code (such as scanning line by line) and thus automatically extract all source text that matches the regular expression from the project code. The specific form of the regular expression is usually related to the specific format of the programming statements containing the source text in the project code, and this disclosure does not limit the specific form of the regular expression.
[0053] In one example, after obtaining the source text using preset rules (such as regular expressions), this disclosure can first perform deduplication on all the source texts obtained so far, that is, remove duplicate source texts from all the source texts obtained by scanning, so as to ensure the uniqueness of the source texts obtained from the project code. Then, source text identifiers are assigned to each of the source texts retained after deduplication.
[0054] The first example of deduplication involves pre-setting a cache list, which can initially be empty. During the scanning of the project code using preset rules, for each source text obtained in the current scan, it is compared with source texts in the cache list. If the source text does not exist in the cache list, it is stored there. If the source text already exists in the cache list, it can be discarded or used to overwrite an existing identical source text in the cache list. The process continues, comparing another source text obtained in the current scan with source texts stored in the cache list, and so on, until the scanning of the project code is complete. The final cache list contains all the deduplicated source texts. This disclosure, by deduplicating all source texts obtained in the scan, helps avoid assigning different source text identifiers to identical source texts obtained in the scan, thus ensuring the robustness of the correspondence between source texts and source text identifiers.
[0055] The second example of deduplication involves pre-setting a cache list. All source documents in the current source document set are written to this cache list. During the scanning of the project code using preset rules, for each source document obtained in the scan, it is compared with the source documents in the cache list. If the source document does not exist in the cache list, it is stored there. If it already exists, it can be discarded or used to overwrite an existing identical source document in the cache list. The process continues, comparing another source document obtained in the scan with the source documents stored in the cache list, and so on, until the project code scanning is complete. The final cache list contains all the deduplicated source documents. This disclosure, by deduplicating all source documents obtained in the scan, helps avoid assigning different source document identifiers to identical source documents, thus ensuring the robustness of the correspondence between source documents and their identifiers.
[0056] In one example, this disclosure can assign source document identifiers to the source documents retained after deduplication based on a random identifier allocation method. Here, random identifier allocation means that when generating source document identifiers for source documents, the identifiers are not formed based on a regular rule, but rather based on a random rule. That is, there is no regularity between the source document identifiers assigned by this disclosure to two different source documents, and there is also no regularity between the source document identifier assigned by this disclosure to a source document and the source document itself. In other words, it can be considered that the source document identifiers assigned by this disclosure to the same source document on two separate occasions are generally different. The aforementioned random identifier allocation method can be a UUID (Universally Unique Identifier) allocation method. For example, the source document identifier assigned to a source document is an identifier consisting of a 32-bit hexadecimal number and four hyphens. By employing a random identifier allocation method, especially the UUID allocation method, to assign source text identifiers, this disclosure can support the distributed allocation of source text identifiers, thereby helping to ensure the efficiency of setting up source text sets and target language text sets.
[0057] This disclosure can assign a UUID to each source text in the cache list, or it can assign a UUID to each newly added source text in the cache list. For example, if this disclosure uses the deduplication method in the first example above, it can assign a source text identifier to each source text in the cache list; while if this disclosure uses the deduplication method in the second example above, it can assign a source text identifier to each newly added source text in the cache list.
[0058] When this disclosure adopts the deduplication method described in the first example above, after assigning a source text identifier to a source text in the cache list, the process of storing the correspondence information between the source text identifier and the source text in the source text set should employ an incremental update method to store this correspondence information in the source text set, thereby ensuring the uniqueness of the source texts in the source text set. For example, after assigning a source text identifier to a source text in the cache list, the source text can be used to search within the source text set. If the source text already exists in the source text set, the correspondence information between the source text identifier and the source text can be discarded, or it can be used to overwrite the existing correspondence information in the source text set. If the source text does not exist in the source text set, the correspondence information between the source text identifier and the source text should be added to the source text set. For example, after assigning source document identifiers to all source documents in the cache list, the process of searching for the source document in the source document set is performed sequentially according to the order of the source documents in the cache list. If the source document already exists in the source document set, the correspondence between the source document identifier and the source document can be discarded, or the correspondence between the source document identifier and the source document can be used to overwrite the correspondence between the source document and the source document that already exists in the source document set. If the source document does not exist in the source document set, the correspondence between the source document identifier and the source document should be added to the source document set. This disclosure, by performing a judgment process on whether the source document exists in the source document set during the process of storing the correspondence information in the source document set, helps to avoid assigning different source document identifiers to the same source document, thereby further ensuring the robustness of the correspondence information between the source document and the source document identifier.
[0059] When this disclosure adopts the deduplication method described in the second example above, during the process of storing the correspondence information between source text identifiers and source texts in the source text set, an incremental update method can be used to store the correspondence information between source text identifiers and source texts in the source text set, thereby ensuring the uniqueness of the source texts in the source text set. For example, after assigning source text identifiers to all newly added source texts in the cache list, the correspondence information between the newly added source texts and source text identifiers can be directly stored in the source text set. Another specific example is that after assigning source text identifiers to all source texts in the cache list, the correspondence information between all source texts and source text identifiers in the cache list can be used to overwrite all the correspondence information stored in the source text set, or the source text set can be cleared first, and then the correspondence information between all source texts and source text identifiers in the cache list can be stored in the source text set. Since the cache list contains all source texts in the source text set before clearing / overwriting, the above methods of clearing and then storing, and overwriting the stored correspondence information, belong to the incremental update method. This disclosure uses an incremental update method in the process of storing corresponding relationship information in the source copy set, which helps to avoid the phenomenon that the source copy set contains the same source copy, thereby helping to ensure the robustness of the source copy set.
[0060] In one example, this disclosure can store the correspondence information between source text identifiers and source text in the form of key-value pairs in a source text file (such as a JSON file) based on a Lightweight Text Data Interchange (LTI) format. For example, for any correspondence information between source text identifiers and source text, a key-value pair can be formed by using the source text identifier in the correspondence information as the key and the source text in the correspondence as the value, and this key-value pair can be stored in a source text file (such as a JSON file) based on a Lightweight Text Data Interchange (LTI) format.
[0061] In one example, this disclosure can provide the scanned source texts to a translation platform and receive the target language texts returned by the translation platform, thereby obtaining the correspondence information between the source text identifiers and the target language texts. This disclosure can store the correspondence information between the source text identifiers and the target language texts in the form of key-value pairs in the corresponding target language text file (such as a JSON file). For example, for any correspondence information between a source text identifier and a target language text, a key-value pair can be formed by using the source text identifier as the key and the target language text as the value, and this key-value pair can be stored in the target language text file (such as a JSON file) based on a lightweight text data exchange format.
[0062] This disclosure uses key-value pairs to store the correspondence between source text identifiers and source text, as well as the correspondence between source text identifiers and target language text. This facilitates the easy acquisition of target language text from source text, thereby enabling timely display of the front-end page to the user. By using source text files and target language text files (especially JSON files) based on a lightweight text data exchange format to store the correspondence information, it not only reduces the consumption of storage resources by the files but also ensures the speed of parsing the stored correspondence information during subsequent processing.
[0063] Figure 1 This is a flowchart of an embodiment of the multilingual front-end page implementation method disclosed herein. Figure 1 The method shown includes steps S100, S101, S102, and S103. The following describes... Figure 1 Each step in the process will be explained separately.
[0064] S100: Obtain the currently selected target language, the set of source texts, and the set of target language texts corresponding to the currently selected target language.
[0065] The currently selected target language in this step can be the language chosen by the user for the currently displayed front-end page. For example, if the source text is in English (i.e., the text on the front-end page is in English by default), and the user wants the text on the front-end page to be in Chinese, the user can select the language through the language selection menu / button on the current front-end page, thus setting the current target language to Chinese. Similarly, if the source text is in English (i.e., the text on the front-end page is in English by default), and the user wants the text on the front-end page to be in English, the user can select the language through the language selection menu / button on the current front-end page, thus setting the current target language to English. In other words, the user's currently selected target language can be the same as or different from the language used in the source text.
[0066] The source text set and target language text set obtained in this step can be the source text set and target language text set formed in the manner described in the above embodiments. The source text set and target language text set can be obtained from the local device (i.e., the source text set and target language text set are pre-stored on the local device) or temporarily obtained from the network side (i.e., the source text set and target language text set are pre-stored on the network side). This disclosure can obtain the source text set and target language text set from the network side by requesting the network side, or it can obtain the source text set and target language text set from information actively pushed by the network side. Since the source text set and target language text set may change during the development and maintenance of the project code, temporarily obtaining the source text set and target language text set from the network side helps ensure the accuracy of the source text set and target language text set used in this disclosure.
[0067] In one example, if the user's current target language is the same as the language used in the source text, the correspondence information contained in the target language text set corresponding to the currently selected target language obtained in this step may be the same as or different from the correspondence information contained in the source text set. A more concrete example: Before the project code goes live, the source text set can be copied, and the copied source text set can be used as the target language text set corresponding to the language used by the source text. Unless the target language text set is subsequently modified, the two are identical. After the project code goes live, if it is found that a piece of text content on the front-end page (the language used by the source text) needs to be modified, and it is temporarily inconvenient to modify the source text content in the project code, this disclosure can modify the target language text in the corresponding relationship of the target language text set corresponding to the language used by the source text, thereby modifying the text content on the front-end page. In the event of the above operation, the correspondence information contained in the target language text set corresponding to the currently selected target language obtained in this step is different from the correspondence information contained in the source text set. By setting a target language copy set for the language used in the source copy, it is easy to temporarily modify the copy content on the front-end page, thereby improving the flexibility of modifying the copy content on the front-end page and thus improving the flexibility of front-end page implementation.
[0068] S101. Determine the source text identifier to be translated for the source text to be translated in the front-end page based on the source text set.
[0069] In this step, the front-end page refers to the page displayed to the user, created by running the project code. The source text to be translated on the front-end page typically belongs to a collection of source texts. Specifically, the source text to be translated in this step refers to the source text used in the project code, such as the text displayed in the default language on the front-end page. Additionally, the source text to be translated can refer to the text involved in internationalization translation functions (such as the `$t` function) in the project code. If the input parameters of the `$t` function contain the source text to be translated, then the source text to be translated can be obtained based on the input parameters of the internationalization translation function. In one example, the internationalization translation function can be used as an instance or a global object.
[0070] In one example, in step S100, this disclosure can pre-generate a reverse mapping table from source text to source text identifier based on the source text set (i.e., parse the source text set to form a Map from value to key, where the Map can be a dictionary, associative array, etc.). Thus, when determining the source text identifier corresponding to the source text to be translated, this reverse mapping table can be used to quickly obtain the source text identifier. Specifically, using the source text to be translated in the front-end page as the value, the key corresponding to that value is searched in the reverse mapping table. Since this disclosure ensures the uniqueness of the source text during the storage of the correspondence information between the source text and the source text identifier, the number of keys obtained from searching the reverse mapping table is usually not multiple. Moreover, by pre-generating a reverse mapping table for the source text set, the time overhead of traversal queries can be avoided, thus facilitating the quick and efficient acquisition of the source text identifier, and consequently ensuring the timeliness of displaying the front-end page to the user.
[0071] The lookup operation in this step can be performed by the internationalization translation function (such as the $t function) in the project code. That is, the source text to be translated is set in the input parameters of the internationalization translation function (such as the $t function). The internationalization translation function takes the source text to be translated in the input parameters as the value and looks up the key corresponding to the value in the reverse mapping table, so that the internationalization translation function obtains the identifier of the source text to be translated.
[0072] In one example, the operation of generating a reverse mapping table from source texts to source text identifiers based on the source text set in this disclosure can be executed in the renderer (i.e., the multilingual renderer) in the project code. Specifically, the renderer first determines whether a reverse mapping table exists. If a reverse mapping table exists, the internationalization translation function continues to perform the operation of finding the source text identifier to be translated in the reverse mapping table. If a reverse mapping table does not exist, the renderer first performs the operation of generating the reverse mapping table, and then the internationalization translation function performs the operation of finding the source text identifier to be translated in the reverse mapping table. Of course, the above operation of generating the reverse mapping table can also be performed without the renderer; for example, it can be performed by the internationalization translation function, and this disclosure does not limit this.
[0073] S102. Based on the source text identifier to be translated obtained above and the target language text set corresponding to the currently selected target language, determine the target language text corresponding to the source text identifier to be translated.
[0074] In one example, in step S100, this disclosure can pre-generate a mapping table from source text identifiers to target language texts based on the target language text set corresponding to the currently selected target language (i.e., parsing the target language text set to generate a key-to-value Map, such as a dictionary or associative array). Thus, when executing step S102, this mapping table can be used to quickly obtain the target language text corresponding to the source text identifier to be translated. Specifically, using the source text identifier obtained in S101 as the key, the value corresponding to that key is searched in the mapping table, thereby quickly obtaining a unique target language text. By pre-generating a mapping table for the target language text set corresponding to the currently selected target language, this disclosure avoids the time overhead of traversal queries, thus facilitating the quick and efficient retrieval of the target language text corresponding to the source text identifier to be translated, and consequently ensuring the timeliness of the front-end page display.
[0075] In another example, in step S100, this disclosure can generate a mapping table (i.e., a key-to-value Map, such as a dictionary or associative array) for each pre-set target language text set, from source text identifiers to target language texts. That is, when there are multiple target language text sets, this disclosure generates multiple mapping tables, with one mapping table corresponding to one target language text set. In this way, when performing this step, the mapping table corresponding to the target language currently selected by the user can be determined first, and the target language text corresponding to the source text identifier to be translated can be quickly obtained using this mapping table. In other words, the source text identifier to be translated obtained in S101 can be used as a key to look up the value corresponding to the key in the mapping table corresponding to the target language currently selected by the user, thereby quickly obtaining a unique target language text. This disclosure generates a mapping table in advance for each target language text set corresponding to each target language. In application scenarios where users frequently switch the target language of the front-end page, it can effectively avoid the problem of high time overhead caused by a large number of traversal query operations. This facilitates quick and efficient retrieval of the target language text corresponding to the source text identifier to be translated, thereby ensuring the timeliness of the front-end page display.
[0076] In one example, this step can be executed by an internationalization translation function (such as the $t function) in the project code. After successfully obtaining the source text identifier through S101, the internationalization translation function (such as the $t function) uses this identifier as a key to search for the value corresponding to that key in the target language text set corresponding to the currently selected target language (such as a mapping table formed by the target language text set corresponding to the user's currently selected target language). If the value corresponding to the key is successfully found, the internationalization translation function uses this value as the target language text corresponding to the source text identifier, thus obtaining a unique target language text and outputting it. If the value corresponding to the key is not successfully found, the internationalization translation function can adopt a fallback translation strategy to determine the target language text corresponding to the source text identifier (i.e., the fallback translation text) and output it. For example, the internationalization translation function can use the source text to be translated as the fallback translation text and output it. By setting a fallback translation strategy, we can avoid anomalies caused by the non-existence of the target language copy corresponding to the source copy to be translated, which helps to ensure the robustness of the front-end page.
[0077] In one example, the operation of generating a mapping table from source text identifiers to target language texts based on the target language text set in this disclosure can be executed in the renderer (i.e., the multilingual renderer) in the project code. Specifically, the renderer can first determine whether a mapping table exists formed by the target language text set corresponding to the user's currently selected target language. If a mapping table exists, the internationalization translation function continues to perform the operation of searching for the target language text corresponding to the source text identifier to be translated in the mapping table. If no mapping table exists, the renderer performs the operation of generating a mapping table (for example, the renderer generates a mapping table based on the target language text set corresponding to the user's currently selected target language; or, for example, the renderer generates a mapping table for each target language text set). Then, the internationalization translation function performs the operation of searching for the target language text corresponding to the source text identifier to be translated in the mapping table corresponding to the user's currently selected target language. Alternatively, the renderer can skip the operation of determining whether a mapping table exists and directly perform the operation of generating a mapping table. Of course, the above operation of generating a mapping table based on the target language text set can also be performed without the renderer. For example, it can be performed by the internationalization translation function, and this disclosure does not limit this.
[0078] S103. Based on the target language text corresponding to the source text identifier obtained above, perform front-end page rendering processing to generate a front-end page based on the currently selected target language.
[0079] In one example, the renderer (i.e., the multilingual renderer) obtains the target language text from the output of the internationalization translation function, and uses the obtained target language text to perform front-end page rendering operations to form the front-end page, which is then displayed to the user. This front-end page is based on the user's currently selected target language. This disclosure does not limit the rendering operations performed by the renderer.
[0080] Figure 2 This is a flowchart illustrating another embodiment of the multilingual front-end page implementation method disclosed herein. Figure 2 The method shown includes steps S200, S201, S202, S203, S204, S205, and S206. The following describes... Figure 2 Each step in the process will be explained separately.
[0081] S200, Begin the process of implementing a multilingual front-end page.
[0082] In this step, the method initialization operation can be performed. For example, a cache list for storing source text can be set up and the cache list can be initialized to empty. Another example is to set up a JSON file for each language supported by the front-end page, that is, a JSON file for each language used in the source text and a JSON file for each target language, and to initialize each JSON file.
[0083] S201. Scan the project code according to preset rules to obtain source text that conforms to the preset rules.
[0084] In one example, this disclosure can use a command-line tool to scan the project code line by line, and the project code in this disclosure is set to include the following:
[0085]
[0086] Assuming the source text uses Chinese as the language, the following regular expression can be used to scan line by line for the above project code:
[0087] \$t\(\s*([′"′])((?:\\\1|(?!\1)[\s\S])*?)\1
[0088] By scanning the code of the above projects, we can obtain the five source texts: refresh, close other, close all on the left, close all on the right, and close all.
[0089] S202. Assign source text identifiers to the source text obtained above.
[0090] This disclosure can first perform deduplication on the obtained source texts, and then assign a source text identifier to each source text retained after deduplication. For example, for each source text obtained by scanning, if the source text does not exist in the cache list, the source text is added to the cache list; if the source text exists in the cache list, the source text is discarded. After deduplication is completed for all source texts obtained by scanning, a source text identifier (such as UUID) can be assigned to each source text in the cache list based on a random identifier allocation method (such as UUID allocation method).
[0091] Continuing from the previous example, this disclosure assigns UUIDs to the five source texts mentioned above, thereby establishing a correspondence between the source texts and their identifiers. This correspondence can be expressed in the following form:
[0092] "ddfb8b60-70db-45ce-8e80-0498d520c52d": "Refresh",
[0093] "329547ba-50cb-420f-be78-8363773f245d": "Close other options",
[0094] "dcc58e05-3fb7-4c90-86d9-0a117e83d9e2": "Close all on the left",
[0095] "4d0bbbd44-ba30-44f9-82b8-ae0d08c4d821": "Close all on the right",
[0096] "1fd22126-a806-4eac-9604-e17ebc117f8e": "Close all"
[0097] S203. Store the correspondence information between source text identifiers and source text in the source text collection.
[0098] This disclosure allows for incremental updates to store the correspondence between source text identifiers and source texts in a source text collection. For example, a source text identifier is read from a cache list, and it is determined whether the JSON file corresponding to the language used in the source text contains that source text identifier. If the source text identifier is not contained, the correspondence between the source text identifier and the source text is stored in the JSON file. If the source text identifier is contained, it is discarded, and the next source text identifier is read from the cache list, until all source text identifiers in the cache list have been checked and stored.
[0099] Continuing from the previous example, this disclosure can store the correspondence information between the above five source texts and UUIDs in the form of key-value pairs (UUID as the key and source text as the value) in the JSON file corresponding to the source text.
[0100] S204. Store the correspondence information between each source copy identifier and the target language copy of the source copy corresponding to each source copy identifier in the corresponding target language copy set.
[0101] This disclosure can provide all source texts in the cache list to the translation platform, thereby obtaining the target language texts corresponding to each source text.
[0102] This disclosure allows for incremental updates of the mapping information between source text identifiers and target language text in a target language text set. For example, a source text identifier is read from a cache list, and it is determined whether the source text identifier is contained in the JSON file corresponding to the language used in the target language text. If the source text identifier is not contained, the mapping information between the source text identifier and the target language text is stored in the JSON file. If the source text identifier is contained, it is discarded, and the next source text identifier is read from the cache list, until all source text identifiers in the cache list have been checked and stored.
[0103] Continuing the previous example, assuming English is a target language, this disclosure provides the five source texts from the cache list to the Chinese-English translation platform to obtain five target language texts based on English. The correspondence between the source text identifiers and the five target language texts based on English can be expressed in the following form:
[0104] "ddfb8b60-70db-45ce-8e80-0498d520c52d": "Refresh",
[0105] "329547ba-50cb-420f-be78-8363773f245d": "Close others",
[0106] "dcc58e05-3fb7-4c90-86d9-0a117e83d9e2": "Close all on the left",
[0107] "4d0bbbd44-ba30-44f9-82b8-ae0d08c4d821": "Close all on the right",
[0108] "1fd22126-a806-4eac-9604-e17ebc117f8e": "Close all"
[0109] The above-mentioned correspondence information can be stored in the corresponding English JSON file in the form of key-value pairs (UUID as the key and target language text as the value, such as Refresh as the value) using an incremental update method.
[0110] In addition, this step can also copy the source copy set and use the copied source copy set as a target language copy set, that is, the target language corresponding to the target language copy set is the same as the target language corresponding to the source copy set.
[0111] S205. In the process of generating a front-end page based on the target language according to the project code, the source text identifier to be translated in the front-end page is determined according to the source text set, and the target language text required for the front-end page is determined according to the determined source text identifier and the target language text set corresponding to the target language currently selected by the user.
[0112] In one example, this disclosure can generate a reverse mapping table from source text to source text identifier using key-value pairs in the source text collection, and use this reverse mapping table to determine the source text identifier to be translated corresponding to the source text to be translated on the front-end page. One implementation process of generating the reverse mapping table in this disclosure can be as follows: first, create an empty reverse mapping table; then, traverse the key-value pairs in the source text collection (such as a dictionary); if the currently traversed value is a string, store the currently traversed source text and source text identifier (such as a key name path, etc.) in the reverse mapping table; if the currently traversed value is an object (such as a nested structure in a dictionary, etc.), then recursively traverse the object.
[0113] In one example, this disclosure can generate a mapping table from source text identifiers to target language texts using key-value pairs in the target language text set, and use this mapping table to determine the target language text corresponding to the source text identifier to be translated. The determination of the target language text corresponding to the source text identifier using the mapping table in this disclosure can be implemented by an internationalization translation function. One implementation process of the internationalization translation function using the mapping table to determine the target language text corresponding to the source text identifier to be translated can be as follows: The internationalization translation function first searches for the source text identifier corresponding to the source text in the reverse mapping table. If the source text identifier is successfully found, it searches for the corresponding value in the target language mapping table. If the corresponding value is successfully found, it is used as the target language text. If the source text identifier is not successfully found in the reverse mapping table or the target language text is not successfully found in the mapping table, the source text can be used as the target language text.
[0114] S206. Render the front-end page according to the target language text required by the front-end page, and generate a front-end page based on the target language currently selected by the user.
[0115] This step can be implemented by a multilingual renderer, and this disclosure does not limit the rendering processing operations performed by the multilingual renderer.
[0116] Exemplary device
[0117] The structure of one embodiment of the multilingual front-end page implementation device disclosed herein is as follows: Figure 3 As shown. The apparatus of this embodiment can be used to implement the corresponding method embodiments of this disclosure. Figure 3 The apparatus shown includes: a storage module 300, an acquisition module 301, a determination identifier module 302, a target language text determination module 303, and a rendering module 304. Optionally, the apparatus may further include: a source text set generation module 305, and a target language text set generation module 306.
[0118] The storage module 300 is primarily used to store a pre-set set of source text and at least one set of target language text. The source text set stores the correspondence between source text identifiers and source texts, and the source texts in the set are automatically extracted from the project code used to implement the front-end page. The target language text set stores the correspondence between source text identifiers and target language texts.
[0119] The acquisition module 301 is mainly used to acquire the currently selected target language and to acquire the source text set and the target language text set corresponding to the currently selected target language from the storage module 300.
[0120] In one example, the acquisition module 301 can generate a reverse mapping table from source text to source text identifiers based on the source text set stored in the storage module 300. That is, the acquisition module 301 parses the source text set stored in the storage module 300 and generates the reverse mapping table. Thus, the identifier determination module 302 can use this reverse mapping table to determine the source text identifier corresponding to the source text to be translated on the front-end page. For example, the internationalization translation function in the identifier determination module 302 uses the source text to be translated in its input parameters and retrieves the source text identifier corresponding to the source text to be translated from the reverse mapping table. The part of the acquisition module 301 that generates the reverse mapping table can be considered as the first parser, and the specific operations performed by the first parser can be found in the relevant content described in S205 of the above method, which will not be described in detail here.
[0121] In one example, the acquisition module 301 can generate a mapping table from source text identifiers to target language texts based on the target language text set. Specifically, the acquisition module 301 parses the target language text set stored in the storage module 300 and generates the mapping table. For instance, the acquisition module 301 generates the mapping table from source text identifiers to target language texts based on the target language text set corresponding to the currently selected target language. As another example, the acquisition module 301 generates separate mapping tables from source text identifiers to target language texts for each target language text set. In this way, the target language text determination module 303 can obtain the target language text corresponding to the source text identifier to be translated based on the mapping table. For example, the internationalization translation function in the target language text determination module 303 uses the source text identifier to be translated as the key and searches for the value corresponding to the key in the mapping table corresponding to the currently selected target language. If the value corresponding to the key is found, the target language text determination module 303 uses the value corresponding to the key as the target language text corresponding to the source text identifier to be translated. If the value corresponding to the key is not found, the target language text determination module 303 uses the source text to be translated as the target language text corresponding to the source text identifier to be translated. The part of obtaining the mapping table in the module 301 can be considered as the second parser, and the specific operations performed by the second parser can be found in the relevant content recorded in S205 of the above method, which will not be described in detail here.
[0122] The specific operations performed by module 301 can be found in step S100 of the above method, and will not be described in detail here. It should be noted that the first parser and the second parser in this disclosure can be combined to form a single parser.
[0123] The identifier determination module 302 is mainly used to determine the identifier of the source text to be translated in the front-end page based on the source text set obtained by the acquisition module 301. The specific operations performed by the identifier determination module 302 can be found in step S101 of the above method, and will not be described in detail here.
[0124] The target language text determination module 303 is mainly used to determine the target language text corresponding to the source text text identifier to be translated based on the identifier to be translated determined by the identifier determination module 302 and the set of target language texts corresponding to the currently selected target language. The specific operations performed by the target language text determination module 303 can be found in step S102 of the above method, and will not be described in detail here.
[0125] The rendering module 304 is mainly used to perform front-end page rendering processing based on the target language copy corresponding to the source copy identifier to be translated obtained by the target language copy determination module 303, generating a front-end page based on the currently selected target language. The specific operations performed by the rendering module 304 can be found in step S103 of the above method, and will not be described in detail here.
[0126] The source text collection generation module 305 is mainly used to generate a source text collection based on the project code and store the generated source text collection in the storage module 300.
[0127] In one example, the source text collection generation module 305 may include: a scanning submodule 3051, an assignment identifier submodule 3052, and a correspondence submodule 3053.
[0128] The scanning submodule 3051 is mainly used to scan the project code according to preset rules, thereby obtaining the source text in the project code that conforms to the preset rules. For example, the scanning submodule 3051 can scan the project code according to preset regular expressions to obtain the source text in the project code that conforms to the regular expressions.
[0129] The identifier allocation submodule 3052 is mainly used to assign source text identifiers to the source text obtained by the scanning submodule 3051. Specifically, the identifier allocation submodule 3052 can first perform deduplication processing on the source text currently scanned by the scanning submodule 3051, and then assign source text identifiers to the source text retained after deduplication. In one example, the identifier allocation submodule 3052 assigns source text identifiers to the source text retained after deduplication based on a random identifier allocation method. For example, the identifier allocation submodule 3052 can assign UUIDs to the source text retained after deduplication based on a UUID allocation method.
[0130] The mapping submodule 3053 is mainly used to store the mapping information between source text identifiers and source texts in the source text collection in the storage module 300 after the assignment identifier submodule 3052 assigns source text identifiers to the source texts. Specifically, the mapping submodule 3053 can store the mapping information between source text identifiers and source texts in the source text collection based on an incremental update method. In one example, the mapping submodule 3053 can store the source text identifiers and source texts in the form of key-value pairs in a source text file (such as a JSON file) based on a lightweight text data exchange format.
[0131] The specific operations performed by the scanning submodule 3051, the allocation identifier submodule 3052, and the correspondence submodule 3053 can be found in steps S201, S202, and S203 of the above method, and will not be described in detail here.
[0132] The target language text set generation module 306 is mainly used to generate a target language text set and store the generated target language text set in the storage module 300. For example, the target language text set generation module 306 can provide the source texts obtained by the scanning submodule 3051 or the source texts retained after deduplication by the assignment identifier submodule 3052 to the translation platform, and receive the target language texts of each source text returned by the translation platform. Then, the target language text set generation module 306 stores each source text identifier and the target language text of each source text identifier in the form of key-value pairs in the corresponding target language text file (such as a JSON file) based on a lightweight text data exchange format. The specific operations performed by the target language text set generation module 306 can be found in the content described in S204 of the above method, and will not be described in detail here.
[0133] Exemplary electronic devices
[0134] The following is for reference. Figure 4 To describe an electronic device according to embodiments of the present disclosure. Figure 4 A block diagram of an electronic device according to an embodiment of the present disclosure is shown. (As follows) Figure 4 As shown, the electronic device 41 includes one or more processors 411 and memory 412.
[0135] The processor 411 may be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 41 to perform desired functions.
[0136] The memory 412 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include random access memory (RAM) and / or cache memory. The non-volatile memory may, for example, include read-only memory (ROM), hard disk, and flash memory. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 411 may execute the program instructions to implement the multilingual front-end page implementation methods of the various embodiments of this disclosure described above, and / or other desired functions.
[0137] In one example, electronic device 41 may further include input device 413 and output device 414, etc., these components being interconnected via a bus system and / or other forms of connection mechanism (not shown). Furthermore, the input device 413 may also include, for example, a keyboard, mouse, etc. The output device 414 can output various information to the outside. The output device 414 may include, for example, a display, speaker, printer, and communication networks and their connected remote output devices, etc.
[0138] Of course, for the sake of simplicity, Figure 4 Only some of the components of the electronic device 41 relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device 41 may include any other suitable components depending on the specific application.
[0139] Exemplary computer program products and computer-readable storage media
[0140] In addition to the methods and apparatus described above, embodiments of this disclosure may also be computer program products comprising computer program instructions that, when executed by a processor, cause the processor to perform the steps in the multilingual front-end page implementation methods according to various embodiments of this disclosure as described in the "Exemplary Methods" section of this specification.
[0141] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of this disclosure. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0142] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions that, when executed by a processor, cause the processor to perform the steps in the multilingual front-end page implementation method according to various embodiments of this disclosure as described in the "Exemplary Methods" section above.
[0143] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (not an exhaustive list) may include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0144] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0145] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For system embodiments, since they largely correspond to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0146] The block diagrams of devices, apparatuses, devices, and systems disclosed herein are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.
[0147] The methods and apparatus of this disclosure may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of this disclosure are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, this disclosure may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the methods according to this disclosure. Thus, this disclosure also covers recording media storing programs for performing the methods according to this disclosure.
[0148] It should also be noted that in the apparatus, devices, and methods of this disclosure, the components or steps can be disassembled and / or recombined. These disassemblies and / or recombinations should be considered as equivalent solutions to this disclosure.
[0149] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.
[0150] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.
Claims
1. A method for implementing a front page based on multiple languages, characterized in that, Set a source set of text and at least one target language set of text, wherein, The source text set is used to store the correspondence information between source text identifiers and source texts. The target language copy set is used to store the correspondence information between source copy identifiers and target language copy. The source text in the source text collection is extracted from the project code used to implement the front-end pages. The source text identifiers in the source text set and the target language text set are automatically assigned to the extracted source texts, and the method includes the following steps: Obtain the currently selected target language, the set of source texts, and the set of target language texts corresponding to the currently selected target language; Based on the set of source texts, determine the identifier of the source text to be translated corresponding to the source text to be translated in the front-end page; Based on the source text identifier to be translated and the set of target language texts corresponding to the currently selected target language, the target language text corresponding to the source text identifier to be translated is determined; The front-end page is rendered based on the target language text corresponding to the source text identifier to be translated, generating a front-end page based on the currently selected target language.
2. The method of claim 1, wherein, The method further includes the step of generating the source text set, including: The project code is scanned according to preset rules to obtain source text in the project code that conforms to the preset rules; Automatically assign source text identifiers to the obtained source text; The correspondence information between the source text identifier and the source text is stored in the source text set.
3. The method of claim 2, wherein, The automatic assignment of source text identifiers to the obtained source text includes: The source text obtained from the current scan is deduplicated; Automatically assign source text identifiers to the source text retained after the deduplication process; Furthermore, storing the correspondence information between the source text identifier and the source text in the source text set includes: Based on the incremental update method, the correspondence information between the source text identifier and the source text is stored in the source text set.
4. The method according to claim 3, characterized in that, The automatic assignment of source text identifiers to the source text retained after deduplication includes: Based on the random identifier allocation method, source text identifiers are automatically assigned to the source text retained after the deduplication process.
5. The method according to any one of claims 2 to 4, characterized in that, The step of storing the correspondence information between the source text identifier and the source text in the source text set includes: The source text identifier and the source text are stored in the source text file as key-value pairs based on a lightweight text data exchange format.
6. The method according to any one of claims 2 to 4, characterized in that, The method further includes the step of generating the target language text set, including: The source texts obtained from the scan are provided to the translation platform, and the target language texts of each source text are returned by the translation platform. Each source text identifier and its corresponding target language text are stored in the target language text file in the form of key-value pairs.
7. The method according to any one of claims 1 to 4, characterized in that, The step of obtaining the currently selected target language, the set of source texts, and the set of target language texts corresponding to the currently selected target language further includes: Generate a reverse mapping table from source texts to source text identifiers based on the source text set; Furthermore, determining the source text identifier corresponding to the source text to be translated in the front-end page based on the source text set includes: The reverse mapping table is used to determine the source text identifier to be translated in the front-end page.
8. The method according to claim 7, characterized in that, The step of obtaining the currently selected target language, the set of source texts, and the set of target language texts corresponding to the currently selected target language further includes: Generate a mapping table from source text identifiers to target language texts based on the target language text set corresponding to the currently selected target language; or Generate a mapping table from source text identifiers to target language text for each target language text set; Furthermore, determining the target language text corresponding to the source text identifier to be translated based on the source text identifier to be translated and the target language text set corresponding to the currently selected target language includes: The internationalization translation function in the project code uses the identifier of the source text to be translated as the key to look up the value corresponding to the key in the mapping table corresponding to the currently selected target language; If the value corresponding to the key is found, the value corresponding to the key is used as the target language text corresponding to the source text identifier to be translated; If no value is found corresponding to the key, then the source text to be translated is taken as the target language text corresponding to the source text identifier to be translated.
9. A front-end page implementation device based on multiple languages, characterized in that, The device includes: A storage module is used to store a pre-set set of source text and at least one set of target language text. The source text set stores the correspondence information between source text identifiers and source texts. The target language text set stores the correspondence information between source text identifiers and target language texts. The source texts in the source text set are extracted from the project code used to implement the front-end page. The source text identifiers in the source text set and the target language text set are automatically assigned to the extracted source texts. The acquisition module is used to acquire the currently selected target language, the set of source texts, and the set of target language texts corresponding to the currently selected target language; The identifier determination module is used to determine the identifier of the source text to be translated corresponding to the source text to be translated in the front-end page based on the source text set; The target language copywriting determination module is used to determine the target language copywriting corresponding to the source copywriting identifier to be translated based on the source copywriting identifier to be translated and the set of target language copywriting corresponding to the currently selected target language. The rendering module is used to perform front-end page rendering processing based on the target language text corresponding to the source text identifier to be translated, and generate a front-end page based on the currently selected target language.
10. A computer-readable storage medium storing a computer program for performing the method of any one of claims 1-8.
11. An electronic device, the electronic device comprising: processor; Memory used to store the processor's executable instructions; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the method of any one of claims 1-8.