Cross-platform Adaptive Internationalization Language Dynamic Switching Method Based on Database

By building a unified database and caching mechanism, the problem of decentralization of international language management on different platforms is solved, and cross-platform language resources are unified management and seamless switching, system performance and user experience are improved, and the rapid expansion of new languages is supported.

CN119886164BActive Publication Date: 2025-08-01HANGZHOU ARTECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510376859.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-28
Publication Date
2025-08-01
Estimated Expiration
2045-03-28

AI Technical Summary

Technical Problem

In the prior art, the international language management of different platforms is scattered, the switching is inconvenient, and the cross-platform compatibility is poor, resulting in high development and maintenance costs, and the language switching process is cumbersome, affecting system performance and user experience.

Method used

By building a unified database to store international language data, providing unified language request interface and cache processing, realizing cross-platform adaptive international language dynamic switching, and supporting multi-end collaborative software product development, including the Web side, client side and APP side.

Benefits of technology

It realizes centralized and unified management of language resources, reduces development and maintenance costs, improves system performance, ensures seamless transition and efficient operation of language switching, provides a smooth user experience, and supports the rapid expansion of new languages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119886164B_ABST
    Figure CN119886164B_ABST
Patent Text Reader

Abstract

The present invention discloses a cross-platform adaptive internationalized language dynamic switching method based on a database. This method constructs a multi-language resource database table structure to uniformly store multi-language resources, establish data associations and unique identifiers; provides a unified and general language request interface to receive requests, query the database to obtain resources and write them into the cache layer, and generate a version identifier; establishes a multi-terminal adaptation mechanism to achieve incremental updates of the front-end application according to the cache version identifier and adapt to requests from different platforms and devices; realizes seamless interface updates through an event mechanism to avoid reloading the application; builds an extended management platform to support the addition, deletion, modification, query, batch import of language resources, and the integration of automated translation interfaces. The present invention solves the problems of scattered language resource management, inconvenient switching, and poor cross-platform compatibility in the prior art, can simplify the management process, reduce costs, improve system performance and scalability, and bring a smooth and convenient multi-language usage experience to users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, and in particular to a cross-platform internationalized language dynamic switching technology based on database storage combined with a microservice architecture, and specifically relates to a database-based cross-platform adaptive internationalized language dynamic switching method. Background Art

[0002] With the widespread adoption of the internet and mobile applications, and the expansion of domestic platform software, applications, and websites into the international market, providing multilingual support has become an essential requirement, as these platforms, applications, and websites need to serve user groups in different regions, countries, and languages. Therefore, the international development of platform software, applications, and websites is particularly important, and their language switching capabilities play a vital role in enhancing user experience and meeting global market demands.

[0003] At present, the development languages and technology stacks used by the web, client, and APP ends of applications on different platforms are different, and the internationalization solutions adopted and their switching methods are also different.

[0004] In the back-end Java language, properties files are often used to store internationalized data. There are two main data formats: (1) key-value pairs and (2) JSON. Create a properties file for each language and use the language and key-value pairs to locate the corresponding values in the configuration file.

[0005] In front-end languages, JavaScript configuration files in JSON format are typically used to store translated text for each language. Each language corresponds to one or more JSON files containing key-value pairs, where the key is a fixed identifier and the value is the translated text. Based on the language selected by the user, the front-end dynamically loads the corresponding translation file.

[0006] In client-side C++, you typically use the tr() function to mark strings for translation. In Qt code, you use the tr() function to mark strings for translation. Use the lupdate tool to generate a .ts file, then use the lrelease tool to compile the .ts file into a .qm file. Finally, load the .qm file in your application to apply the translation.

[0007] Under the microservices architecture, different front-end applications adopt different methods and file storage for internationalized languages. When entering internationalized data in this way, if multiple languages need to be supported, different files must be opened simultaneously or multiple times to find the corresponding key values and perform translations. Especially for characters with double-byte encoding such as Chinese, manual Unicode character encoding conversion is required after data entry to ensure normal reading. Different sub-applications independently implement their internationalization and international resource management, resulting in redundancy and duplication of international resources, as well as non-uniform international language environments. When entering a new language or adding a new type of language, corresponding out-of-package upgrade processes (upgrading the application) need to be executed for different applications to take effect. In addition, a series of cumbersome and complex processes such as manual entry, editing, verification, out-of-package, release, and user upgrade are also accompanied by problems such as high development costs, difficult maintenance, and performance loss.

