Language switching method, device, computer equipment, readable storage medium and program product

By preloading the language pack and updating the text of page elements, the problem of low language switching efficiency of existing security software is solved, and sensorless switching and efficiency improvement is achieved.

CN119761387APending Publication Date: 2025-04-04LONGSE ELECTRONICS
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411927778.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The language switching method of existing security software is usually regenerated by destroying the entire page, resulting in inefficient switching and affecting the user experience.

Method used

By preloading each language pack, the text of each page element in the page is updated according to the target language type, the language is switched invisibly and the efficiency of language switching is improved.

Benefits of technology

It realizes language invisible switching, improves the efficiency of language switching in the page, reduces the page's memory space, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119761387A_ABST
    Figure CN119761387A_ABST
Patent Text Reader

Abstract

The present application relates to a language switching method, apparatus, computer equipment, readable storage medium and program product. By loading a language pack set corresponding to the language configuration information, determining the target language type and the page to be switched based on the language switching instruction, determining the target language pack according to the target language type, and updating the current texts corresponding to the various page elements in the page according to the target texts corresponding to the various page elements in the target language pack under the target language type, the target page after the language switching is obtained. Compared with the traditional switching method of destroying the entire page and then regenerating it, this solution pre-loads each language pack, and uses each target text of the target language type in the language pack to perform text switching for the text of the page elements in the page that need to be switched in the language, thereby realizing seamless switching of languages ​​and improving the efficiency of language switching in the page.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of language processing technology, and in particular to a language switching method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] With the vigorous development of global information technology and domestic security technology, relevant security software has been widely used around the world. Users in different countries and regions have different usage habits and languages. It is particularly important to study the relevant technologies of software internationalization and develop security software compatible with multiple language versions. At present, the language switching method of security software is usually achieved by destroying the entire page and regenerating it. However, language switching by destroying the page and regenerating it is time-consuming and leads to reduced efficiency.

[0003] Therefore, the current language switching method has the defect of low switching efficiency. Summary of the invention

[0004] Based on this, it is necessary to provide a language switching method, apparatus, computer device, computer-readable storage medium and computer program product that can improve switching efficiency in response to the above technical problems.

[0005] In a first aspect, the present application provides a language switching method, comprising:

[0006] Obtain a language switching instruction, and determine a target language type and a page to be switched according to the language switching instruction;

[0007] According to the target language type, a language pack set is queried to obtain a corresponding target language pack; the language pack set is loaded based on the language configuration information; the target language pack includes each target text corresponding to each page element in the page to be switched under the target language type;

[0008] Obtaining each current text corresponding to each page element in the page to be switched;

[0009] The current texts corresponding to the page elements in the page are updated according to the target texts in the target language package to obtain the target page after language switching.

[0010] In one embodiment, the method further comprises:

[0011] Obtain code information corresponding to the page;

[0012] Traversing the code information to obtain each of the page elements including the language switching identifier;

[0013] According to the language configuration information, language conversion is performed on each text corresponding to each of the page elements to obtain each language package corresponding to each of the page elements in each language type;

[0014] The language pack set is generated according to each of the language packs.

[0015] In one embodiment, performing language conversion on each text corresponding to each of the page elements according to the language configuration information to obtain each language package corresponding to each of the page elements in each language type includes:

[0016] Determine each language type according to the language configuration information;

[0017] For each language type, query the historical conversion record according to the text corresponding to the page element to obtain the first text of the text corresponding to the page element in the language type;

[0018] Obtaining a second text in the language type for the text input corresponding to the page element;

[0019] A language pack corresponding to the language type is obtained according to the first text and the second text.

[0020] In one embodiment, the step of determining the page to be switched includes:

[0021] Get the activation status of each page;

[0022] The page to be switched is obtained according to the page whose activation status belongs to the activated page.

[0023] In one embodiment, the updating of each current text corresponding to each page element in the page according to each target text in the target language package to obtain the target page after language switching includes:

[0024] If the page is a non-modal page, the page is notified through the observer mode to update the current texts corresponding to the page elements in the page according to the target texts, so as to obtain the target page after the language is switched;

[0025] If the page is a modal page, when it is detected that the page is displayed, the current texts corresponding to the page elements in the page are updated according to the target texts to obtain the target page after the language is switched.

[0026] In one embodiment, the step of notifying the page through the observer mode to update the current texts corresponding to the page elements in the page according to the target texts to obtain the target page after the language switching includes:

[0027] Notifying the page through the observer mode to update the current text corresponding to the page element in the page according to the target text;

[0028] Obtain the text display area range corresponding to the page element in the page;

[0029] According to the text display area range, adjusting the display format corresponding to the target text;

[0030] The target text after adjusting the display format is output to the text display area to obtain the target page after language switching.

[0031] In a second aspect, the present application also provides a language switching device, comprising:

