Language resource configuration and loading method and device, equipment and storage medium

By dynamically loading language resources and automatically converting the key name format of multiple libraries, the problem of low loading efficiency caused by the fixed language resources at compile time is solved, and efficient loading and hot updating of language resources are achieved.

CN121166229BActive Publication Date: 2026-05-12SHENZHEN DINSTAR TECH
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN DINSTAR TECH
Filing Date
2025-11-06
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

In existing technologies, language resources are fixed at compile time, which means that when adding or modifying language support in a production environment, the entire application needs to be recompiled and re-deployed, resulting in low efficiency in loading language resources.

Method used

Synchronous updates are achieved by dynamically loading language resources on demand and automatically converting the key name format of multiple libraries. This includes generating a key name format mapping relationship between the interface component library and the time processing library, receiving language switching instructions, extracting the corresponding language code, and determining and loading the target language resource file.

Benefits of technology

It improves the loading efficiency of language resources, supports hot updates without rebuilding the application, and reduces the waiting time and response speed for language switching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121166229B_ABST
    Figure CN121166229B_ABST
Patent Text Reader

Abstract

The application discloses a language resource configuration and loading method and device, equipment and a storage medium, relates to the technical field of language loading, and the language resource configuration and loading method comprises the following steps: acquiring a language configuration file, generating a key name format mapping relationship of an interface component library and a time processing library according to the language configuration file; receiving a language switching instruction, and extracting a corresponding language code according to the language switching instruction; determining a target language resource file according to the language code and the key name format mapping relationship; and loading the target language resource file. The application can improve the loading efficiency of language resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of language loading technology, and in particular to a method, apparatus, device, and storage medium for configuring and loading language resources. Background Technology

[0002] In current web application development based on front-end frameworks like Vue, multilingual internationalization is crucial for supporting global business operations. Currently, this typically relies on statically integrating language resource files during application build and configuring them separately through basic internationalization libraries, user interface component libraries, and event processing libraries. However, this approach has significant drawbacks: language resources are fixed at compile time, meaning that adding or modifying language support in a production environment requires recompiling and re-deploying the entire application, resulting in inefficient language resource loading. Therefore, improving the loading efficiency of language resources remains a problem that needs to be addressed.

[0003] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention

[0004] The main objective of this application is to provide a method, apparatus, device, and storage medium for configuring and loading language resources, aiming to solve the technical problem of how to improve the loading efficiency of language resources.

[0005] To achieve the above objectives, this application proposes a method for configuring and loading language resources, the method comprising:

[0006] Obtain the language configuration file, and generate a key-name mapping relationship between the interface component library and the time processing library based on the language configuration file;

[0007] Receive a language switching instruction and extract the corresponding language code based on the language switching instruction;

[0008] The target language resource file is determined based on the mapping relationship between the language code and the key name format.

[0009] Load the target language resource file.

[0010] In one embodiment, the step of generating the key name format mapping relationship between the interface component library and the time processing library based on the language configuration file includes:

[0011] Parse the language configuration file to obtain the language list;

[0012] Iterate through the language codes of the language list;

[0013] According to preset conversion rules, the language code is converted into the interface component library key name format and the time processing library key name format respectively;

[0014] The key name format mapping relationship is obtained based on the language code, the interface component library key name format, and the time processing library key name format.

[0015] In one embodiment, the step of converting the language code into the interface component library key name format and the time processing library key name format according to the preset conversion rules includes:

[0016] The key name formats of the interface component library and the time processing library are determined according to the preset conversion rules.

[0017] The language code is converted into the interface component library key name format and the time processing library key name format, respectively.

[0018] In one embodiment, the step of determining the target language resource file based on the mapping relationship between the language code and the key name format includes:

[0019] The target language code is obtained based on the mapping relationship between the language code and the key name format.

[0020] Based on the target language code and the preset file path rules, construct the complete path of the target language resource file;

[0021] Download the target language resource file corresponding to the language code according to the complete path.

[0022] In one embodiment, the step of loading the target language resource file includes:

[0023] Based on the key name format mapping relationship and the target language resource file, obtain the first configuration resource corresponding to the interface component library and the second configuration resource corresponding to the time processing library;