[0008] In view of the above problems, there is an urgent need for an innovative solution to integrate the internationalization requirements of different platforms, achieve centralized and unified management of language resources, simplify the language switching process, improve system performance, ensure seamless transition of language switching, and facilitate the expansion of new languages. Based on this need, this patent proposes a cross-platform adaptive internationalized language dynamic switching method and system based on a database, aiming to fundamentally solve the deficiencies of the prior art and provide strong support for the internationalization development of software. Summary of the Invention

[0009] In view of the deficiencies of the current related prior art, the present invention provides a cross-platform adaptive internationalized language dynamic switching method based on a database. The present invention focuses on the software product development scenario of multi-terminal (Web terminal, client terminal, APP terminal, etc.) collaboration under the microservices architecture, aiming to solve a series of problems in the prior art such as scattered language resource management, inconvenient switching, poor cross-platform compatibility, and cumbersome data storage operations in the internationalization process of different platforms. To this end, the present invention constructs a unified database to store internationalized language data, realizes the internationalization interface of the back-end service and cache processing, and achieves cross-platform adaptive internationalized language dynamic switching. This can not only simplify the language resource management process, reduce development and maintenance costs, but also improve system performance, ensure the stable and efficient operation of the system in different language environments, bring a more smooth and convenient user experience to users, and at the same time improve the scalability of the system to better adapt to the changing market demands.

[0010] To achieve the above object, the technical solution adopted by the present invention is: a cross-platform adaptive internationalized language dynamic switching method based on a database, including:

[0011] Build the table structure of the multilingual resource database: Create a database table that includes a primary key field, an identifier field, and multilingual fields. Each language field corresponds to a translated text in a specific language, which is used to uniformly store multilingual resources, establish data association relationships and unique identifiers for different languages;

[0012] Provide a unified and general language request interface: The backend service provides a unified interface to respond to requests for language switching operations triggered from the interface. When the user performs a language switching operation on the interface, this interface receives the corresponding request, queries the database according to the request parameters to obtain the target language resources, then writes the obtained language resources into the cache layer, and generates a version identifier at the same time;

[0013] Establish a multi-terminal adaptation mechanism: Provide unified interface adaptation for different front-end applications. The front-end applications implement incremental updates based on the cache version identifier to adapt to requests from different platforms and devices;

[0014] Implement seamless interface updates: During the language switching process, capture the user's language switching operation through an event mechanism, obtain the updated language resources according to the cache version identifier, update the interface elements and text display content, avoid reloading the entire application, and ensure seamless transition of the interface;

[0015] Build an extension management platform: Provide a visual interface to support operations such as adding, deleting, modifying, and querying language resources, support batch import and integration of automated translation interfaces, and facilitate the configuration and management of language resources.

[0016] Further, in the step of building the table structure of the multilingual resource database, execute specific SQL statements to create the database table. The table structure includes a primary key for uniquely identifying data, category information, internationalization content identifiers, and fields corresponding to multiple languages, and records the last update date at the same time.

[0017] Further, in the step of providing a unified and general language request interface, the backend interface implements a general interface. The front-end application stores data in the browser's local storage space, and by default uses the language of the browser or the operating system. The user can separately set the language to be displayed. The process of obtaining language information is as follows:

[0018] The interface starts or triggers a request to obtain language information at regular intervals. The front-end request can carry the last update time;

[0019] If the backend determines that there is data, it returns the corresponding data and the front-end refreshes the local cache;

[0020] If the backend determines that there is no data, it returns that there is no update and the process ends.

[0021] Further, in the step of building the extended management platform, a front-end operation page is provided, which supports manually adding language information with Chinese as a required item, and other language information can be optionally filled in or automatically translated from Chinese by invoking the translation system service in the background and then stored in the database; it also supports batch importing of language information through an Excel table. The steps for batch generating internationalized language texts through the Excel table batch import mechanism are as follows:

[0022] Download the import template from the web page;

[0023] Edit the language texts to be batch imported for translation;

[0024] Upload the Excel table file to be imported;

[0025] After the file data reaches the backend logic, determine whether the file data is legal;

[0026] If the data is legal, read the file information, call the translation engine through backend code processing, and translate multiple language text information;

[0027] Generate a unique internationalization key and store the relevant data in the database.

[0028] Further, when adding internationalized language configuration on the web side, the specific process is as follows:

[0029] After entering the web-side internationalized language configuration addition page, the Chinese required item needs to be entered first;