[0032] A first acquisition module, used to acquire a language switching instruction, and determine a target language type and a page to be switched according to the language switching instruction;

[0033] A query module, configured to query a language package set according to the target language type to obtain a corresponding target language package; the language package set is loaded based on the language configuration information; the target language package includes each target text corresponding to each page element in the page to be switched under the target language type;

[0034] A second acquisition module is used to acquire each current text corresponding to each page element in the page to be switched;

[0035] The switching module is used to update the current texts corresponding to the page elements in the page according to the target texts in the target language package to obtain the target page after language switching.

[0036] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0037] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.

[0038] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of the above method when executed by a processor.

[0039] The above-mentioned language switching method, device, computer equipment, computer-readable storage medium and computer program product load the language pack set corresponding to the language configuration information, determine the target language type and the page to be switched based on the language switching instruction, determine the target language pack according to the target language type, and update the current texts corresponding to the various page elements in the page according to the target texts corresponding to the various page elements in the target language pack under the target language type, so as to obtain the target page after the language switching. Compared with the traditional switching method of destroying the entire page and then regenerating it, this solution pre-loads each language pack, and uses each target text of the target language type in the language pack to perform text switching for the text of the page elements in the page that need to switch the language, thereby realizing seamless switching of languages ​​and improving the efficiency of language switching in the page. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0041] Figure 1 is a flow chart of a language switching method in one embodiment;

[0042] Figure 2 A flowchart of a language package generation step in one embodiment;

[0043] Figure 3 A flow chart of a language switching step in one embodiment;

[0044] Figure 4 is a flow chart of a language switching method in another embodiment;

[0045] Figure 5 is a structural block diagram of a language switching device in one embodiment;

[0046] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0048] With the vigorous development of global information technology and domestic security technology, the demand for related software to go abroad and open up overseas international markets is growing. Users in different countries and regions have different usage habits and languages. It is particularly important to conduct research on software internationalization related technologies and develop security software that is compatible with multiple language versions.

[0049] During use, users will be involved in switching between multiple languages. Generally, software provides a language selection function to achieve related switching of different language modules, such as switching between Chinese and English, switching between English and Japanese, etc. Language switching generally requires destroying the interface and recreating it, which is time-consuming and seriously affects the user experience.

[0050] Based on this, the present application pre-loads various language packs, and uses the various target texts of the target language type in the language pack to perform text switching on the text of the page elements that need to switch languages ​​in the page, thereby achieving seamless language switching and improving the efficiency of language switching in the page.

[0051] In one embodiment, Figure 1 As shown, a language switching method is provided. This embodiment uses the method applied to a terminal as an example, wherein the terminal may be a smart device such as a mobile phone and a computer. It is understandable that the method may also be applied to a server, and may also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server, including the following steps S202 to S208. Among them:

[0052] Step S202: obtaining a language switching instruction, and determining a target language type and a page to be switched according to the language switching instruction.

[0053] Among them, the above-mentioned terminals may include smart devices such as smart phones and computers. When users use software or web pages in the terminal, such as security software or security web pages, they need to switch between browsing on different pages. In order to meet the language needs of various groups of people, it is necessary to switch the language of each text appearing on the page. The user can trigger a language switching instruction in the terminal, such as clicking a corresponding language switching button and selecting the target language type to be switched. The terminal can thus obtain a language switching instruction, so that the terminal can determine the target language type and the page to be switched according to the above-mentioned language switching instruction.

[0054] The target language type may be the type of language that the user wants to switch to, including but not limited to Chinese, English, Russian, etc. The terminal may further determine the page that needs to be switched to a language, which may also be referred to as the page to be switched. The terminal may determine the page that needs to be switched based on the current activation status of each page.

[0055] In one embodiment, the step of determining the page to be switched includes: obtaining the activation status corresponding to each page; and obtaining the page to be switched according to the page whose activation status belongs to the activated page.

[0056] In this embodiment, multiple pages can be opened in the terminal, and each page can have corresponding text that needs to be switched in language. Then, when determining the page that needs to be switched in language, the terminal can first obtain the activation status corresponding to each page. Among them, the activation status of the page indicates whether the page is displayed. If the page is in a display state, it means that the activation status of the page is activated; if the page is in a non-display state, it means that the activation status of the page is non-activated. Therefore, the terminal can obtain the page to be switched according to the page in the activation state. Therefore, the terminal only needs to maintain the page in the activated state, which not only reduces the memory space occupied by the page, but also improves the efficiency of page switching.

[0057] Step S204, querying the language pack set according to the target language type to obtain the corresponding target language pack; the language pack set is loaded based on the language configuration information; the target language pack includes each target text corresponding to each page element under the target language type.

