Cross-platform self-adaptive internationalization language dynamic switching method based on database
By uniformly storing international language data in the database and providing cross-platform adaptive international language dynamic switching methods, the problem of dispersed and inconvenient language management in the existing technology is solved, efficient and seamless language switching and resource management are achieved, and development and maintenance costs are reduced.
Patent Information
- Application Number
- CN202510376859.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-03-28
AI Technical Summary
In the process of internationalization, different platforms in the prior art have decentralized language resource management, inconvenient switching, poor cross-platform compatibility, and cumbersome data storage operations, resulting in redundant and duplicate international resource, high development costs, difficulty in maintenance and performance losses.
By building a unified database to store international language data, providing back-end services international interfaces and cache processing, realizing cross-platform adaptive international language dynamic switching. The specific steps include building a multi-language resource database table structure, providing a unified common language request interface, establishing a multi-terminal adaptation mechanism, achieving seamless interface updates, and building an extended management platform.
It realizes centralized and unified management of language resources, simplifies the language switching process, improves system performance, ensures a seamless transition of language switching, and reduces development and maintenance costs.
Smart Images

Figure CN119886164A_ABST
Abstract
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 in particular to a cross-platform adaptive internationalized language dynamic switching method based on a database. Background Art
[0002] With the widespread popularity of the Internet and mobile applications, as well as the expansion of domestic platform software, applications, and websites into the international market, providing multilingual support has become an indispensable requirement, given that these platform software, 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 function plays a vital role in enhancing user experience and meeting global market needs.
[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 and switching methods adopted are also different.
[0004] In the back-end Java language, properties file format is usually used to store internationalized data. There are two main data formats: (1) key-value pair format; (2) JSON format. Create a properties file for each language and locate the corresponding value in the configuration file through different languages and key-value pairs.
[0005] In the front-end language, a JS configuration file in JSON format is usually used to store the translated text for each language. Each language corresponds to one or more JSON files, which contain 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 the client C++ language, the tr() function is usually used for translation marking. In the Qt code, the strings that need to be translated are marked by the tr() function. Use the lupdate tool to generate a .ts file, and then use the lrelease tool to compile the .ts file into a .qm file. Finally, load the .qm file in the application to apply the translation.
[0007] Under the microservice architecture, different front-end applications use different methods and files to store internationalized languages. When entering internationalized data in this way, if you need to support multiple languages, you must open different files at the same time or multiple times, find the corresponding key values, and translate them. Especially for double-byte encoded characters such as Chinese, you need to manually convert Unicode character encoding 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 inconsistency in international language environments. When entering a new language or adding a new language, the corresponding package upgrade process (upgrade application) must be executed for different applications to take effect. In addition, a series of tedious and complex processes such as manual entry, editing, verification, package release, 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, an innovative solution is urgently needed to integrate the internationalization requirements of different platforms, realize the centralized and unified management of language resources, simplify the language switching process, improve system performance, ensure the seamless transition of language switching, and facilitate the expansion of new languages. This patent is based on this demand and proposes a database-based cross-platform adaptive international language dynamic switching method and system, aiming to fundamentally solve the deficiencies of the existing technology and provide strong support for the international development of software. Summary of the invention
[0009] In view of the shortcomings of the current related prior art, the present invention provides a cross-platform adaptive international language dynamic switching method based on a database. The present invention focuses on the software product development scenario of multi-end (Web end, client end, APP end, etc.) collaboration under the microservice architecture, aiming to solve a series of problems in the prior art such as decentralized 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 stores international language data by constructing a unified database, realizes the back-end service internationalization interface and cache processing, and achieves cross-platform adaptive international language dynamic switching. This can not only simplify the language resource management process and reduce development and maintenance costs, but also improve system performance, ensure that the system runs stably and efficiently in different language environments, bring users a smoother and more convenient user experience, and improve the scalability of the system to better adapt to the changing market needs.
[0010] To achieve the above purpose, the technical solution adopted by the present invention is: a cross-platform adaptive international language dynamic switching method based on a database, comprising: Build a multilingual resource database table structure: Create a database table containing primary key fields, identifier fields, and multilingual fields, where each language field corresponds to a language translation text, which is used to uniformly store multilingual resources and establish data associations and unique identifiers in different languages; Providing a unified universal language request interface: The backend service provides a unified interface for responding to language switching operation requests triggered from the interface. When the user performs a language switching operation on the interface, the 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 generates a version identifier at the same time. Establish a multi-terminal adaptation mechanism: provide unified interface adaptation for different front-end applications, and the front-end applications implement incremental updates based on the cache version identifier to adapt to requests from different platforms and devices; Achieve seamless interface updates: During the language switching process, the user's language switching operation is captured through the event mechanism, and the updated language resources are obtained according to the cache version identifier, and the interface elements and text display content are updated to avoid reloading the entire application and ensure seamless interface transition; Build an extended management platform: Provide a visual interface to support the addition, deletion, modification and query of language resources, support batch import and automatic translation interface integration, and facilitate the configuration and management of language resources.
[0011] Furthermore, in the step of constructing a multilingual resource database table structure, SQL statements are specifically executed to create a database table, the table structure includes a primary key for uniquely identifying data, category information, internationalized content identifiers, and fields corresponding to multiple languages, and the last update date is recorded.
[0012] Furthermore, in the step of providing a unified universal language request interface, the backend interface implements a universal interface, and the frontend application stores data in the browser local storage space, using the language of the browser or operating system by default. The user can set the language to be displayed separately. The process of obtaining language information is as follows: The interface starts or triggers a timed request to obtain language information. The last update time can be included in the front-end request. If the backend determines that there is data, it returns the corresponding data and the frontend refreshes the local cache; If the backend determines that there is no data, it returns that there is no update and the process ends.
[0013] Furthermore, in the step of building the extended management platform, a front-end operation page is provided to support manual addition of language information, with Chinese as a required item, and other language information can be selected to be filled in or automatically translated into the database after the background translation system service is called according to Chinese; it also supports batch import of language information through Excel spreadsheets; wherein, the steps of batch generating internationalized language texts through the Excel spreadsheet batch import mechanism are as follows: Download the import template from the web page; Edit the language texts to be imported for translation in batches; Upload the Excel spreadsheet file to be imported; After the file data reaches the backend logic, it determines whether the file data is legal; If the data is legal, the file information is read and the translation engine is called through the background code processing to translate the text information into multiple languages; Generate a unique international key and store the relevant data in the database.
[0014] Furthermore, when adding international language configuration on the web side, the specific process is as follows: After entering the web-side international language configuration addition page, you need to enter the Chinese mandatory items first; Then determine whether to customize the language information. If you choose to customize the translation language information, first determine whether there is repeated language text information. If so, a page prompt "This language text information already exists" will be given; if not, the data will enter the backend logic; if the language information is not customized, the data will directly reach the backend logic; After the data reaches the backend logic, it is determined again whether there is duplicate language text information. If so, a page prompt "this language text information already exists" will be given. If not, the translation engine will be called through the backend code processing to translate the text information into multiple languages. Then generate a unique international key and store the relevant data in the database.
[0015] Furthermore, in the unified universal language request interface, when the user selects a language or the device language environment changes, the system loads the corresponding language resources through the interface in real time, replaces the interface elements according to preset rules, and updates the text display content based on the language data obtained by the back-end interface, thereby achieving seamless switching of multi-language interfaces.
[0016] 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 inputs; when the application is running, the required language resources are queried and dynamically loaded from the database using a query algorithm based on user needs or system settings, and the resources are updated and managed in combination with the version identifier of the cache layer.
[0017] Furthermore, when a new language is added, a corresponding language field is added to the database table, the configuration file or front-end page of the extension management platform 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 to support the new language without affecting existing functions.
[0018] Furthermore, the system logs and error prompts have been internationalized, specifically: During the logging phase, when the backend service records logs, it uses a placeholder key plus any amount of static text to form a log entry. The key is an identifier pointing to the translation string in the frontend language package. During the log transmission phase, log entries are transmitted from the backend to the frontend in their original state, including the key and additional text. In the front-end parsing phase, the front-end parses the key in the log entry and accesses the internationalized language pack that is dynamically loaded based on the user's language preference; During the internationalization processing phase, the translated text matching the key is searched in the language pack and replaced in the corresponding position of the original log message without affecting the static text part. In the log display phase, the processed log entries are localized according to the user's language preference and displayed in the user interface; Internationalization of error prompts: The backend returns the key, and the frontend uses the request interceptor to find the corresponding text based on the international language package for error prompts.
[0019] The present invention adopts the above technical solution, which has at least the following beneficial effects: 1. Unlike the prior art where language switching requires restarting the application, the present invention provides a unified universal language request interface, which can capture the user's language switching request in real time after the user selects the language. The system quickly obtains the target language resources from the database according to the request parameters, and combines the efficient collaboration of the cache layer to quickly update the interface elements and text display content, so that the language switch can be completed without restarting the application. For example, in a news information application, when the user is browsing different news content, if he wants to switch the language, he can use the technology of the present invention to instantly see the conversion of the interface language, avoiding the inconvenience and delay caused by restarting the application, and greatly improving the user's efficiency and experience.
[0020] 2. By dynamically loading and updating the interface in real time, the present invention avoids the problem of interface freeze caused by reloading resources when switching languages based on traditional localized files. During the language switching process, the system accurately obtains updated language resources based on the cached version identifier, realizes seamless replacement of interface elements and instant update of text content, ensures a smooth language switching process, and provides users with a high-quality interactive experience. For example, in a game application with complex interactive functions, when players switch languages during the game, there will be no interface freeze or operation interruption, the game can continue to run smoothly, and the language switch is completed instantly.
[0021] 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 multilingual resource database table structure includes a primary key field, an identifier field and a multilingual field. Each language translation text has a corresponding storage location, and data associations and unique identifiers of different languages are established. Developers no longer need to develop interface elements or maintain a large number of scattered language files for each language separately. The maintenance of all language resources can be completed in a unified database, which greatly reduces the development and maintenance costs. For example, when a large number of translated texts in a certain language need to be updated, batch operations can be performed in the database without having to modify them one by one in many scattered files, which reduces the probability of errors and improves management efficiency.
[0022] 4. With the help of the dynamic loading mechanism, the system obtains the required language resources from the database according to user needs or system settings during operation, without packaging all language resources into the application. This not only reduces the application package size 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, it supports multiple languages. After adopting the technology of the present invention, the size of the application installation package is significantly reduced. After the new language version is launched, users can obtain updates in the application in a timely manner without waiting for the update and installation of the entire application.
[0023] 5. The internationalization solution provided by the present invention gets rid of the limitation of a single platform and is widely applicable to multiple platforms such as desktop applications, mobile applications, web applications, etc. By establishing a unified interface adaptation mechanism, different front-end applications can realize incremental updates according to the cache version identifier, and can dynamically adjust the interface layout and element display mode according to the screen size, resolution, interaction mode and other characteristics of different platforms to ensure cross-platform consistency and compatibility. For example, an online education application that has a Web end, an APP end and a desktop client at the same time, whether it is studying courses on the computer desktop, previewing or reviewing courses on the mobile phone APP, or interacting with teachers on the web page, users can enjoy the same high-quality multi-language switching service on different platforms, and the interface display and interactive experience can be optimized according to the platform characteristics, providing users with a unified and good cross-platform usage experience.
[0024] 6 The present invention realizes automatic language switching, and can automatically switch the language according to the language environment of the device or the language preference preset by the user. Compared with the method in some prior arts where the user needs to manually set the language, the tediousness of manually selecting the language is greatly eliminated. For example, when a user travels abroad and the language of the mobile device used is set to the local language, after installing the application supported by the present invention, the application will automatically identify the device language and switch to the corresponding language interface without the need for manual operation by the user, which truly makes the language switching "unconscious", improving the convenience and intelligence of the user experience.
[0025] 7. In the prior art, adding a new language often requires a lot of code modifications and interface reconstruction, which is a complicated process and prone to errors. The present invention greatly simplifies the process of adding new languages through a unified language resource management method. When a new language needs to be expanded, it is only necessary to add the corresponding language field to the database table, update the configuration file or front-end page of the extension management platform, and add the query and return logic for the new language in the unified general language request interface, so as to support the new language without affecting the existing functions. For example, if you want to add support for a new minority language to a social application, developers can quickly integrate the new language by simply following the above steps, which greatly improves the scalability of the system and enables it to quickly respond to the market's changing needs for multi-language support.
[0026] 8. The present invention provides developers with more flexible dynamic language switching control capabilities. It supports users to switch languages freely 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 relying solely on the default language settings of the operating system. For example, in a financial management application with a unique interactive 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
[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0028] Figure 1 It is a flow chart of the internationalized language dynamic switching method of the present invention; Figure 2 It is a flow chart of international language configuration of the present invention; Figure 3It is a flow chart of the steps of batch generation of internationalized language texts by the import mechanism of the present invention; Figure 4 The present invention provides a unified universal language request interface step flow chart. DETAILED DESCRIPTION
[0029] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0030] See also Figure 1 This embodiment provides a database-based cross-platform adaptive internationalized language dynamic switching method, including: Build a multilingual resource database table structure: Create a database table containing primary key fields, identifier fields, and multilingual fields, where each language field corresponds to a language translation text, which is used to uniformly store multilingual resources and establish data associations and unique identifiers in different languages; Providing a unified universal language request interface: The backend service provides a unified interface for responding to language switching operation requests triggered from the interface. When the user performs a language switching operation on the interface, the 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 generates a version identifier at the same time. Establish a multi-terminal adaptation mechanism: provide unified interface adaptation for different front-end applications, and the front-end applications implement incremental updates based on the cache version identifier to adapt to requests from different platforms and devices; for example, on the Web front-end, the JavaScript code logic is used to determine the difference between the cache version identifier and the back-end data version, and decide whether to pull the updated language resource data from the back-end based on this. The cache version identifier is used to decide whether to pull the updated language resource data from the back-end to achieve efficient incremental updates; for the mobile APP front-end, according to the characteristics of different operating systems (such as Android and iOS), different screen sizes and interaction methods are adapted, and the cache version identifier is combined to complete the update and display of language resources.
[0031] Achieve seamless interface updates: During the language switching process, the user's language switching operation is captured through the event mechanism, and the updated language resources are obtained according to the cached version identifier. The interface elements and text display content are updated to avoid reloading the entire application and ensure seamless transition of the interface. For example, in Web applications, JavaScript's event listening mechanism is used. When the user triggers a language switching operation, it responds immediately and obtains the latest language resources from the backend according to the cached version. The text elements on the interface are accurately updated through DOM operations to achieve fast switching of the interface language. The entire process is smooth and without lag.
[0032] Build an extended management platform: Provide a visual interface to support the addition, deletion, modification and query of language resources, support batch import and automatic translation interface integration, and facilitate the configuration and management of language resources. The visual interface has clear operation instructions, and developers can intuitively add, modify and delete language resources on the interface; the batch import function supports the rapid entry of a large number of language resources through Excel tables, and the automatic translation interface can quickly generate translation texts in other languages based on the existing Chinese content.
[0033] As an implementation method, in the step of constructing a multilingual resource database table structure described in this embodiment, SQL statements are specifically executed to create a database table. The table structure includes a primary key for uniquely identifying data, category information, internationalized content identifiers, and fields corresponding to multiple languages, and the last update date is recorded.
[0034] like Figure 2 As an implementation method, the front-end web operation page is used to manage language information. Chinese is a required field, and the corresponding translation of the corresponding language can be selected or left blank. When saving, the background will call the translation system service to translate the corresponding language according to the given Chinese, and then store it in the database. This column operation is completed in the background. The user only needs to simply enter Chinese to generate a unique key and translation information of all national languages. In this embodiment, when adding international language configuration on the web side, the specific process is as follows: After entering the web-side international language configuration addition page, you need to enter the Chinese mandatory items first; Then determine whether to customize the language information. If you choose to customize the translation language information, first determine whether there is repeated language text information. If so, a page prompt "This language text information already exists" will be given; if not, the data will enter the backend logic; if the language information is not customized, the data will directly reach the backend logic; After the data reaches the backend logic, it is determined again whether there is duplicate language text information. If so, a page prompt "this language text information already exists" will be given. If not, the translation engine will be called through the backend code processing to translate the text information into multiple languages. Then generate a unique international key and store the relevant data in the database.
[0035] like Figure 3 As shown, as an implementation method, in the step of building an extended management platform described in this embodiment, a front-end operation page is provided to support manual addition of language information, with Chinese as a required item, and other language information can be selected to be filled in or automatically translated into the database after the background calls the translation system service according to Chinese; it also supports batch import of language information through Excel tables; the process of batch importing language information through Excel tables is as follows: Download the import template from the web page; Edit the language texts to be imported for translation in batches; Upload the Excel spreadsheet file to be imported; After the file data reaches the backend logic, it determines whether the file data is legal; If the data is legal, the file information is read and the translation engine is called through the background code processing to translate the text information into multiple languages; Generate a unique international key and store the relevant data in the database.
[0036] This process uses the web page to download and import templates, upload Excel files after completing language text editing, and call the translation engine to generate texts in multiple languages through a series of operations such as data legitimacy judgment and information reading by the back-end logic, and then generate a unique international key and store it in the database. This process greatly improves the efficiency of international language text generation and management, and realizes efficient processing of language resources in a convenient, time-saving and labor-saving way.
[0037] As an implementation method, in the unified universal 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 through the interface in real time, replaces the interface elements according to preset rules, and updates the text display content based on the language data obtained by the back-end interface, thereby realizing seamless switching of multi-language interfaces.
[0038] As an implementation method, the multi-language resource database table structure storage and management mechanism described in this embodiment is: multiple language resources are entered into the database through a configuration file or a front-end page input. When the application is running, the required language resources are queried and dynamically loaded from the database based on user needs or system settings using a query algorithm, and the resources are updated and managed in combination with the version identifier of the cache layer.
[0039] As an implementation method, in this embodiment, when a new language is expanded, a corresponding language field is added to the database table, the configuration file or front-end page of the extension management platform 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 to achieve support for the new language without affecting the existing functions.
[0040] As an implementation method, in order to support logging and display in a multi-language environment, a structured logging method is usually adopted in Web applications. This method allows log entries to contain placeholders (such as {key}), which 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 allows the original log message to remain unchanged, while the actual message displayed to the user depends on the internationalization (i18n) processing in the front-end application.
[0041] The front-end receives the log data from the back-end and parses the {key}. Next, the method queries the internationalized language pack used by the front-end application to find the language resource corresponding to {key}. The language pack usually contains specific text information corresponding to multiple language environments. Once the appropriate translation 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 interface.
[0042] In this embodiment, the system log and error prompts have been internationalized, specifically: Logging phase: When the backend service records logs, it uses the placeholder {key} plus any amount of static text to form a log entry. Here, {key} is an identifier that points to a translation string in the frontend language package.
[0043] Log transmission phase: When log entries are transmitted from the backend to the frontend, they remain in their original state, that is, in the form of {key} and any additional text.
[0044] Front-end parsing phase: After receiving the log entry, the front-end parses the {key} in the log entry. The internal implementation of this method may include accessing the internationalized language pack stored on the front-end, which is usually dynamically loaded according to the user's language preference.
[0045] Internationalization processing phase: Search for the translated text matching {key} in the language pack and replace it with the corresponding position of the original log message. This process needs to ensure that the replacement logic does not affect any static text parts that originally exist in the log.
[0046] Log display stage: Finally, the processed log entries will be displayed in the user interface, and the log information at this time has been localized according to the user's language preference.
[0047] This design pattern not only improves the maintainability of the logging system, but also enhances the user experience because it allows log information to be presented in the user's native language, making it easier to understand. Internationalization of error prompts: The backend returns {key}, and the front-end error prompts are uniformly sent through the request interceptor. The errorIntl method is used to process the {key} sent by the backend, and the corresponding text information is found and displayed according to the international language package.
[0048] Date, time, and number internationalization transformation: In order to make applications or websites adapt to global users, the internationalization of dates, times, and numbers is also essential. Different countries and regions have significant differences in the way dates, times, and numbers are represented.
[0049] Date Format Month-Day-Year (MM / DD / YYYY): commonly used in the United States, Canada and other countries.
[0050] Day-Month-Year (DD / MM / YYYY): commonly used in countries such as the United Kingdom and Australia.
[0051] Year-Month-Day (YYYY / MM / DD): commonly used in China, Japan and other countries.
[0052] Time format 12-hour format: morning (AM) and afternoon (PM) are indicated.
[0053] 24-hour format: Use 0-23 to represent the hour of the day.
[0054] Number Format Decimal point: Some countries use a dot (.) to represent a decimal point, while others use a comma (,).
[0055] Thousands separator: Some countries use a comma (,) to represent thousands, while others use a dot (.) to represent thousands.
[0056] The Intl.DateTimeFormatAPI API can be used to format date and time, supporting multiple language environments, and can specify the various parts of the date and time (such as year, month, day, hour, minute, second, etc.). The Intl.NumberFormatAPI API can be used to format numbers, supporting number formats in multiple language environments, such as currency, percentage, etc.
[0057] like Figure 4 As shown, in the step of providing a unified universal language request interface in this embodiment, the back-end interface implements a universal interface, and the front-end application stores data in the browser local storage space. The language of the browser or operating system is used by default. The user can set the language to be displayed separately. The process of obtaining language information is as follows: The interface starts or triggers a timed request to obtain language information. The last update time can be included in the front-end request. If the backend determines that there is data, it returns the corresponding data and the frontend refreshes the local cache; If the backend determines that there is no data, it returns that there is no update and the process ends.
[0058] Implement a common interface, which is divided into different typeId parameters and language types according to different projects. The front-end application requests this interface based on the above two fields and returns a Map<key,value> The front-end application will store the data in the local storage space of the browser. The default language is the language of the browser or operating system. Users can set the language to be displayed separately, and the setting is only valid for the current user.
[0059] The present invention provides a universal international dynamic language switching method and system, which can automatically switch the application language according to the user's choice or the language environment of the device in different user environments. The mechanism can dynamically load different language resources at runtime, support seamless switching of multi-language interfaces, and improve user experience and adaptability.
[0060] The present invention adds a database to store language resources through a configuration file or page input, and can dynamically load the required language resources according to user requirements or system settings when the application is running, ensuring that the system has good expansibility and flexibility.
[0061] The present invention solves the problem in the prior art that when switching languages, the application needs to be restarted or the interface becomes chaotic, and provides a seamless switching solution, which can update the interface display in real time after the user selects a language without reloading the entire application.
[0062] The present invention supports multi-language expansion, not only limited to currently supported languages, but can be easily expanded to new language environments by adding new language resources to adapt to user needs in different regions.
[0063] The system can be widely used on different platforms and devices, including desktop applications, mobile applications, web pages and APPs, and is not dependent on operating systems or hardware environments, and has wide applicability.
[0064] In traditional localization systems, language resources are usually stored as independent files (such as .json, .xml or .properties files), and a new language file needs to be loaded every time the language is switched. This method usually loads the language file when the application starts, and the resources need to be reloaded when the language is switched, which may cause the interface to freeze.
[0065] Advantages: Simple to implement, suitable for small applications.
[0066] There is no need for complex dynamic language switching algorithms, and development is relatively straightforward.
[0067] Disadvantages: Resources need to be reloaded each time the language is switched, resulting in a long switching time and affecting the user experience. Real-time interface updates are not supported, and the interface may need to be refreshed or the application restarted, resulting in an unsmooth user experience.
[0068] Comparison with the present invention: The present invention avoids the problems of reloading resources and interface freeze by dynamically loading and updating the interface in real time, making language switching smoother and more fluent.
[0069] Some operating systems (such as Android and iOS) provide system-level internationalization support, and applications can directly call the language switching interface provided by the operating system.
[0070] Advantages: Internationalization support provided by the operating system itself, no additional resource management is required during development.
[0071] System-level language switching is usually automatic and requires no user intervention.
[0072] Disadvantages: System-level language switching is usually not flexible enough to customize the user experience according to the needs within the application. Dynamic language switching within the application is not supported, and the language cannot be dynamically adjusted according to different users or scenarios.
[0073] Comparison with the present invention: The present invention provides a more flexible dynamic language switching mechanism, supporting users to switch languages freely within the application, rather than relying solely on the default language setting 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.
[0074] Some systems embed multiple language resources in the application, and the user directly replaces the interface content after selecting the language. This solution usually relies on the language pack or resource file generated during compilation.
[0075] Advantages: Simple implementation, no need for complex runtime resource loading. Load all language resources at once, reducing runtime network requests.
[0076] Disadvantages: The application package size is large, which may affect the download and installation time. It does not support dynamic expansion or update of language resources, which increases the difficulty of updating.
[0077] Comparison with the present invention: The present invention dynamically loads language resources, and does not need to package all language resources into the application, thereby reducing the application package size and download time. At the same time, the present invention supports dynamic update of language resources, and users can experience new language support without updating the entire application.
[0078] Although the embodiments of the present invention have been shown and described above, it will be appreciated that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, substitute and vary the above embodiments within the scope of the present invention.
Claims
1. A cross-platform adaptive internationalized language dynamic switching method based on a database, characterized by: include: Build a multilingual resource database table structure: Create a database table containing primary key fields, identifier fields, and multilingual fields, where each language field corresponds to a language translation text, which is used to uniformly store multilingual resources and establish data associations and unique identifiers in different languages; Providing a unified universal language request interface: The backend service provides a unified interface for responding to language switching operation requests triggered from the interface. When the user performs a language switching operation on the interface, the 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 generates a version identifier at the same time. Establish a multi-terminal adaptation mechanism: provide unified interface adaptation for different front-end applications. Front-end applications implement incremental updates based on cache version identifiers to adapt to requests from different platforms and devices. Achieve seamless interface updates: During the language switching process, the user's language switching operation is captured through the event mechanism, and the updated language resources are obtained according to the cache version identifier, and the interface elements and text display content are updated to avoid reloading the entire application and ensure seamless interface transition; Build an extended management platform: Provide a visual interface to support the addition, deletion, modification and query of language resources, support batch import and automatic translation interface integration, and facilitate the configuration and management of language resources.
2. According to claim 1, it is characterized in that: in the step of constructing a multilingual resource database table structure, a SQL statement is specifically executed to create a database table, and the table structure includes a primary key for uniquely identifying data, category information, internationalized content identifiers, and fields corresponding to multiple languages, and the last update date is recorded.
3. The method according to claim 1, characterized in that: In the step of providing a unified universal language request interface, the backend interface implements a universal interface, and the frontend application stores data in the browser local storage space. The language of the browser or operating system is used by default. Users can set the language to be displayed separately. The process of obtaining language information is as follows: The interface starts or triggers a timed request to obtain language information. The last update time can be included in the front-end request. If the backend determines that there is data, it returns the corresponding data and the frontend 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 the extension management platform, a front-end operation page is provided to support manual addition of language information, with Chinese as a required item. Other language information can be selected or automatically translated into Chinese by calling the translation system service in the background and stored in the database; it also supports batch import of language information through Excel spreadsheets; the steps of batch generating internationalized language texts through the Excel spreadsheet batch import mechanism are as follows: Download the import template from the web page; Edit the language texts to be imported for translation in batches; Upload the Excel spreadsheet file to be imported; After the file data reaches the backend logic, it determines whether the file data is legal; If the data is legal, the file information is read and the translation engine is called through the background code processing to translate the text information into multiple languages; Generate a unique international key and store the relevant data in the database.
5. The method according to claim 4, characterized in that: When adding international language configuration on the web side, the specific process is as follows: After entering the web-side international language configuration addition page, you need to enter the Chinese mandatory items first; Then determine whether to customize the language information. If you choose to customize the translation language information, first determine whether there is repeated language text information. If it is repeated, a page prompt "the language text information already exists" will be given; if it is not repeated, the data will enter the back-end logic; if the language information is not customized, the data will directly reach the back-end logic; After the data reaches the backend logic, it is determined again whether there is duplicate language text information. If there is duplicate, a page prompt "this language text information already exists" is also given; if there is no duplicate, the translation engine is called through the backend code processing to translate the text information in multiple languages; Then generate a unique international key and store the relevant data in the database.
6. The method according to claim 1, characterized in that: In the unified universal language request interface provided, when the user selects a language or the device language environment changes, the system loads the corresponding language resources through the interface in real time, replaces the interface elements according to preset rules, and updates the text display content based on the language data obtained by the back-end interface, thereby realizing seamless switching of multi-language interfaces.
7. The method according to claim 1, characterized in that: 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 inputs; when the application is running, the required language resources are queried and dynamically loaded from the database using a query algorithm according to user needs or system settings, and the resources are updated and managed in combination with the version identifier of the cache layer.
8. The method according to claim 7, characterized in that: When adding a new language, add the corresponding language field in the database table, update the configuration file or front-end page of the extension 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.
9. The method according to any one of claims 1 to 8, characterized in that: The system logs and error prompts have been internationalized, specifically: During the logging phase, when the backend service records logs, it uses a placeholder key plus any amount of static text to form a log entry. The key is an identifier pointing to the translation string in the frontend language package. During the log transmission phase, log entries are transmitted from the backend to the frontend in their original state, including the key and additional text. In the front-end parsing phase, the front-end parses the key in the log entry and accesses the internationalized language pack that is dynamically loaded based on the user's language preference; During the internationalization processing phase, the translated text matching the key is searched in the language pack and replaced in the corresponding position of the original log message without affecting the static text part. In the log display phase, the processed log entries are localized according to the user's language preference and displayed in the user interface; Internationalization of error prompts: The backend returns the key, and the frontend uses the request interceptor to find the corresponding text based on the international language package for error prompts.
Citation Information
Patent Citations
Configuration method and device for multi-language game resources
CN111273978A
Front-end multi-language loading adaptation method and device, computer equipment and storage medium
CN111381913A
Language text management method and device, storage medium and electronic equipment
CN113918254A
Multi-language switching method, component, medium and equipment under front-end and back-end separation architecture
CN114168246A
Multi-language content realization method and realization device
CN116401358A
Cited By
Multi-language support framework oriented to operating system and data management method of multi-language support framework
CN120235166A
A system based on a multi-language support framework oriented to an operating system and a data management method thereof
CN120235166B
Multilingual resource decoupling method based on business meta-model
CN120469761A
Interface display language switching method and device, storage medium and electronic equipment
CN121143932A