[0030] Subsequently, determine whether to customize the language information. If customizing the translated language information is selected, first determine whether there is duplicate language text information. If there is a duplicate, a page prompt "This language text information already exists" will be given; if there is no duplicate, the data will enter the backend logic; if not customizing the language information, the data will directly reach the backend logic;

[0031] After the data reaches the backend logic, determine again whether there is duplicate language text information. If there is a duplicate, the same page prompt "This language text information already exists" will be given; if there is no duplicate, call the translation engine through backend code processing to translate multiple language text information;

[0032] Then generate a unique internationalization key and store the relevant data in the database.

[0033] Further, in the provided unified general language request interface, when the user selects a language or the device language environment changes, the system loads the corresponding language resources in real time through this interface, replaces the interface elements according to the preset rules, and updates the text display content based on the language data obtained from the backend interface to achieve seamless switching of the multi-language interface.

[0034] Furthermore, the multi-language resource database table structure storage and management mechanism is as follows: Multiple language resources are entered into the database through configuration files or front-end page input. During application operation, according to user requirements or system settings, the required language resources are queried and dynamically loaded from the database using a query algorithm, and at the same time, resource updates and management are combined with the version identifier of the cache layer.

[0035] Furthermore, when a new language is extended, corresponding language fields are added to the database table, and the configuration file or front-end page of the extended management platform is updated to support the entry and management of the new language. The query and return logic for the new language is added to the unified general language request interface to support the new language without affecting the existing functions.

[0036] Furthermore, the system's logs and error messages have been internationalized, specifically as follows:

[0037] During the log recording stage, when the back-end service records logs, a placeholder key is used plus any number of static texts to form a log entry. The key is an identifier pointing to the translation string in the front-end language pack;

[0038] During the log transmission stage, the log entry remains in its original state containing the key and additional text during the transmission from the back-end to the front-end;

[0039] During the front-end parsing stage, the front-end parses the key in the log entry and accesses the internationalized language pack dynamically loaded according to the user's language preference;

[0040] During the internationalization processing stage, the translation text matching the key is found in the language pack and replaced at the corresponding position in the original log message, without affecting the static text part;

[0041] During the log display stage, the processed log entry is localized according to the user's language preference and displayed on the user interface;

[0042] Error message internationalization: The back-end returns the key, and the front-end uses a request interceptor to find the corresponding text according to the internationalized language pack for error messages.

[0043] The present invention adopts the above technical solutions and has at least the following beneficial effects:

[0044] 1. Different from the situation in the prior art where language switching requires restarting the application, the present invention utilizes a unified general language request interface. After the user selects a language, it can capture the user's language switching request in real time. The system quickly obtains the target language resources from the database according to the request parameters, and combines with the efficient cooperation of the cache layer to quickly update the interface elements and text display content, realizing language switching without restarting the application. For example, in a news and information application, when the user is browsing different news contents and wants to switch languages, using the technology of the present invention, the user can instantly see the conversion of the interface language, avoiding the inconvenience and delay caused by restarting the application, and greatly improving the user's usage efficiency and experience.

[0045] 2. By dynamically loading and real-time updating the interface, the present invention avoids the interface lag problem caused by reloading resources when switching languages based on localized files in the prior art. During the language switching process, the system accurately obtains the updated language resources according to the cache version identifier, realizes seamless replacement of interface elements and instant update of text content, ensuring a smooth and fluent language switching process and providing users with a high-quality interaction experience. For example, in a game application with complex interaction functions, when the player switches languages during the game, there will be no interface lag or operation interruption, and the game can continue to run smoothly, and the language switching is completed instantly.

[0046] 3. The present invention breaks the traditional cumbersome language file management mode and centrally manages all language resources through configuration files or databases. The constructed multi-language resource database table structure includes a primary key field, an identifier field, and multi-language fields. Each language translation text has a corresponding storage location, establishing a data association relationship and a unique identifier for different languages. Developers no longer need to develop interface elements or maintain a large number of scattered language files for each language separately, and can complete the maintenance work of all language resources in a unified database, greatly reducing the development and maintenance costs. For example, when a large number of translation texts of a certain language need to be updated, batch operations can be performed in the database, instead of modifying them one by one in numerous scattered files, reducing the probability of errors and improving the management efficiency.