[0058] The terminal may generate multiple language packages in advance to form a language package set. The terminal may configure language packages for multiple languages, generate language configuration information based on the languages ​​supported for switching, and store the language configuration information in JSON (JavaScript Object Notation) format.

[0059] The terminal can generate language packages corresponding to the languages ​​supported for switching in advance. The terminal can determine the text to be translated based on the code information of the software where the above page is located in advance, so that the terminal can translate the text to be translated into the text corresponding to each language type, and the terminal integrates the text of each language type separately to form the language packages corresponding to each language type.

[0060] When the terminal starts the software or opens the page, for example, when the security software is started or the security webpage is opened, the terminal can load the pre-stored language configuration information, so that the terminal determines the default loaded language type and the language type supported for switching based on the language configuration information. Thus, the terminal can load various language packages of the corresponding language type. Among them, the above language configuration information can be modified according to actual needs, that is, the default supported language type can be modified, and the language type supported for switching can also be modified.

[0061] Specifically, the above-mentioned language pack structure includes modules, translation IDs (identifiers) and language types, etc. Among them, the translation ID represents the language switching identifier. For the content that needs to be switched when switching languages, the terminal can add a translation ID to it, that is, the text with the translation ID belongs to the text that needs to be translated. The above-mentioned language types may include multiple, including but not limited to Chinese, English, Traditional Chinese, Arabic, Bulgarian, Czech, Dutch, French, German, Greek, Hebrew, Hungarian, Italian, Japanese, Korean, Polish, Portuguese, Romanian, Russian, Spanish, Thai, Turkish, Vietnamese, Ukrainian and other mainstream languages ​​corresponding to translation fields. The terminal can add a new translation field and can query by module, translation ID, language type and other categories, so that the terminal can quickly find the translated content. At the same time, it supports translation modification, import of new translations and re-translation functions. The language pack export can be arranged and combined according to the actual customization needs of the user to avoid the generation of unnecessary files.

[0062] Step S206, obtaining each current text corresponding to each page element in the page to be switched.

[0063] Among them, after the terminal determines the page to be switched, it can further determine the content that needs to be switched in the page. Among them, the content that needs to be switched in language can be each page element in the page. The above-mentioned each page element can be a page element carrying a translation ID, and the translation IDs of these page elements can be added to the corresponding page elements in advance during the code editing stage. The above-mentioned page elements include but are not limited to button text, page title, prompt information, etc. in the page. The above-mentioned translation ID can be a unique identifier for identifying translatable text elements. The text contained in the page element corresponding to the translation ID can be set as Value by the terminal. That is, Value is the text value corresponding to the above-mentioned translation ID, which can be a specific translation content. The terminal can use the translation ID as the Key field, display the translation ID and translation content in the structure of translation ID: translation Value, and store it in JSON format, so that it can be used in different language environments without further conversion.

[0064] The terminal can determine the various page elements that need to be translated in the above-mentioned page to be switched based on the translation ID, that is, the language switching identifier. Thus, the terminal can obtain the various current texts corresponding to the various page elements. Among them, the terminal can obtain the text value currently corresponding to the language switching identifier of the above-mentioned page element as the above-mentioned current text. Among them, the current text represents the text currently displayed in the page.

[0065] Step S208, updating each current text corresponding to each page element in the page according to each target text in the target language package, to obtain a target page after language switching.

[0066] Among them, the target language package includes each target text corresponding to each page element under the target language type. The target language package can be a language package determined based on the target language type selected by the user. The target texts corresponding to each page element in the target language package can be translated in advance based on the text of each page element. The terminal can update the current texts corresponding to each page element in the page according to the target texts in the target language package, and obtain the target page after the language is switched. For example, the terminal can replace the values ​​corresponding to each language switching identifier of each page element based on each target text, and quickly refresh the page so that each page element in the above-mentioned page to be switched is displayed with the target text, thereby obtaining the target page after the language is switched.

[0067] In the above-mentioned language switching method, by loading the language pack set corresponding to the language configuration information, the target language type and the page to be switched are determined based on the language switching instruction, the target language pack is determined according to the target language type, and the current texts corresponding to the various page elements in the page are updated according to the various target texts corresponding to the various page elements in the target language pack under the target language type, so as to obtain the target page after the language switching. Compared with the traditional switching method of destroying the entire page and then regenerating it, this solution pre-loads each language pack, and uses the various target texts of the target language type in the language pack to perform text switching for the text of the page elements in the page that need to be switched in the language, thereby realizing seamless switching of languages ​​and improving the efficiency of language switching in the page.

[0068] The same software may have different client implementations. In addition to the local interface, there will also be a web interface. Different clients are implemented using different technical solutions and have different language loading formats. Unifying the language pack format and enabling cross-platform use of language packs can not only reduce the size of the language pack, but also avoid the translation files coming from different sources and increasing maintenance costs.