[0024] Update the display text of the interface component library using the first configuration resource;

[0025] Update the date and time format of the time processing library using the second configuration resource;

[0026] Update the translated text in the target language resource file to the basic internationalization library.

[0027] In one embodiment, after the step of loading the target language resource file, the method further includes:

[0028] Monitor whether the target language resource file is loaded successfully;

[0029] If loading fails, obtain the default language code and load the default language resource file corresponding to the default language code.

[0030] In one embodiment, prior to the step of receiving the language switching instruction, the method further includes:

[0031] The preloaded language code is selected based on the system language environment or user history.

[0032] The corresponding language resource files are preloaded according to the preloaded language code;

[0033] The language resource files are cached in local storage.

[0034] Furthermore, to achieve the above objectives, this application also proposes a language resource configuration and loading device, which includes:

[0035] The processing module is used to obtain the language configuration file and generate a key-name format mapping relationship between the interface component library and the time processing library based on the language configuration file.

[0036] A receiving module is used to receive language switching instructions and extract the corresponding language code according to the language switching instructions;

[0037] The determination module is used to determine the target language resource file based on the mapping relationship between the language code and the key name format;

[0038] The loading module is used to load the target language resource file.

[0039] In addition, to achieve the above objectives, this application also proposes a language resource configuration and loading device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the language resource configuration and loading method described above.

[0040] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the language resource configuration and loading method described above.

[0041] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the language resource configuration and loading method described above.

[0042] This application provides a method for configuring and loading language resources. The method involves obtaining a language configuration file, generating a key-name format mapping relationship between an interface component library and a time processing library based on the language configuration file, receiving a language switching instruction, extracting the corresponding language code based on the language switching instruction, determining the target language resource file based on the language code and the key-name format mapping relationship, and loading the target language resource file. This application improves the loading efficiency of language resources by dynamically loading language resources on demand and automatically converting the key-name formats of multiple libraries to achieve synchronous updates. Attached Figure Description

[0043] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0044] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 This is a flowchart illustrating an embodiment of the language resource configuration and loading method of this application.

[0046] Figure 2 This is a schematic diagram of language resource loading provided in Embodiment 1 of the language resource configuration and loading method of this application;

[0047] Figure 3 This is a flowchart illustrating Embodiment 2 of the language resource configuration and loading method of this application;

[0048] Figure 4 A simplified flowchart illustrating the language resource configuration and loading method provided in Embodiment 1 of this application;

[0049] Figure 5 This is a schematic diagram of the module structure of the language resource configuration and loading device according to an embodiment of this application;

[0050] Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the language resource configuration and loading method in the embodiments of this application.

[0051] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0052] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0053] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0054] This application obtains a language configuration file, generates a key-name format mapping relationship between an interface component library and a time processing library based on the language configuration file; receives a language switching instruction, and extracts the corresponding language code based on the language switching instruction; determines the target language resource file based on the language code and the key-name format mapping relationship; and loads the target language resource file.

[0055] In current web application development based on front-end frameworks like Vue, multilingual internationalization is crucial for supporting global business operations. Currently, this typically relies on statically integrating language resource files during application build and configuring them separately through basic internationalization libraries, user interface component libraries, and event processing libraries. However, this approach has significant drawbacks: language resources are fixed at compile time, meaning that adding or modifying language support in a production environment requires recompiling and re-deploying the entire application, resulting in inefficient language resource loading. Therefore, improving the loading efficiency of language resources remains a problem that needs to be addressed.

[0056] This application improves the loading efficiency of language resources by dynamically loading language resources on demand and automatically converting the key name format of multiple libraries to achieve synchronous updates.

[0057] Based on this, embodiments of this application provide a method for configuring and loading language resources, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the language resource configuration and loading method of this application.

[0058] In this embodiment, the language resource configuration and loading method includes steps S10 to S40:

[0059] Step S10: Obtain the language configuration file and generate a key name format mapping relationship between the interface component library and the time processing library based on the language configuration file;

[0060] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or language resource configuration and loading device capable of performing the above functions. The following description uses a language resource configuration and loading device as an example to illustrate this embodiment and the subsequent embodiments.