[0047] 4. With the help of the dynamic loading mechanism, the system obtains the required language resources from the database according to the user's needs or system settings during runtime, without the need to package all language resources into the application. This not only reduces the package size of the application and speeds up the download time, but also supports the dynamic update of language resources. Users can experience new language support without updating the entire application. Taking an office software used globally as an example, which supports multiple languages, after adopting the technology of the present invention, the application installation package size is significantly reduced. After a new language version is launched, users can obtain the update in the application in a timely manner without waiting for the update and installation of the entire application.

[0048] 5. The internationalization solution provided by the present invention breaks away from the limitations of a single platform and is widely applicable to multiple platforms such as desktop applications, mobile applications, and web applications. By establishing a unified interface adaptation mechanism, different front-end applications can achieve incremental updates according to the cache version identifier, and can dynamically adjust the interface layout and element display mode according to the characteristics of different platforms such as screen size, resolution, and interaction method, ensuring cross-platform consistency and compatibility. For example, an online education application that has both a Web version, an APP version, and a desktop client. Whether learning courses on the computer desktop, previewing or reviewing courses on the mobile APP, or interacting with teachers on the web, users can enjoy the same high-quality multilingual switching service on different platforms, and the interface display and interaction experience can be optimized according to the platform characteristics, providing users with a unified and good cross-platform usage experience.

[0049] 6. The present invention realizes automatic language switching and can automatically switch languages according to the language environment of the device or the user's preset language preference. Compared with the way in which users need to manually set languages in some existing technologies, it greatly eliminates the tediousness of manually selecting languages. For example, when a user is traveling abroad and the language setting of the mobile device is the local language, after installing the application supported by the present invention, the application will automatically recognize the device language and switch to the corresponding language interface without the need for manual operation by the user, truly making the language switching "invisible" and improving the convenience and intelligence of the user experience.

[0050] 7. In the prior art, adding a new language often requires a large amount of code modification and interface reconstruction, which is a complex process and prone to errors. The present invention greatly simplifies the process of adding a new language through a unified language resource management method. When a new language needs to be extended, only need to add the corresponding language field in the database table, update the configuration file of the extended management platform or the front-end page, and add the query and return logic for the new language in the unified general language request interface, then the new language can be supported without affecting the existing functions. For example, if a new small language needs to be added to a social application, developers can perform simple operations according to the above steps to quickly realize the integration of the new language, greatly improving the scalability of the system and enabling it to quickly respond to the changing needs of the market for multilingual support.

[0051] 8. The present invention provides developers with more flexible dynamic language switching control capabilities. It supports users to freely switch languages within the application. Developers can customize personalized language switching processes and interface display methods according to the business logic of the application and user needs, rather than simply relying on the default language settings of the operating system. For example, in a financial management application with a unique interaction design, developers can use the present invention to customize personalized language switching prompts and interface layouts for different investment scenarios to better meet user needs and provide a better user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following-described drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0053] Figure 1 It is a flowchart of the internationalized language dynamic switching method of the present invention;

[0054] Figure 2 It is a flowchart of the internationalized language configuration of the present invention;

[0055] Figure 3 It is a flowchart of the steps for batch generating internationalized language texts by the import mechanism of the present invention;

[0056] Figure 4 It is a flowchart of the steps for providing a unified general language request interface by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0057] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description involves the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. On the contrary, they are only examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.

[0058] Please refer to Figure 1 , this embodiment provides a cross-platform adaptive internationalized language dynamic switching method based on a database, including:

[0059] Construct a multi-language resource database table structure: Create a database table including a primary key field, an identifier field, and multi-language fields. Each language field corresponds to a language translation text, which is used to uniformly store multi-language resources, establish data association relationships and unique identifiers for different languages;

[0060] Provide a unified and general language request interface: The backend service provides a unified interface to respond to requests for language switching operations triggered from the interface. When the user performs a language switching operation on the interface, this interface receives the corresponding request, queries the database based on the request parameters to obtain the target language resources, then writes the obtained language resources into the cache layer, and simultaneously generates a version identifier.

[0061] Establish a multi - terminal adaptation mechanism: Provide unified interface adaptation for different front - end applications. The front - end applications implement incremental updates according to the cache version identifier to adapt to requests from different platforms and devices. For example, in the Web front - end, through JavaScript code logic used to judge the difference between the cache version identifier and the backend data version and decide whether to pull updated language resource data from the backend, it decides whether to pull updated language resource data from the backend according to the cache version identifier to achieve efficient incremental updates. For the mobile APP front - end, according to the characteristics of different operating systems (such as Android and iOS), it adapts to different screen sizes and interaction methods, and combines the cache version identifier to complete the update and display of language resources.