[0069] Based on this, in one embodiment, it also includes: obtaining code information corresponding to the page; traversing the code information to obtain each page element containing a language switching identifier; performing language conversion on each text corresponding to each page element according to the language configuration information to obtain each language package corresponding to each page element under each language type; and generating a language package set according to each language package.

[0070] In this embodiment, the terminal can pre-generate language packages corresponding to each language type, and specifically, the language package can be generated for the text of each page element containing a language switching identifier in the page. Among them, each of the above pages can have corresponding code information, such as the source code of the security software. The terminal can obtain the code information corresponding to the page, and traverse the code information to obtain each page element containing a language switching identifier. Among them, whether the page element contains a language switching identifier can be set according to the actual situation. The terminal can determine the language type that needs to be pre-configured based on the language configuration information, so that the terminal can perform language conversion on each text corresponding to each page element, and obtain each language package corresponding to each page element under each language type. Thus, the terminal can generate a language package set based on each language package.

[0071] Specifically, Figure 2 As shown, Figure 2 It is a flowchart of the language pack generation step in an embodiment. The terminal includes a language pack management platform. The language pack management platform contains information such as device type, version information record, module list, translation list, etc. Its parameters are created based on the standard baseline version, and store new records of different functions and historical record data of user-customized versions. Among them, the new record refers to the archive of newly added translations of different software type device versions. User-customized version records are archived based on translations of different customized requirements of users. By storing historical records on the language pack management platform, new product language packs can be quickly combined and customized, which reduces maintenance costs and time costs, avoids multiple translations of the same language, reduces the fault tolerance of translation software, and improves customer understanding.

[0072] Figure 2 The process of the terminal entering parsing and creating a language pack for the corresponding device model through the file entry generation module is described. Among them, the terminal can read the source code file to be parsed, that is, the above-mentioned code information, and traverse and query the translation ID value of the corresponding translation keyword in all files. This value can be used as a query condition for the device background translation management platform. The terminal calls the relevant protocol interface to search the platform history records, completes the translation content corresponding to the translation ID, and the unqueried records will be counted as the last output record. Then the terminal obtains the manually entered translation text and modifies and completes the missing translation. At the same time, the terminal can choose to synchronously import the newly added translation information to the translation record management platform, and finally export the language pack of the corresponding translation file according to user needs. In this way, the terminal can greatly improve the efficiency of creating translation files, and at the same time reduce the fault tolerance of frequent modifications of translation content by managing historical translation file records.

[0073] The language configuration information corresponding to the language pack can be stored in JSON format, and the language configuration information includes a configuration file and a general configuration table of the database. When the terminal starts the page, the configuration in the database is loaded first, that is, the language configuration information is read, and then the default configuration file in the language configuration information is read, where the default configuration file represents the configuration information of the default supported language type. The default configuration file stores data in json format, which can achieve cross-platform compatibility and easy parsing.

[0074] If the terminal detects that the default language file format is defined in the default configuration file, it will be loaded according to the default configuration file first. At the same time, the terminal can also modify the size of the default supported language type array, so that the terminal can quickly customize the default loaded language type and the number of loaded language packs in this way without changing the code and database files. Among them, the above language configuration information can be specifically expressed as "languageType: ["Chinese", "English", "Korean", ..., "Japanese"]; defaultValue: {language: "English"}". Among them, languageType represents the language type, that is, the language type that supports switching, and defaultValue represents the default loaded language type. For example, if the user needs to load Russian as the default language and the language pack only contains Russian and English, then it is only necessary to modify the default language type in the default json configuration to Russian, and the default supported language array to ["English", "Russian"]. In this way, there is no need to go through a complex deep customization approval process, and shallow customization of language packs can be achieved, reducing development and communication costs. If you need to restore to the default factory settings, you only need to synchronize the default configuration file cache data to the database to achieve the default configuration modification.

[0075] Through this embodiment, the terminal can search for page elements containing language switching identifiers by traversing code information, and translate the text of the page elements into various language types to form various language packages, thereby unifying the format of the language packages and reducing maintenance costs. The terminal also switches the language of the page based on the language packages, thereby improving the efficiency of language switching.

[0076] During the video software development and maintenance process, different users in different countries constantly propose modification suggestions for the software translation, which ultimately results in a large amount of technical coordination and software change work. At the same time, considering that the resources of the embedded device itself are limited, an overly large language package will occupy too many resources of the embedded system, affecting the stability and robustness of the device. Reducing the size of the language package to achieve a lightweight language library management module is currently a pain point.

[0077] Based on this, in one embodiment, language conversion is performed on each text corresponding to each page element according to the language configuration information to obtain each language package corresponding to each page element under each language type, including: determining each language type according to the language configuration information; for each language type, querying the historical conversion record according to the text corresponding to the page element to obtain the first text of the text corresponding to the page element under the language type; obtaining the second text under the language type input for the text corresponding to the page element; and obtaining the corresponding language package under the language type according to the first text and the second text.