[0061] It should be noted that the core of this application lies in the centralized management of all internationalization-related functions of the application, the decoupling of each functional module, the on-demand loading of language resources, and the support for hot updates (modification of configuration does not require rebuilding). It is an implementation technology that transforms static language resource data structures into web client interfaces. It adopts a modular design, consisting of three core layers: configuration layer, core layer, and application layer. Supported language environments are defined through JSON configuration files. It includes the i18n base library, internationalization adapters for Ant Design Vue and Day.js, and provides a unified composable API for Vue components.

[0062] It should be noted that the language configuration file is a configuration file for the corresponding language uploaded by the user according to their own needs.

[0063] In one feasible approach, the step of generating the key name format mapping relationship between the interface component library and the time processing library based on the language configuration file includes: parsing the language configuration file to obtain a language list; traversing the language codes of the language list; converting the language codes into the interface component library key name format and the time processing library key name format respectively according to preset conversion rules; and obtaining the key name format mapping relationship based on the language codes, the interface component library key name format, and the time processing library key name format. The step of converting the language codes into the interface component library key name format and the time processing library key name format respectively according to preset conversion rules includes: determining the interface component library key name format and the time processing library key name format according to preset conversion rules; and converting the language codes into the interface component library key name format and the time processing library key name format respectively.

[0064] It's important to note that the process begins by parsing the language configuration file. A JSON parser reads the file content to obtain a list of supported languages, such as ["zh-CN", "en-US"]. Next, each language code in the list is iterated over, and its format is converted sequentially. Then, each language code is converted into the UI component library key name format and the time processing library key name format according to preset conversion rules. For example, "en-US" is converted to the "en_US" format required by the UI component library. Finally, based on the original language code, the converted UI component library key name formats, and the time processing library key name formats, a complete key name format mapping relationship is constructed and stored as an in-memory mapping table for later use.

[0065] It should be noted that this embodiment implements a Vue composition function for dynamically loading internationalized language resources of the Ant Design Vue component library. The core functionality includes dynamically loading Ant Design Vue language resources, standardizing language key formats, managing language resource caching, and runtime language switching. The language resource loading mechanism uses dynamic imports to achieve on-demand loading, supports batch loading of multiple language resources, silently handles errors without affecting application operation, and returns an object containing all loaded language resources. Language key formatting converts standard language codes (e.g., en-US) to Ant Design format (e.g., en_US), handles case standardization, and supports batch conversion. A composition function manages the reactive language resource collection, providing two main methods: initializing and loading the required language resources, and retrieving the specified language resource. This embodiment also provides a Vue composition function for dynamically loading internationalized language resources of the Day.js time library. It supports on-demand loading of language resources and switching between different language environments at runtime, forming a complementary time processing solution with the Ant Design Vue internationalization solution. During Day.js language resource metadata initialization, it filters the supported language resources based on the project's list of supported locales, converts the language key format (e.g., en-US to en), and returns an object containing key-value pairs of valid language resources. It converts standard language codes (e.g., en-US) to Day.js format (e.g., en), removes region suffixes using regular expressions, and converts them all to lowercase. It implements on-demand loading through dynamic imports, supports batch loading of multiple language resources, silently handles errors, and returns an object containing the loaded language resources. It also uses composite functions to manage reactive language resource collections, providing two core methods: initializing and loading the required language resources, and switching Day.js's global language resources.