[0062] Implement seamless interface updates: During the language switching process, capture the user's language switching operation through the event mechanism, obtain the updated language resources according to the cache version identifier, update the interface elements and text display content, avoid re - loading the entire application, and ensure seamless transition of the interface. For example, in a Web application, using the event listening mechanism of JavaScript, when the user triggers a language switching operation, it immediately responds and obtains the latest language resources from the backend according to the cache, and accurately updates the text elements on the interface through DOM operations to achieve fast switching of the interface language, and the whole process is smooth and without lag.

[0063] Build an extension management platform: Provide a visual interface to support operations such as adding, deleting, modifying, and querying language resources, support batch import and integration of automated translation interfaces, and facilitate the configuration and management of language resources. The visual interface has clear operation guides, and developers can intuitively perform operations such as adding, modifying, and deleting language resources on the interface. The batch import function supports quickly entering a large number of language resources through an Excel table, and the automated translation interface can quickly generate translation texts in other languages based on the existing Chinese content.

[0064] As an implementation method, in the step of constructing the multi - language resource database table structure in this embodiment, specific SQL statements are executed to create a database table. The table structure includes a primary key for uniquely identifying data, category information, internationalization content identifiers, and fields corresponding to multiple languages, and at the same time records the last update date.

[0065] Such as Figure 2As an implementation, the front-end web operation page is used to manage language information. Chinese is a required field, and the corresponding translations of the corresponding languages can be optionally filled in or left blank. When saving, the background will call the translation system service according to the provided Chinese to translate the corresponding languages, and then store them in the database. All these operations are completed in the background. Users only need to simply input Chinese to generate a unique key and translation information in all national languages. In this embodiment, when adding internationalized language configuration on the web side, the specific process is as follows:

[0066] After entering the web-side internationalized language configuration addition page, the required Chinese field needs to be input first;

[0067] Subsequently, it is judged whether to customize the language information. If the custom translation language information is selected, it is first judged whether there is duplicate language text information. If there is a duplicate, the page prompt "This language text information already exists" will be given; if there is no duplicate, the data will enter the back-end logic; if the language information is not customized, the data will directly reach the back-end logic;

[0068] After the data reaches the back-end logic, it is judged again whether there is duplicate language text information. If there is a duplicate, the page prompt "This language text information already exists" will be given as well; if there is no duplicate, the translation engine will be called through background code processing to translate multiple language text information;

[0069] Then a unique internationalized key is generated, and the relevant data is stored in the database.

[0070] As Figure 3 shown, as an implementation, in the steps of building the extended management platform in this embodiment, a front-end operation page is provided, which supports manually adding language information, with Chinese as the required field, and other language information can be optionally filled in or automatically translated by the background calling the translation system service according to Chinese and then stored in the database; it also supports batch importing language information through an Excel table. The process of batch importing language information through an Excel table is as follows:

[0071] Download the import template from the web page; <U+

[0072] Edit the language text to be batch imported for translation;

[0073] Upload the Excel table file to be imported;

[0074] After the file data reaches the back-end logic, it is judged whether the file data is legal;

[0075] If the data is legal, read the file information, call the translation engine through background code processing to translate multiple language text information;

[0076] Generate a unique internationalized key and store the relevant data in the database.

[0077] This process downloads and imports a template through a web page. After completing the language text editing, an Excel file is uploaded. Through a series of operations such as the back-end logic's judgment of data legality and information reading, a translation engine is called to generate text in multiple languages, and then a unique internationalization key is generated and stored in the database. This process greatly improves the efficiency of internationalization language text generation and management, and realizes the efficient processing of language resources in a convenient, time-saving and labor-saving way.

[0078] As an implementation manner, in the unified general language request interface provided in this embodiment, when the user selects a language or the device language environment changes, the system loads the corresponding language resources in real time through this interface, replaces the interface elements according to the preset rules, and updates the text display content based on the language data obtained from the back-end interface, realizing seamless switching of the multi-language interface.

[0079] As an implementation manner, the storage and management mechanism of the multi-language resource database table structure in this embodiment is as follows: multiple language resources are entered into the database through a configuration file or input on the front-end page. During the operation of the application, according to the user's needs or system settings, the required language resources are queried and dynamically loaded from the database using a query algorithm, and at the same time, the version identifier of the cache layer is combined for resource update and management.