[0078] In this embodiment, the terminal may generate language configuration information in advance, and determine each language type that supports switching based on the language configuration information. Thus, the terminal may determine the language package of the language type that needs to be generated based on the language configuration information. Among them, the language configuration information stores the supported language types and default language settings by default, and the language package is stored in the device and corresponds to the language types supported by the language configuration information. The terminal can translate the text into a language type based on a variety of methods. For example, for each language type, the terminal can query the historical conversion record according to the text corresponding to the page element to obtain the first text of the text corresponding to the page element under the language type. Among them, the historical conversion record can be a record of the text that has been translated in the historical translation process of the above text, that is, the text translation is performed based on the historical information to form the first text of the text corresponding to the above page element under the above language type. The terminal can also obtain the second text under the language type for the text input corresponding to the page element. Among them, for the text that is not in the historical conversion record, such as the text that has not been translated, the terminal can obtain the translated text input for the text as the second text, or it can query the dictionary of the corresponding language type based on the text to obtain the second text. Thus, the terminal can obtain the corresponding language package under the language type according to the first text and the second text. The terminal may generate the above-mentioned language package for each language type, thereby obtaining a language package set including multiple language packages.

[0079] Specifically, the language switching identifier of the above-mentioned page element can be a translation ID, and the text corresponding to the page element can be the Value associated with the translation ID as the key. The terminal can import the code file of the above-mentioned page, traverse and parse all source code files to find the key corresponding to the translation ID. The terminal will first generate a set of key fields of the translation ID of the default reference language type, and other languages ​​will generate a corresponding translation file in the same format to form a language package. Then the terminal can query whether there is a corresponding translation for the translation ID through the translation record management platform. If it exists, the terminal completes the translation content corresponding to the key of all translation IDs, that is, determines the first text; for the translation ID without historical conversion records, the terminal can mark and record it, and add the translated text by obtaining the input translation text or querying to form a second text, so that the terminal can form a language package under the corresponding language type based on the first text and the second text. And the terminal can also synchronize the translation management platform data. The above-mentioned language package is stored in json mode, and each line is displayed in the form of translation ID: translated text value. Therefore, the terminal uses the json general format, and the parsing can be used in different language environments without further conversion.

[0080] Through this embodiment, the terminal can generate language packs under various language types based on multiple methods, so that the terminal can switch the language of page elements based on language packs of multiple language types, thereby improving the efficiency of language switching. In addition, by storing the language packs in JSON format, the storage pressure is reduced, and a lightweight language pack structure is realized.

[0081] In one embodiment, each current text corresponding to each page element in the page is updated according to each target text to obtain the target page after language switching, including: if the page is a non-modal page, the page is notified through the observer mode to update each current text corresponding to each page element in the page according to each target text to obtain the target page after language switching; if the page is a modal page, when it is detected that the page is displayed, each current text corresponding to each page element in the page is updated according to each target text to obtain the target page after language switching.

[0082] In this embodiment, the above-mentioned page may include multiple types of pages, such as modal pages and non-modal pages. Among them, the non-modal page will not block the user's operation, and the user can continue to interact with other windows or pages without closing the page. The modal page will block the user's operation, and the user must complete the operation of the page before continuing other operations. For different types of pages, the terminal can use different switching methods to switch the language type.

[0083] If the terminal detects that the above page is a non-modal page, the terminal can notify the page through the observer mode to update the current texts corresponding to the various page elements in the page according to the various target texts by means of a quick refresh, and obtain the target page after the language is switched. The observer mode can automatically notify all objects that depend on it of the state change of an object by realizing a one-to-many dependency relationship, so as to perform relevant updates.

[0084] If the terminal detects that the page is a modal page, then when the terminal detects that the page is displayed, for example, when a modal dialog box pops up, the terminal can update the current text corresponding to each page element in the page by refreshing the page according to each target text to obtain the target page after the language is switched.

[0085] Specifically, Figure 3 As shown, Figure 3 The figure is a flowchart of a language switching step in an embodiment. Figure 3 The flowchart of the method for quickly switching the translation language page is described in . When the terminal detects that the program is started, it will first read the language configuration information and load the corresponding language package content. When the current page needs to be displayed, the terminal will refresh and read the current page and its sub-pages, such as displaying the sub-page in the foreground, read its translation id and parse and display it. At the same time, the terminal can also add the current page to the observer set. When the terminal detects that the current language type needs to be switched, the terminal reloads the new language pack through the device background translation management module. The terminal notifies all currently activated pages to refresh quickly through the observer mode, re-reads the translation content corresponding to the translation ID under the target language type and displays it. In addition, for the currently displayed non-modal pages, the terminal can add these non-modal pages to the observer, and when the page is in an inactive creation state, the terminal will cancel the observer and destroy the inactive state page, that is, the program only maintains the state of the page that needs to be displayed, and other pages do not need to be cached in memory all the time, thereby reducing resource usage.