[0066] It should be noted that the overall language resource configuration process first requires defining a standard data structure. This data structure must include a mapping relationship with standard language identifiers (compliant with BCP 47 specifications), explicitly specifying languages ​​and regions, and using a JSON array structure to clearly list all supported languages ​​in the current version. When new languages ​​need to be supported, simply add the new language code to the array, establishing mapping relationships, inline relationships, and style associations on the client side. Through the client configuration file path, obtain all supported language items from the UI library and its accompanying time library, add an error handling mechanism to handle loading failures, generate a standard JSON data structure for local language resources, and establish mapping relationships. Use a JSON file to centrally manage all supported languages, implement a dynamic filtering mechanism, compare the types and quantities of supported language resources in the two libraries, take the intersection, and apply key-value pairs according to rules. The system performs language conversion, sets up the mapping relationship between the language library and the client, verifies and keeps it synchronized. The language mapping relationship is updated with each compilation to facilitate the addition of new languages. Based on the defined public language resource JSON data structure file, the system preloads the client user settings to determine the languages ​​to be preloaded before application mounting, parses the language items, loads the corresponding language library configuration items, and sets default values. An error handling mechanism is added; if settings fail, the system reverts to the default values, thereby improving the response speed and user experience when switching languages. Plugins are installed, imported and registered in the application's main entry file, and the corresponding language resources are available in the public directory and can be loaded according to the JSON configuration file, making them available for business systems to use.

[0067] Step S20: Receive a language switching instruction and extract the corresponding language code according to the language switching instruction;

[0068] It should be noted that the system receives language switching commands triggered by the user through the interface drop-down menu via an event acquisition mechanism, and extracts the corresponding language code, such as "zh-CN" or "en-US," from the data packet of the command. Then, based on the extracted language code and a pre-established key-name format mapping relationship, the system determines the identifier and storage location of the target language resource file. Finally, the system dynamically loads the determined target language resource file via an HTTP request. This file contains all the translated text and format definitions for the corresponding language, completing the language environment switch.

[0069] In one feasible approach, prior to the step of receiving the language switching instruction, the method further includes: determining a preloaded language code based on the system language environment or user history; preloading the corresponding language resource file based on the preloaded language code; and caching the language resource file to local storage.

[0070] It should be noted that before receiving the language switching instruction, the system also obtains the system's language environment and, combined with the user's historical selection records in local storage, comprehensively analyzes and determines the pre-loaded language code. Based on the determined pre-loaded language code, the corresponding language resource file is asynchronously loaded in advance during the application initialization phase, reducing the user's waiting time for subsequent language switching. The successfully loaded language resource file is serialized and cached in local storage, using localStorage or sessionStorage mechanisms to establish a mapping relationship between the language code and the file content.

[0071] Step S30: Determine the target language resource file based on the mapping relationship between the language code and the key name format;

[0072] It should be noted that the system determines the identifier and storage location of the target language resource file based on the extracted language code and the pre-established key name format mapping relationship. For example, it constructs a complete file access path by combining the base path and the language code.

[0073] In one feasible approach, the step of determining the target language resource file based on the mapping relationship between the language code and the key name format includes: obtaining the target language code based on the mapping relationship between the language code and the key name format; constructing the complete path of the target language resource file based on the target language code and a preset file path rule; and downloading the target language resource file corresponding to the language code based on the complete path.

[0074] It should be noted that, firstly, based on the mapping relationship between language codes and key name formats, the standardized identifier corresponding to the target language code is retrieved. Next, based on the target language code and preset file path rules, the complete path to the target language resource file is constructed. For example, the base path " / locales / " is combined with the language code and extension to form " / locales / zh-CN.json". Then, the target language resource file corresponding to the language code is downloaded according to the constructed complete path.

[0075] Step S40: Load the target language resource file.

[0076] It should be noted that this can be used as a reference. Figure 2 , Figure 2 This is a diagram illustrating the loading of language resources. After the language resource file is loaded, the server updates the JSON. The client then initiates an HTTP request and applies the new language in real time by refreshing the interface.

[0077] In one feasible approach, after the step of loading the target language resource file, the method further includes: monitoring whether the target language resource file has been successfully loaded; if the loading is unsuccessful, obtaining the default language code and loading the default language resource file corresponding to the default language code.

[0078] It should be noted that the system continuously monitors the loading status of the target language resource files to determine whether the language resources have been loaded successfully. If loading fails, the system retrieves the preset default language code, such as "en-US," from the system configuration. Based on the retrieved default language code, the loading process is triggered to load the default language resource file corresponding to the default language code, ensuring that the system can still display correctly under abnormal circumstances.