[0080] As an implementation manner, when a new language is extended in this embodiment, a corresponding language field is added to the database table, the configuration file of the extended management platform or the front-end page is updated to support the entry and management of the new language, and the query and return logic for the new language is added to the unified general language request interface, realizing support for the new language without affecting the existing functions.

[0081] As an implementation manner, in a Web application, in order to support logging and display in a multi-language environment, a structured logging method is usually adopted. This method allows log entries to contain placeholders (such as {key}), and these placeholders will be parsed and replaced on the front end. Specifically, when the back-end system generates a log entry, it will use a predefined key (such as {key}) plus any additional text. This approach keeps the original log message unchanged, while the message actually displayed to the user depends on the internationalization (i18n) processing in the front-end application.

[0082] The front-end part receives the log data from the back-end and parses the {key} in it. Then, this method will query the internationalization language package used by the front-end application to find the language resources corresponding to the {key}. The language package usually contains the specific text information corresponding to multiple language environments. Once the appropriate translated text is found, the front-end logic will replace the {key} in the original log message and display the final, language-localized information on the user's interface.

[0083] In this embodiment, the logs and error prompts of the system have been internationalized. Specifically:

[0084] Log recording stage: When the back-end service records logs, it uses the placeholder {key} plus any number of static texts to form a log entry. Here, the {key} is an identifier that points to a translation string in the front-end language package.

[0085] Log transmission stage: During the process of transmitting the log entry from the back-end to the front-end, it remains in its original state, that is, in the form containing the {key} and any additional text.

[0086] Front-end parsing stage: After the front-end receives the log entry, it parses the {key} in the log entry. The internal implementation of this method may include accessing the internationalization language package stored in the front-end, which is usually dynamically loaded according to the user's language preference.

[0087] Internationalization processing stage: Search for the translation text that matches the {key} in the language package and replace it in the corresponding position of the original log message. This process needs to ensure that the replacement logic does not affect any static text parts originally existing in the log.

[0088] Log display stage: Finally, the processed log entry will be displayed in the user interface, and at this time, the log information is already the version that has been localized according to the user's language preference.

[0089] Such a design pattern not only improves the maintainability of the log system but also enhances the user experience because it allows the log information to be presented in the user's mother tongue, making it easier to understand.

[0090] Internationalization of error prompts: The back-end returns {key}, and the front-end error prompts uniformly go through the request interceptor and use the errorIntl method to process the {key} passed by the back-end. According to the internationalization language package, find the corresponding text information and display it.

[0091] Internationalization transformation of dates, times, and numbers:

[0092] To enable applications or websites to accommodate global users, the internationalization of dates, times, and numbers is also essential. There are significant differences in the representation of dates, times, and numbers among different countries and regions.

[0093] Date Format

[0094] Month - Day - Year (MM / DD / YYYY): Commonly used in countries such as the United States and Canada.

[0095] Day - Month - Year (DD / MM / YYYY): Commonly used in countries such as the United Kingdom and Australia.

[0096] Year - Month - Day (YYYY / MM / DD): Commonly used in countries such as China and Japan.

[0097] Time Format

[0098] 12 - hour format: Represented by AM (ante meridiem) and PM (post meridiem).

[0099] 24 - hour format: Uses 0 - 23 to represent the hours in a day.

[0100] Number Format

[0101] Decimal point: In some countries, a dot (.) is used to represent the decimal point, while in some countries, a comma (,) is used.

[0102] Thousands separator: In some countries, a comma (,) is used to represent the thousands separator, while in some countries, a dot (.) is used.

[0103] Using the Intl.DateTimeFormat API This API can be used to format date and time, supports multiple language environments, and can specify various parts of the date and time (such as year, month, day, hour, minute, second, etc.). Using the Intl.NumberFormat API This API can be used to format numbers, supports number formats in multiple language environments, such as currency, percentage, etc.

[0104] As Figure 4 shown, in the step of providing a unified general - language request interface in this embodiment, the backend interface implements a general interface, the front - end application stores data in the browser's local storage space, by default, it adopts the language of the browser or the operating system, and the user can separately set the language to be displayed. The process of obtaining language information is as follows:

[0105] The interface starts or triggers a request to obtain language information at regular intervals. When the front - end requests, it can carry the last update time;

[0106] If the backend determines that there is data, it returns the corresponding data, and the front - end refreshes the local cache;

[0107] If the backend determines that there is no data, it returns "no update" and the process ends.