[0086] For modal pages, such as modal dialog boxes, the terminal can handle them in a burn-after-use mode. For example, when the terminal detects a pop-up modal box, it can refresh the page to switch the language. When the terminal detects that the modal box is closed, the terminal destroys the modal box and all resources. In this way, the terminal only needs to maintain the active status page, which not only reduces memory usage but also improves page switching efficiency.

[0087] Through this embodiment, the terminal can adopt different language switching methods for different types of pages. Compared with the traditional method that requires destroying the interface to recreate the display, this solution does not need to destroy the program to recreate the window, thereby realizing seamless switching of page translation languages. In addition, language switching is realized by updating the text of page elements based on the language package, which also improves the efficiency of language switching.

[0088] In one embodiment, the page is notified through the observer mode to update the current texts corresponding to the page elements in the page according to the target texts to obtain the target page after the language is switched, including: notifying the page through the observer mode to update the current texts corresponding to the page elements in the page according to the target texts; obtaining the text display area range corresponding to the page elements in the page; adjusting the display format corresponding to the target text according to the text display area range; outputting the target text with the adjusted display format to the text display area range to obtain the target page after the language is switched.

[0089] In this embodiment, for a non-modal page, the terminal can determine whether the target text can be accurately displayed in the text display area of ​​the page element after replacing the text corresponding to the language switching identifier of the page element, and make corresponding adjustments. For example, the terminal can notify the page in observer mode to update the current text corresponding to the page element in the page according to the target text, such as updating the value corresponding to the translation ID of the page element based on the target text. And the terminal can also obtain the text display area range corresponding to the page element in the page, such as information such as the width and length of the text display area. Thereby, the terminal can adjust the display format corresponding to the target text according to the text display area range, so that the target text can be adaptively displayed within the text display area range. The terminal can output the target text after adjusting the display format to the text display area range to obtain the target page after the language switch.

[0090] Specifically, after the terminal switches the language using the target text, the activated observer page can adjust the length of the translated content to fit the corresponding text display area. The terminal can calculate the length information of the entry when the user's target text is displayed based on the currently set file font size information, alignment, etc., and determine whether the width of the user's translated language entry in the cell of the text display area is greater than the width of the corresponding default language entry in the cell. If it exceeds, the terminal will fold, wrap, or add ellipsis to display according to the preset hiding rules.

[0091] Through this embodiment, the terminal can adjust the display form of the target text based on the text display area range of the page element, thereby improving the adaptability of the target text to the page when the language is switched.

[0092] In an exemplary embodiment, Figure 4 As shown, Figure 4It is a flow chart of the language switching method in another embodiment. In this embodiment, the terminal includes a device background management unit, a device front-end management unit, and a web front-end display management unit. The configuration file may be the above-mentioned language configuration information, which stores the supported language file types and default language settings by default, and the language pack is stored in the device and corresponds to the configuration file supporting the language pack file one by one. The device background management unit includes a set of language packs for corresponding models, and the language pack default configuration import and database management. The above-mentioned terminal may include a device front end and a web (webpage) end, wherein the device front end may be a software end. The terminal can process the RPC (Remote Procedure Call) request messages of the device front end and the web at the same time, and can realize language modification, default restoration, loading, etc.

[0093] This embodiment includes steps S101 to S105.

[0094] Step S101: The terminal manages translation records and files through the translation record management platform, and can store and manage language pack files of different schemes and device types at the same time. The language pack includes device import history records and newly added records. And the terminal can export the required history records according to different query conditions through the platform for easy query and use in different scenarios.

[0095] Step S102: The terminal can automatically and efficiently extract the fields that need to be translated in the product through the file entry generation module. After starting, you can choose to specify the source code path, and traverse and parse all the key values ​​corresponding to the translation keyword ID in the source code and make statistics. After the file entry generation unit parses out all the key values, it will first generate a set of key fields of the translation id of the default benchmark language, in which Chinese is used as the default benchmark, and other languages ​​can be switched as the benchmark language. For other languages ​​other than the benchmark language, the terminal will generate a corresponding translation file in the same format. Through the file entry generation unit, the terminal can access the translation record management platform system to query whether there is a corresponding translation for the translation id corresponding to the page element. If there is a translation content (value) corresponding to all the translation key values, the id of the translation that is not available is marked and recorded, or it can be added manually. The added information can synchronize the translation management platform data. The language package can be stored in the json format of the file, and each line is recorded in the form of id: value. And it is stored in the json general format, and the parsing can be used in the language environment of different platforms without further conversion.