[0079] It's important to note that from a system perspective, the internationalization plugin is loaded and basic configurations are initialized upon application startup. Then, `localConfig.json` is automatically parsed to obtain the list of supported languages ​​and default language settings. The corresponding language resource file (e.g., `zh-CN.json`) is loaded based on the configuration. Components directly use the translation functions provided by the plugin to display the current language content in real time. Language switching events are triggered through UI interactions (such as dropdown menus). The plugin automatically loads new language resources and updates all dependent components without requiring a page refresh. In the development environment, only `localConfig.json` and the language resources in the `locales / ` directory need to be maintained. When adding a new language, simply add the corresponding JSON file and update the configuration for it to take effect. In the production environment, when internationalization configuration is required, only `localConfig.json` and the language resources in the `locales / ` directory need to be modified and maintained; there's no need to return to the development phase, modify the code, compile, and deploy again. Once the application system obtains the configuration file, refreshing the system will immediately take effect.

[0080] This embodiment obtains a language configuration file, generates a key name format mapping relationship between the interface component library and the time processing library based on the language configuration file, receives a language switching instruction, and extracts the corresponding language code based on the language switching instruction, determines the target language resource file based on the language code and the key name format mapping relationship, and loads the target language resource file. This embodiment improves the loading efficiency of language resources by dynamically loading language resources on demand and automatically converting the key name format of multiple libraries to achieve synchronous updates.

[0081] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 Step S40 also includes steps S401 to S404:

[0082] Step S401: Obtain the first configuration resource corresponding to the interface component library and the second configuration resource corresponding to the time processing library according to the key name format mapping relationship and the target language resource file;

[0083] It should be noted that the system will filter out the first configuration resources specific to the UI component library from the target language resource file based on the UI component library key name format in the mapping relationship. These resources include component-related translations such as button text, tooltips, and label content. Simultaneously, based on the time processing library key name format, it will extract the second configuration resources specific to the time processing library, including time-related localization content such as date format, month name, and day of the week representation.

[0084] Step S402: Update the display text of the interface component library using the first configuration resource;

[0085] It should be noted that the system will call the localization configuration interface provided by the UI component library (such as Ant Design Vue) to inject the first configuration resource into the component library instance. The system will update the display text of all UI elements using this component library in real time, including but not limited to pagination text in tables, validation prompts in forms, and button labels in pop-ups, ensuring that the text inside the components remains consistent with the current locale.

[0086] Step S403: Update the date and time format of the time processing library using the second configuration resource;

[0087] It should be noted that the system applies a second configuration resource through the locale setting method of a time processing library (such as Day.js). This ensures that all date and time displays formatted by this time processing library follow the conventions of the current language, including year-month-day order, localized weekday names, and relative time representations, guaranteeing that the time display conforms to local language habits.

[0088] Step S404: Update the translated text in the target language resource file to the basic internationalization library.

[0089] It should be noted that, finally, the system updates the remaining generic translated text in the target language resource files to the core translation store via the API of the basic internationalization library (such as Vue I18n). This step completes the language switching of the main content of the application, including all translated content that does not depend on any specific third-party library, such as page titles, body text, and custom component text.

[0090] This embodiment obtains the first configuration resource corresponding to the interface component library and the second configuration resource corresponding to the time processing library based on the key name format mapping relationship and the target language resource file; updates the display text of the interface component library using the first configuration resource; updates the date and time format of the time processing library using the second configuration resource; and updates the translated text in the target language resource file to the basic internationalization library. This embodiment improves the efficiency of language resource loading by updating the component library and processing library through the key name format mapping relationship and the target language resource file.

[0091] For example, to help understand the implementation process of the language resource configuration and loading method obtained by combining this embodiment with the above embodiment one, please refer to... Figure 4 , Figure 4 A simplified flowchart of a language resource configuration and loading method is provided. Specifically, after initializing the plugin, the configuration is loaded through a configuration file and the initial language is set through a language pack. Then, at runtime, the language is switched during component rendering to achieve language updates.

[0092] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the language resource configuration and loading method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0093] This application also provides a language resource configuration and loading device; please refer to [reference needed]. Figure 5 The language resource configuration and loading device includes:

[0094] Processing module 10 is used to obtain the language configuration file and generate a key name format mapping relationship between the interface component library and the time processing library based on the language configuration file;