[0108] Implement a general interface, which is divided into different typeId parameters according to different projects, as well as the language type of language. The front-end application requests this interface based on the above two fields and will return data in the format of Map<key, value>. The front-end application will store it in the browser's local storage space. By default, the language of the browser or operating system is used. Users can set the language to be displayed separately, and the setting is only valid for the current user.

[0109] The present invention provides a general method and system for internationalized dynamic language switching, which can automatically switch the application language according to the user's selection or the language environment of the device in different user environments. This mechanism can dynamically load different language resources at runtime, support seamless switching of multi-language interfaces, and improve the user experience and adaptability.

[0110] The present invention adds database-stored language resources through configuration files or page inputs, and can dynamically load the required language resources according to user needs or system settings during application runtime, ensuring that the system has good scalability and flexibility.

[0111] The present invention solves the problems in the prior art that the application needs to be restarted or the interface is chaotic when switching languages, and provides a seamless switching solution. After the user selects a language, the interface display can be updated in real time without reloading the entire application.

[0112] The present invention supports the extension of multiple languages, not limited to the currently supported languages, but can be easily extended to new language environments by adding new language resources to meet the needs of users in different regions.

[0113] This system can be widely applied to different platforms and devices, including desktop applications, mobile applications, web pages, and APPs, and does not depend on the operating system or hardware environment, having wide applicability.

[0114] In traditional localization systems, language resources are usually stored as independent files (such as.json,.xml, or.properties files), and new language files need to be loaded each time the language is switched. This method usually loads language files at application startup, and resources need to be reloaded when switching languages, which may cause interface lags.

[0115] Advantages: Simple to implement, suitable for small applications.

[0116] Do not require complex dynamic language switching algorithms, and the development is relatively straightforward.

[0117] Disadvantages: Each time the language is switched, resources need to be reloaded, resulting in a long switching time and affecting the user experience. It does not support real-time interface updates, and the interface may need to be refreshed or the application restarted, resulting in a non-smooth user experience.

[0118] Comparison with the present invention:

[0119] The present invention avoids the problems of resource reloading and interface jamming through dynamic loading and real-time interface updates, making the language switching smoother and more fluent.

[0120] Some operating systems (such as Android and iOS) provide system-level internationalization support, and applications can directly call the language switching interfaces provided by the operating system.

[0121] Advantages: The internationalization support provided by the operating system itself eliminates the need for additional resource management during development.

[0122] System-level language switching is usually automatic and does not require user intervention.

[0123] Disadvantages: System-level language switching is usually not flexible enough and cannot customize the user experience according to the internal requirements of the application. It does not support dynamic language switching within the application and cannot dynamically adjust the language according to different users or scenarios.

[0124] Comparison with the present invention: The present invention provides a more flexible dynamic language switching mechanism, supporting users to freely switch languages within the application instead of simply relying on the default language settings of the operating system. Through the present invention, developers can better control the language switching behavior in the application and provide a better user experience.

[0125] Some systems fix and embed multiple language resources in the application, and directly replace the interface content after the user selects a language. This solution usually relies on language packages or resource files generated during compilation.

[0126] Advantages: Simple implementation, no need for complex runtime resource loading. All language resources are loaded at once, reducing network requests during runtime.

[0127] Disadvantages: The package size of the application is relatively large, which may affect the download and installation time. It does not support dynamic expansion or update of language resources, increasing the difficulty of updates.

[0128] Comparison with the present invention: The present invention dynamically loads language resources, eliminating the need to package all language resources into the application, thus reducing the package size and download time of the application. At the same time, the present invention supports dynamic updates of language resources, and users can experience new language support without updating the entire application.

[0129] Although the embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.

Claims