[0096] Step S103: The terminal loads and manages all language packs corresponding to the model of the device through the device background translation management unit. The terminal maintains a set of default configuration files and a general configuration table of the database through this unit. When the terminal program starts, the configuration in the database, that is, the language configuration information, is loaded first, and then the default configuration file is read. The default configuration file stores data in json format, which can achieve cross-platform compatibility and easy parsing. If the default language file format is defined in the default configuration file, the terminal will load it according to the default configuration file first. At the same time, the terminal can also modify the size of the default supported language type array. In this way, the default loaded language type and the number of loaded language packs can be quickly customized without changing the code and database files. In this way, users can achieve shallow customization of language packs by themselves without going through a complex deep customization approval process, reducing development and communication costs. If you need to restore to the default factory settings, you only need to synchronize the default configuration file cache data to the database to achieve the default configuration modification.

[0097] Step S104: For the page displayed by software, the terminal reads the default language configuration parameters of the database and loads them into the memory through the front-end display unit of the device. The database will not be frequently operated when reading the configuration. The language information will be synchronously modified to the database only when the configuration is modified. This can greatly improve the reading and writing efficiency and reduce the file reading and writing I / O (Input / Output). The terminal switches to loading the corresponding language json language package through the read configuration information, parses the translation id of the current page one by one, reads the corresponding value, and finally renders and displays it to the display interface. When switching pages, it will refresh the corresponding translation value display of the read target page again. The terminal can also calculate the length information of the user's translated language entry through the device display unit according to the currently set file font size information, alignment, etc., and determine whether the width of the user's translated language entry in the cell is greater than the width of the corresponding default language entry in the cell. If it exceeds, it will be folded, wrapped or displayed with ellipsis according to the set hiding rules. Among them, the default can be displayed with ellipsis or in other forms. In addition, the terminal notifies all currently activated pages to quickly refresh the pages through the observer mode, so as to realize the page display based on the above-mentioned target texts, without destroying the program to recreate the page, and realizing the seamless switching of the translation language.

[0098] For the currently displayed non-modal page, the terminal will add it to the observer, and the inactive page will unregister the observer. After the terminal modifies the language category through the configuration module, it will switch the translation file cache and send a switch message to all currently active observer pages that have been added to the cache. The observer page that is activated will immediately call the refresh interface to refresh the translation values ​​corresponding to all translation IDs of the current page and its subpages and adjust the size. For modal dialog boxes, they are handled in a burn-after-use mode. When the modal box pops up, the terminal refreshes the page, and closing the modal box destroys the modal box and all resources. In the above way, the program only needs to maintain the activated state page, which not only reduces the memory space occupied by the page, but also improves the efficiency of page switching.

[0099] Step S105: The terminal may also include a display mode of a web page. The terminal provides an RPC remote access mechanism through the web front-end management unit, and the terminal can access the device through the web page. After the web login is successful, the terminal reads the configuration language type from the device side through the RPC mechanism, including the above-mentioned language configuration information, and then the terminal downloads the language package file to the browser cache. The language package and the terminal software share a copy, so the web interface can achieve the same effect as the terminal local device front-end display unit, and share a language package file, which greatly reduces the size of the web module. Among them, when the web switches the language, the background configuration file and the database language configuration are modified at the same time, so that the remote configuration modification of the language configuration can be realized.

[0100] Through the above embodiment, the terminal pre-loads various language packages, and uses various target texts of the target language type in the language package to perform text switching for the text of the page elements that need to be switched in the page, thereby achieving seamless switching of languages ​​and improving the efficiency of language switching in the page.

[0101] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0102] Based on the same inventive concept, the embodiment of the present application also provides a language switching device for implementing the above-mentioned language switching method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more language switching device embodiments provided below can refer to the limitations on the language switching method above, and will not be repeated here.

[0103] In an exemplary embodiment, Figure 5 As shown, a language switching device is provided, including: a first acquisition module 500, a query module 502, a second acquisition module 504 and a switching module 506, wherein:

[0104] The first acquisition module 500 is used to acquire a language switching instruction and determine a target language type and a page to be switched according to the language switching instruction.

[0105] The query module 502 is used to query the language pack set according to the target language type to obtain the corresponding target language pack; the language pack set is loaded based on the language configuration information; the target language pack includes each target text corresponding to each page element under the target language type.

[0106] The second acquisition module 504 is used to acquire each current text corresponding to each page element in the page to be switched.

[0107] The switching module 506 is used to update each current text corresponding to each page element in the page according to each target text in the target language package to obtain a target page after language switching.

[0108] In one embodiment, the above-mentioned device also includes: a generation module, which is used to obtain code information corresponding to the page; traverse the code information to obtain each page element containing a language switching identifier; according to the language configuration information, perform language conversion on each text corresponding to each page element to obtain each language package corresponding to each page element under each language type; and generate a language package set according to each language package.