[0095] The receiving module 20 is used to receive a language switching instruction and extract the corresponding language code according to the language switching instruction;

[0096] The determining module 30 is used to determine the target language resource file based on the mapping relationship between the language code and the key name format;

[0097] Loading module 40 is used to load the target language resource file.

[0098] This embodiment obtains a language configuration file, generates a key name format mapping relationship between the interface component library and the time processing library based on the language configuration file, receives a language switching instruction, and extracts the corresponding language code based on the language switching instruction, determines the target language resource file based on the language code and the key name format mapping relationship, and loads the target language resource file. This embodiment improves the loading efficiency of language resources by dynamically loading language resources on demand and automatically converting the key name format of multiple libraries to achieve synchronous updates.

[0099] In one embodiment, the processing module 10 is further configured to parse the language configuration file to obtain a language list; traverse the language codes of the language list; convert the language codes into interface component library key name format and time processing library key name format respectively according to preset conversion rules; and obtain a key name format mapping relationship based on the language codes, the interface component library key name format and the time processing library key name format.

[0100] In one embodiment, the processing module 10 is further configured to determine the interface component library key name format and the time processing library key name format according to a preset conversion rule; and to convert the language code into the interface component library key name format and the time processing library key name format respectively.

[0101] In one embodiment, the determining module 30 is further configured to obtain the target language code according to the mapping relationship between the language code and the key name format; construct the complete path of the target language resource file according to the target language code and the preset file path rules; and download the target language resource file corresponding to the language code according to the complete path.

[0102] In one embodiment, the loading module 40 is further configured to obtain a first configuration resource corresponding to the interface component library and a second configuration resource corresponding to the time processing library according to the key name format mapping relationship and the target language resource file; update the display text of the interface component library using the first configuration resource; update the date and time format of the time processing library using the second configuration resource; and update the translated text in the target language resource file to the basic internationalization library.

[0103] In one embodiment, the loading module 40 is further configured to monitor whether the target language resource file has been successfully loaded; if the loading fails, the default language code is obtained and the default language resource file corresponding to the default language code is loaded.

[0104] In one embodiment, the loading module 20 is further configured to determine the preloaded language code based on the system language environment or user history selection; preload the corresponding language resource file according to the preloaded language code; and cache the language resource file in local storage.

[0105] The language resource configuration and loading apparatus provided in this application, employing the language resource configuration and loading method described in the above embodiments, can solve the technical problem of how to improve the loading efficiency of language resources. Compared with the prior art, the beneficial effects of the language resource configuration and loading apparatus provided in this application are the same as those of the language resource configuration and loading method described in the above embodiments, and other technical features in the language resource configuration and loading apparatus are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0106] This application provides a language resource configuration and loading device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the language resource configuration and loading method in the first embodiment described above.

[0107] The following is for reference. Figure 6 The diagram illustrates a structural schematic of a language resource configuration and loading device suitable for implementing embodiments of this application. The language resource configuration and loading device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The language resource configuration and loading device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0108] like Figure 6As shown, the language resource configuration and loading device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in ROM (Read Only Memory) 1002 or a program loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the language resource configuration and loading device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touch screens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the language resource configuration and loading device to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows language resource configuration and loading devices with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.

[0109] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0110] The language resource configuration and loading device provided in this application, employing the language resource configuration and loading method described in the above embodiments, can solve the technical problem of how to improve the loading efficiency of language resources. Compared with the prior art, the beneficial effects of the language resource configuration and loading device provided in this application are the same as those of the language resource configuration and loading method described in the above embodiments, and other technical features in this language resource configuration and loading device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.

[0111] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0112] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0113] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the language resource configuration and loading methods described in the above embodiments.

[0114] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0115] The aforementioned computer-readable storage medium may be included in a language resource configuration and loading device; or it may exist independently and not be assembled into a language resource configuration and loading device.

[0116] The aforementioned computer-readable storage medium carries one or more programs. When the one or more programs are executed by the language resource configuration and loading device, the language resource configuration and loading device: obtains a language configuration file; generates a key-name format mapping relationship between an interface component library and a time processing library based on the language configuration file; receives a language switching instruction and extracts the corresponding language code based on the language switching instruction; determines a target language resource file based on the language code and the key-name format mapping relationship; and loads the target language resource file.