1. Cross-platform adaptive internationalized language dynamic switching method based on a database, characterized in that: Including: Constructing a multi - language resource database table structure: Create a database table that includes a primary key field, an identifier field, and multi - language fields. Each language field corresponds to a translated text in a specific language, which is used to uniformly store multi - language resources, establish data association relationships and unique identifiers for different languages; Providing a unified and general language request interface: The backend service provides a unified interface to respond to language switch operation requests triggered from the interface. When the user performs a language switch operation on the interface, this interface receives the corresponding request, queries the database according to the request parameters to obtain the target language resources, then writes the obtained language resources into the cache layer, and simultaneously generates a version identifier; Establishing a multi - terminal adaptation mechanism: Provide unified interface adaptation for different front - end applications. The front - end applications implement incremental updates according to the cache version identifier to adapt to requests from different platforms and devices; Implementing seamless interface updates: During the language switch process, capture the user's language switch operation through an event mechanism, obtain the updated language resources according to the cache version identifier, update the interface elements and text display content, avoid re - loading the entire application, and ensure a seamless transition of the interface; Building an extension management platform: Provide a visual interface to support operations such as adding, deleting, modifying, and querying language resources, support batch import and integration of automated translation interfaces, and facilitate the configuration and management of language resources; In the said providing a unified and general language request interface, when the user selects a language or the device language environment changes, the system loads the corresponding language resources in real - time through this interface, replaces the interface elements according to preset rules, and updates the text display content based on the language data obtained from the backend interface to achieve seamless switching of the multi - language interface; The system's logs and error messages have been internationalized. Specifically: In the log recording stage, when the backend service records logs, it uses a placeholder key plus any number of static texts to form a log entry. The key is an identifier pointing to the translated string in the front - end language pack; In the log transmission stage, the log entry remains in its original state containing the key and additional text during the transmission from the backend to the front - end; In the front - end parsing stage, the front - end parses the key in the log entry and accesses the internationalized language pack dynamically loaded according to the user's language preference; In the internationalization processing stage, search for the translated text that matches the key in the language pack and replace it at the corresponding position in the original log message, without affecting the static text part; In the log display stage, the processed log entry is displayed on the user interface after being localized according to the user's language preference; Error message internationalization: The backend returns a key, and the front - end uses a request interceptor to find the corresponding text according to the internationalized language pack for error messages; 2. The method according to claim 1, wherein: In the step of constructing the multi - language resource database table structure, specifically execute SQL statements to create a database table. The table structure includes a primary key for uniquely identifying data, category information, an internationalization content identifier, and fields corresponding to multiple languages, and simultaneously records the last update date.

3. The method according to claim 1, wherein: In the step of providing a unified general language request interface, the backend interface implements a general interface. The front-end application stores data in the browser's local storage space, and by default, uses the language of the browser or operating system. Users can separately set the language to be displayed. The process of obtaining language information is as follows: When the interface starts or is triggered periodically to request language information, the front-end request can carry the last update time; If the backend determines that there is data, it returns the corresponding data, and the front-end refreshes the local cache; If the backend determines that there is no data, it returns that there is no update, and the process ends.

4. The method according to claim 1, characterized in that: In the step of building an extended management platform, a front-end operation page is provided, which supports manually adding language information. Chinese is a required field, and other language information can be optionally filled in or automatically translated by the background calling the translation system service according to Chinese and then stored in the database; it also supports batch importing of language information through an Excel sheet. Among them, the steps for batch generating internationalized language texts through the Excel sheet batch import mechanism are as follows: Download the import template from the web page; Edit the language texts to be batch imported for translation; Upload the Excel sheet file to be imported; After the file data reaches the backend logic, judge whether the file data is legal; If the data is legal, read the file information, call the translation engine through the backend code processing, and translate multiple language text information; Generate a unique internationalization key and store the relevant data in the database.

5. The method according to claim 4, wherein: When adding internationalized language configuration on the web side, the specific process is as follows: After entering the web side internationalized language configuration addition page, the Chinese required field needs to be entered first; Subsequently, judge whether to customize the language information. If you choose to customize the translated language information, first judge whether there is duplicate language text information. If there is a duplicate, a page prompt "This language text information already exists" will be given; if there is no duplicate, the data enters the backend logic; if you do not customize the language information, the data directly reaches the backend logic; After the data reaches the backend logic, judge again whether there is duplicate language text information. If there is a duplicate, the same page prompt "This language text information already exists" will be given; if there is no duplicate, call the translation engine through the backend code processing and translate multiple language text information; Then generate a unique internationalization key and store the relevant data in the database.

6. The method according to claim 1, wherein: The storage and management mechanism of the multi-language resource database table structure is as follows: Enter multiple language resources into the database through configuration files or front-end page input. During the application operation, according to user requirements or system settings, use a query algorithm to query and dynamically load the required language resources from the database, and at the same time combine the version identifier of the cache layer for resource update and management.

7. The method according to claim 6, characterized in that: When a new language is extended, add the corresponding language field to the database table, update the configuration file or front-end page of the extended management platform to support the entry and management of the new language, and add the query and return logic for the new language in the unified general language request interface to support the new language without affecting the existing functions.

Citation Information

Patent Citations

  • Language text management method and device, storage medium and electronic equipment

    CN113918254A

  • Multi-language configuration management method, electronic equipment and storage medium

    CN116739005A