[0109] In one embodiment, the above-mentioned device also includes: a generation module, which is used to determine each language type according to the language configuration information; for each language type, query the historical conversion record according to the text corresponding to the page element to obtain the first text of the text corresponding to the page element under the language type; obtain the second text under the language type for the text input corresponding to the page element; and obtain the corresponding language package under the language type according to the first text and the second text.

[0110] In one embodiment, the first acquisition module 500 is used to acquire the activation status corresponding to each page; and obtain the page to be switched according to the page whose activation status belongs to the activated page.

[0111] In one embodiment, the switching module 506 is used to notify the page through the observer mode to update the current texts corresponding to the page elements in the page according to the target texts if the page is a non-modal page, so as to obtain the target page after the language switching; if the page is a modal page, when it is detected that the page is displayed, the current texts corresponding to the page elements in the page are updated according to the target texts to obtain the target page after the language switching.

[0112] In one embodiment, the switching module 506 is used to notify the page in observer mode to update the current text corresponding to the page element in the page according to the target text; obtain the text display area range corresponding to the page element in the page; adjust the display format corresponding to the target text according to the text display area range; output the target text with the adjusted display format to the text display area range to obtain the target page after the language is switched.

[0113] Each module in the above-mentioned language switching device can be implemented in whole or in part by software, hardware and a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.

[0114] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 6As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a language switching method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

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

[0116] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above-mentioned language switching method when executing the computer program.

[0117] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned language switching method is implemented.

[0118] In one embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the language switching method described above is implemented.

[0119] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0120] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0121] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0122] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A language switching method, characterized in that: The method comprises: Obtain a language switching instruction, and determine a target language type and a page to be switched according to the language switching instruction; According to the target language type, a language pack set is queried to obtain a corresponding target language pack; the language pack set is loaded based on the language configuration information; the target language pack includes each target text corresponding to each page element in the page to be switched under the target language type; Obtaining each current text corresponding to each page element in the page to be switched; The current texts corresponding to the page elements in the page are updated according to the target texts in the target language package to obtain the target page after language switching.

2. The method according to claim 1, characterized in that The method further comprises: Obtain code information corresponding to the page; Traversing the code information to obtain each of the page elements including the language switching identifier; According to the language configuration information, language conversion is performed on each text corresponding to each of the page elements to obtain each language package corresponding to each of the page elements in each language type; The language pack set is generated according to each of the language packs.

3. The method according to claim 2, characterized in that The language conversion is performed on each text corresponding to each of the page elements according to the language configuration information to obtain each language package corresponding to each of the page elements in each language type, including: Determine each language type according to the language configuration information; For each language type, query the historical conversion record according to the text corresponding to the page element to obtain the first text of the text corresponding to the page element in the language type; Obtaining a second text in the language type for the text input corresponding to the page element; A language pack corresponding to the language type is obtained according to the first text and the second text.

4. The method according to claim 1, characterized in that: The steps of determining the page to be switched include: Get the activation status of each page; The page to be switched is obtained according to the page whose activation status belongs to the activated page.

5. The method according to any one of claims 1 to 4, characterized in that: The updating of each current text corresponding to each page element in the page according to each target text in the target language package to obtain a target page after language switching includes: If the page is a non-modal page, the page is notified through the observer mode to update the current texts corresponding to the page elements in the page according to the target texts, so as to obtain the target page after the language is switched; If the page is a modal page, when it is detected that the page is displayed, the current texts corresponding to the page elements in the page are updated according to the target texts to obtain the target page after the language is switched.

6. The method according to claim 5, characterized in that The step of notifying the page through the observer mode to update the current texts corresponding to the page elements in the page according to the target texts to obtain the target page after the language is switched includes: Notifying the page through the observer mode to update the current text corresponding to the page element in the page according to the target text; Obtain the text display area range corresponding to the page element in the page; According to the text display area range, adjusting the display format corresponding to the target text; The target text after adjusting the display format is output to the text display area to obtain the target page after language switching.

7. A language switching device, characterized in that: The device comprises: A first acquisition module, used to acquire a language switching instruction, and determine a target language type and a page to be switched according to the language switching instruction; A query module, configured to query a language package set according to the target language type to obtain a corresponding target language package; the language package set is loaded based on the language configuration information; the target language package includes each target text corresponding to each page element in the page to be switched under the target language type; A second acquisition module is used to acquire each current text corresponding to each page element in the page to be switched; The switching module is used to update the current texts corresponding to the page elements in the page according to the target texts in the target language package to obtain the target page after the language is switched.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Cited By

  • Multilingual resource decoupling method based on business meta-model

    CN120469761A

  • Enterprise application internationalization method and device based on meta-model context awareness, equipment and storage medium

    CN121579123A