[0117] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0118] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0119] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0120] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., computer programs) for executing the above-described language resource configuration and loading method, thereby solving the technical problem of how to improve the loading efficiency of language resources. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the language resource configuration and loading method provided in the above embodiments, and will not be repeated here.

[0121] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the language resource configuration and loading method described above.

[0122] The computer program product provided in this application solves the technical problem of how to improve the loading efficiency of language resources. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the language resource configuration and loading methods provided in the above embodiments, and will not be repeated here.

[0123] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A method for configuring and loading language resources, characterized in that, The method includes: Obtain the language configuration file, and generate a key-name mapping relationship between the interface component library and the time processing library based on the language configuration file; Receive a language switching instruction and extract the corresponding language code based on the language switching instruction; The target language resource file is determined based on the mapping relationship between the language code and the key name format. Load the target language resource file; The step of generating the key name format mapping relationship between the interface component library and the time processing library based on the language configuration file includes: Parse the language configuration file to obtain the language list; Iterate through the language codes of the language list; According to preset conversion rules, the language code is converted into the interface component library key name format and the time processing library key name format respectively; The key name format mapping relationship is obtained based on the language code, the interface component library key name format, and the time processing library key name format. The step of loading the target language resource file includes: Based on the key name format mapping relationship and the target language resource file, obtain the first configuration resource corresponding to the interface component library and the second configuration resource corresponding to the time processing library; Update the display text of the interface component library using the first configuration resource; Update the date and time format of the time processing library using the second configuration resource; Update the translated text in the target language resource file to the basic internationalization library.

2. The method as described in claim 1, characterized in that, The step of converting the language code into the interface component library key name format and the time processing library key name format according to the preset conversion rules includes: The key name formats of the interface component library and the time processing library are determined according to the preset conversion rules. The language code is converted into the interface component library key name format and the time processing library key name format, respectively.

3. The method as described in claim 1, characterized in that, The step of determining the target language resource file based on the mapping relationship between the language code and the key name format includes: The target language code is obtained based on the mapping relationship between the language code and the key name format. Based on the target language code and the preset file path rules, construct the complete path of the target language resource file; Download the target language resource file corresponding to the language code according to the complete path.

4. The method as described in claim 1, characterized in that, After the step of loading the target language resource file, the method further includes: Monitor whether the target language resource file is loaded successfully; If loading fails, obtain the default language code and load the default language resource file corresponding to the default language code.

5. The method as described in claim 1, characterized in that, Before the step of receiving the language switching instruction, the method further includes: The preloaded language code is selected based on the system language environment or user history. The corresponding language resource files are preloaded according to the preloaded language code; The language resource files are cached in local storage.

6. A language resource configuration and loading device, characterized in that, The device includes: The processing module is used to obtain the language configuration file and generate a key-name format mapping relationship between the interface component library and the time processing library based on the language configuration file. A receiving module is used to receive language switching instructions and extract the corresponding language code according to the language switching instructions; The determination module is used to determine the target language resource file based on the mapping relationship between the language code and the key name format; The loading module is used to load the target language resource file; The step of generating the key name format mapping relationship between the interface component library and the time processing library based on the language configuration file includes: Parse the language configuration file to obtain the language list; Iterate through the language codes of the language list; According to preset conversion rules, the language code is converted into the interface component library key name format and the time processing library key name format respectively; The key name format mapping relationship is obtained based on the language code, the interface component library key name format, and the time processing library key name format. The loading of the target language resource file includes: Based on the key name format mapping relationship and the target language resource file, obtain the first configuration resource corresponding to the interface component library and the second configuration resource corresponding to the time processing library; Update the display text of the interface component library using the first configuration resource; Update the date and time format of the time processing library using the second configuration resource; Update the translated text in the target language resource file to the basic internationalization library.

7. A language resource configuration and loading device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the language resource configuration and loading method as described in any one of claims 1 to 5.

8. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the language resource configuration and loading method as described in any one of claims 1 to 5.