Target language file reading method and device, electronic equipment and storage medium
By receiving HTTP requests and looking for multilingual files in the cache, if the update cycle is not found or reached, the file will be reloaded from the multilingual platform, solving the complex problem of multilingual file updates in the Spring Boot project, realizing hot updates and real-time effectiveness of multilingual files.
Patent Information
- Application Number
- CN202411929142.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-18
AI Technical Summary
When updating multilingual files in Spring Boot projects, the existing technology needs to manually modify and redeploy the files, resulting in high operation and maintenance complexity and poor flexibility, and the real-time update of multilingual files cannot be achieved.
Provides a target language file reading method, obtains the language type expected by the user by receiving HTTP requests, and finds the multilingual files in the cache. If the predefined update cycle is not found or reached, the target language file will be reloaded from the multilingual platform to the cache.
It realizes hot updates of multilingual files, reduces operation and maintenance complexity and cost, improves flexibility, and allows real-time effectiveness of language content.
Smart Images

Figure CN119847663A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present disclosure relate to the field of configuration update technology, and in particular, to a method, device, electronic device, and storage medium for reading a target language file. Background Art
[0002] The Spring Boot framework provides many out-of-the-box features, such as multi-language support provided by internationalization components. The Spring Boot project is a specific application built on the Spring Boot framework. The Spring Boot project can use the internationalization components provided by the Spring Boot framework to achieve multi-language support, so that content in different languages can be displayed on the project page according to user needs.
[0003] However, if you want to update the multi-language files in the Spring Boot project, you need to manually modify the multi-language files, recompile and package the Spring Boot project, and finally redeploy it to the production environment. This not only increases the complexity and cost of operation and maintenance, but also has poor flexibility and cannot achieve real-time update of multi-language files. Changes in language content cannot take effect immediately and need to wait for the next deployment. Summary of the invention
[0004] In order to solve the technical problem of high complexity and poor flexibility caused by manually modifying the multi-language files in the Spring Boot project and redeploying them every time the user needs to read updated multi-language files, the present disclosure provides a target language file reading method, the method comprising:
[0005] Receiving an HTTP request to obtain a target language type of a page content desired by a user, wherein a request header of the HTTP request includes the language type of the page content desired by the user;
[0006] Searching for a target language file corresponding to the target language type in the multi-language files stored in the cache, wherein the multi-language files include language files corresponding to a plurality of language types respectively;
[0007] If the target language file is not found in the multi-language files stored in the cache, or the difference between the current time and the predefined initial time reaches a predefined update period, the target language file is reloaded from the multi-language platform to the multi-language files stored in the cache;
[0008] The reloaded target language file is read from the cache to obtain data for the target language of the page content that the user expects.
[0009] Optionally, the method further includes:
[0010] If the target language file is found in the multi-language files stored in the cache, and the difference between the current moment and the predefined initial moment does not reach the predefined update period, the found target language file is read from the multi-language files stored in the cache to obtain data of the target language type of the page content desired by the user.
[0011] Optionally, the predefined initial time is set in a cache, and after reloading the target language file from the multilingual platform to the multilingual file stored in the cache, the method further includes:
[0012] Records the moment when the target language file is reloaded from the multi-language platform into the multi-language file stored in the cache;
[0013] The predefined initial time set in the cache is updated to the recorded time of reloading the target language file from the multi-language platform to the multi-language file stored in the cache.
[0014] Optionally, before searching the multi-language files stored in the cache for the target language file corresponding to the target language type, the method further includes:
[0015] Load all multi-language files from the multi-language platform to the local computer, and write the local multi-language files into the cache;
[0016] The step of reloading the target language file from the multilingual platform to the multilingual file stored in the cache includes:
[0017] Load the incremental target language files from the last loading time to the current time from the multi-language platform to the multi-language files stored in the cache.
[0018] Optionally, the step of loading the incremental target language file from the multilingual platform between the last loading time and the current time to the multilingual file stored in the cache includes:
[0019] Obtain the incremental target language file from the multi-language platform from the last loading time to the current time;
[0020] Overwriting the local multi-language file with the acquired incremental target language file in the original format;
[0021] Write the overwritten local multi-language file to the cache.
[0022] Optionally, the multi-language platform provides a software development kit SDK, and the local project adds the dependency of the software development kit SDK and configures the information of the multi-language platform;
[0023] The method of loading all multi-language files from the multi-language platform to the local computer and writing the local multi-language files into the cache includes:
[0024] Through the interface of the software development kit SDK, the full amount of multi-language files are loaded from the multi-language platform to the local, and the local multi-language files are written into the cache.
[0025] Optionally, the multi-language platform provides a software development kit SDK, and the local project adds the dependency of the software development kit SDK and configures the information of the multi-language platform;
[0026] The step of loading the incremental target language file from the last loading time to the current time from the multi-language platform to the multi-language file stored in the cache includes:
[0027] The incremental target language files between the last loading time and the current time are loaded from the multi-language platform to the multi-language files stored in the cache through the interface of the software development kit SDK.
[0028] The present disclosure also provides a target language file reading device, the device comprising:
[0029] A receiving unit, configured to receive an HTTP request to obtain a target language type of a page content desired by a user, wherein a request header of the HTTP request includes the language type of the page content desired by the user;
[0030] A search unit, configured to search for a target language file corresponding to the target language type in the multi-language files stored in the cache, wherein the multi-language files include language files corresponding to a plurality of language types respectively;
[0031] A loading unit, configured to reload the target language file from the multilingual platform to the multilingual files stored in the cache if the target language file is not found in the multilingual files stored in the cache, or if the difference between the current time and the predefined initial time reaches a predefined update period;
[0032] The reading unit is used to read the reloaded target language file in the cache to obtain data of the target language type of the page content expected by the user.
[0033] The present disclosure also provides an electronic device, comprising a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are interconnected via the bus;
[0034] The memory stores machine-readable instructions, and the processor executes the above method by calling the machine-readable instructions.
[0035] The present disclosure also provides a machine-readable storage medium, wherein the machine-readable storage medium stores machine-readable instructions, and when the machine-readable instructions are called and executed by a processor, the above method is implemented.
[0036] According to the embodiment of the present disclosure, an HTTP request is first received, and the target language type of the page content expected by the user is obtained in the request header of the HTTP request. Then, a target language file corresponding to the target language type is searched in the multi-language files stored in the cache, wherein the multi-language files include language files corresponding to multiple language types respectively. Furthermore, if the target language file is not found in the multi-language files stored in the cache, or the difference between the current moment and the predefined initial moment reaches a predefined update period, the target language file is reloaded from the multi-language platform to the multi-language files stored in the cache. Finally, the reloaded target language file is read in the cache to obtain data of the target language type of the page content expected by the user.
[0037] Through the above method, the technical solution of the present disclosure cannot find the target language file in the multi-language files stored in the cache, or when the difference between the current moment and the predefined initial moment reaches the predefined update cycle, the target language file is reloaded from the multi-language platform to the multi-language files stored in the cache; in this way, when the target language file on the multi-language platform is updated, the updated target language file can be directly pulled to the local cache, without manually modifying the multi-language files in the Spring Boot project, recompiling and packaging the Spring Boot project, and finally redeploying it to the production environment, and then loading the multi-language files in the Spring Boot project into the cache. After adopting the technical solution of the present disclosure, the complexity and cost of operation and maintenance can be reduced, flexibility can be improved, and hot update of the target language file can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0039] Figure 1 is a flow chart of a method for reading a target language file according to an exemplary embodiment;
[0040] Figure 2 is a flow chart of another target language file reading method shown in an exemplary embodiment;
[0041] Figure 3is a schematic diagram of a multi-language platform file update according to an exemplary embodiment;
[0042] Figure 4 is a hardware structure diagram of an electronic device shown in an exemplary embodiment;
[0043] Figure 5 It is a block diagram of a target language file reading device shown in an exemplary embodiment. DETAILED DESCRIPTION
[0044] In order to enable those skilled in the art to better understand the technical solutions in the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present disclosure.
[0045] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this disclosure. In some other embodiments, the steps included in the method may be more or less than those described in this disclosure. In addition, a single step described in this disclosure may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this disclosure may also be combined into a single step for description in other embodiments.
[0046] The Spring Boot framework provides many out-of-the-box features, such as multi-language support provided by internationalization components. The Spring Boot project is a specific application built on the Spring Boot framework. The Spring Boot project can use the internationalization components provided by the Spring Boot framework to achieve multi-language support, so that content in different languages can be displayed on the project page according to user needs.
[0047] However, if you want to update the multi-language files in the Spring Boot project, you need to manually modify the multi-language files, recompile and package the Spring Boot project, and finally redeploy it to the production environment. This not only increases the complexity and cost of operation and maintenance, but also has poor flexibility and cannot achieve real-time update of multi-language files. Changes in language content cannot take effect immediately and need to wait for the next deployment.
[0048] In view of this, the present disclosure aims to propose a technical solution that can realize hot update of target language files in Spring Boot projects.
[0049] The technical solution first receives an HTTP (HyperText Transfer Protocol) request, obtains the target language type of the page content expected by the user in the request header of the HTTP request, and then searches for a target language file corresponding to the target language type in the multi-language files stored in the cache, wherein the multi-language files include language files corresponding to multiple language types respectively; further, if the target language file is not found in the multi-language files stored in the cache, or the difference between the current moment and the predefined initial moment reaches a predefined update period, the target language file is reloaded from the multi-language platform to the multi-language files stored in the cache; finally, the reloaded target language file is read in the cache to obtain data of the target language type of the page content expected by the user.
[0050] For example, an online shopping website supports multiple languages, such as English, Chinese, and French. Users can access the online shopping website through a browser and specify the language they expect the online shopping website page to be in. The user sends an HTTP request through the browser, and the request header contains Accept-Language:zh_CN, indicating that the user expects the page content to be in Chinese. After receiving the HTTP request, the server parses and finds that the user expects the page content to be in Chinese. First, it searches for multilingual files in the cache. The multilingual files contain language files corresponding to various languages, such as Chinese language files, English language files, French language files, etc. Each language file contains the data of the language corresponding to the website page display content. If the Chinese language file containing Chinese greetings and other Chinese page content, that is, the zh_CN.properties file, is not found in the multilingual files stored in the cache, or the time difference between the current time and the predefined initial time exceeds the preset update cycle (for example, 60 seconds), the server sends a request to the multilingual platform to obtain the latest zh_CN.properties file and writes it into the multilingual files stored in the cache. Finally, the server reads the reloaded zh_CN.properties file from the multilingual files stored in the cache, for example, reads "greeting.message = Welcome to our website", and then the server returns the obtained Chinese greeting "Welcome to our website" to the user and displays it on the web page.
[0051] Through the above method, the technical solution of the present disclosure cannot find the target language file in the multi-language files stored in the cache, or when the difference between the current moment and the predefined initial moment reaches the predefined update cycle, the target language file is reloaded from the multi-language platform to the multi-language files stored in the cache; in this way, when the target language file on the multi-language platform is updated, the updated target language file can be directly pulled to the local cache, without manually modifying the multi-language files in the Spring Boot project, recompiling and packaging the Spring Boot project, and finally redeploying it to the production environment, and then loading the multi-language files in the Spring Boot project into the cache. After adopting the technical solution of the present disclosure, the complexity and cost of operation and maintenance can be reduced, flexibility can be improved, and hot update of the target language file can be achieved.
[0052] The present disclosure is described below through specific embodiments in combination with specific application scenarios.
[0053] See also Figure 1 , Figure 1 The following is a flowchart of a method for reading a target language file according to an exemplary embodiment. The method may perform the following steps:
[0054] Step 102: Receive an HTTP request to obtain the target language type of the page content desired by the user, wherein the request header of the HTTP request includes the language type of the page content desired by the user.
[0055] For example, an online shopping website supports multiple languages, such as English, Chinese, and French. Users can access the online shopping website through a browser and specify the language they expect the online shopping website page to be in. The user sends an HTTP request through the browser, and the request header contains Accept-Language:zh_CN, indicating that the user expects the page content to be in Chinese.
[0056] Among them, an HTTP request is a request sent by a client (usually a browser) to a server to request a certain resource or perform a certain operation. An HTTP request consists of a request line, a request header, and a request body. Accept-Language is a request header of a specific HTTP request, which is used to inform the server which language the client (usually a browser) wants to receive content in. The value of this HTTP request header can be one or more language tags, which are used to identify the standard format of a language, usually consisting of a language code and a country / region code, separated by a hyphen (-). For example, zh-CN represents Chinese (Simplified) and en-US represents American English. When a user visits a website, the user can select a preferred language in their browser settings. Most modern browsers allow users to set a preferred language, which is usually located in the "Settings" or "Options" menu of the browser. The user's operating system language setting will also affect the default language setting of the browser. For example, if the user's operating system is set to Chinese, the browser will usually use Chinese as the preferred language by default. The present disclosure does not limit the specific way in which the user selects the target language type. After confirming the target language selected by the user, the browser will generate an HTTP request and include the Accept-Language field in the request header of the HTTP request. After receiving the HTTP request, the server parses the Accept-Language field in the request header of the HTTP request to determine the page language type expected by the user.
[0057] Step 104: searching for a target language file corresponding to the target language type in the multi-language files stored in the cache, wherein the multi-language files include language files corresponding to a plurality of language types.
[0058] For example, the multi-language file contains language files corresponding to various languages, such as Chinese language files, English language files, French language files, etc. Each language file contains data in the language corresponding to the content displayed on the website page. When the server receives an HTTP request with Accept-Language:zh-CN in the request header, indicating that the user expects the page content to be in Chinese, it searches for the Chinese language file corresponding to Chinese in the multi-language files stored in the cache.
[0059] Among them, cache is a storage technology used to temporarily save frequently accessed data to improve data access speed and system performance. Cache can be stored in memory, hard disk or other storage media. Through the cache mechanism, the number of accesses to the original data source can be reduced, thereby speeding up the reading of data. Multilingual files contain language files corresponding to various languages. These files are usually used to achieve internationalization, so that applications can support multiple languages. A common form of multilingual files is a language pack, which is usually one or more files, each of which contains data entries in a specific language version. These language packs enable applications to load corresponding text resources according to the user's language preferences, thereby realizing interface localization. Finding the cache is to search for specific data in the cache. The process of finding the cache usually includes checking whether the required data already exists in the cache. If it exists, it is used directly. If it does not exist, it is obtained from other data sources and stored in the cache.
[0060] Step 106: If the target language file is not found in the multilingual files stored in the cache, or the difference between the current time and the predefined initial time reaches a predefined update period, the target language file is reloaded from the multilingual platform to the multilingual files stored in the cache.
[0061] For example, if the zh_CN.properties file containing Chinese greetings and other Chinese page content is not found in the multilingual files stored in the cache, or the time difference between the current moment and the predefined initial moment exceeds the predefined update cycle (e.g., 60 seconds), the server sends a request to the multilingual platform to obtain the latest zh_CN.properties file and writes it to the multilingual files stored in the cache.
[0062] Among them, the multilingual platform is a system or service for centrally managing multilingual files, centrally storing and managing translation content in multiple languages, supporting translation and version control in multiple languages, and providing an API (Application Programming Interface) for applications (such as Spring Boot projects) to call. Developers will create resource files for each supported language, such as zh_CN.properties, en_US.properties, etc. These multilingual files contain translations for all texts in the application pages. Multilingual files are usually stored on the multilingual platform (i.e., the server). In order to improve performance, the server may use cache to store these resource files.
[0063] Step 108: Read the reloaded target language file from the multi-language files stored in the cache to obtain data of the target language type of the page content desired by the user.
[0064] For example, the server reads the reloaded zh_CN.properties file from the multilingual files stored in the cache, such as reading "greeting.message = Welcome to our website", and then the server returns the obtained Chinese greeting "Welcome to our website" to the user and displays it on the web page.
[0065] The server reads data from the selected resource file, such as "greeting.message = Welcome to our website". Finally, the server sends the read data (Chinese greeting) back to the user's browser as part of the response. The user's browser receives the data returned by the server and renders it on the web page, so that the user can see the text in the language version they expect (Chinese).
[0066] In one embodiment shown, the method further includes: if the target language file is found in the multi-language files stored in the cache, and the difference between the current moment and the predefined initial moment does not reach the predefined update period, then reading the found target language file in the multi-language files stored in the cache to obtain data of the target language type of the page content desired by the user.
[0067] For example, a website supports two languages, Chinese and English. The website administrator predefines the initial time to be 00:00:00 on November 15, 2024, and predefines the update cycle of various language files to be updated every 24 hours. The update cycle of the language files is set to ensure that users can see the latest translation content. A cache mechanism is set on the multilingual platform (i.e., the server) to store various language files, such as the Chinese language file zh_CN.properties and the English language file en_US.properties. When a user visits the website at 10:00:00 on November 15, 2024, which is less than 24 hours from the predefined initial time, the server reads the zh_CN.properties file from the multilingual files stored in the cache, and then reads "greeting.message = Welcome to our website" from the zh_CN.properties file, and then sends the obtained Chinese greeting "Welcome to our website" back to the user's browser as part of the response.
[0068] Among them, the server records the last updated timestamp of the target language file (i.e. the predefined initial moment) and sets an update cycle (updated every 24 hours). This timestamp and update cycle are used to determine whether the target language file needs to be reloaded when an HTTP request is received. The server will calculate the time difference between the current moment and the predefined initial moment by comparing the current system time with the last updated time of the file. If the time difference between the current moment and the predefined initial moment does not reach the update cycle, the server will decide not to reload the target language file, but directly use the target language file version in the multi-language file stored in the cache. This process ensures that users can quickly obtain the language content they expect while reducing the server load and response time.
[0069] In one embodiment shown, the predefined initial time is set in the cache, and after the target language file is reloaded from the multilingual platform to the multilingual file stored in the cache, the method further includes: recording the time when the target language file is reloaded from the multilingual platform to the multilingual file stored in the cache; and updating the predefined initial time set in the cache to the recorded time when the target language file is reloaded from the multilingual platform to the multilingual file stored in the cache.
[0070] For example, a website supports two languages, Chinese and English. The website administrator predefines the initial time to be 00:00:00 on November 15, 2024, and the update cycle of various language files is updated every 24 hours. The multilingual files stored in the server cache include the Chinese language file zh_CN.properties and the English language file en_US.properties. Assume that at 00:00:00 on November 17, 2024, an HTTP request is received, and the user expects the language to be Chinese. Since the update cycle of 24 hours has been exceeded, the server reloads the latest Chinese language file zh_CN.properties from the multilingual platform to the multilingual files stored in the cache. After reloading the language files, the server updates the previously set predefined initial time (00:00:00 on November 15, 2024) to the newly recorded reload time (00:00:00 on November 17, 2024).
[0071] The server not only sets a predefined initial time when loading a file for the first time, but also updates this time after each reload of the file, ensuring that the file update cycle is adhered to, while optimizing the use of the cache and improving the response speed and performance of the website.
[0072] In order to help those skilled in the art better understand the above embodiments, Figure 2 This method is described.
[0073] See also Figure 2 , Figure 2 FIG. 1 is a flowchart of another target language file reading method shown in an exemplary embodiment. Figure 2 As shown, first, an HTTP request is received to obtain the target language type (Chinese, English, etc.) of the page content expected by the user, and then the target language file corresponding to the target language type is searched in the multi-language files stored in the cache. If the target language file is found in the multi-language files stored in the cache, it is determined whether the difference between the current moment and the predefined initial moment has reached the predefined update cycle. If it has reached, it is necessary to load the latest target language file from the multi-language platform to the multi-language file stored in the cache, and then read the reloaded target language file in the multi-language file; taking the Spring Boot project as an example, the target language file may be stored in PropertiesHolder, which is a class in the Spring framework used to encapsulate and manage the content of property files (i.e., .properties files). The resource file content represented by the PropertiesHolder object is the "multi-language file" mentioned above. A new PropertiesHolder instance needs to be created to encapsulate the newly loaded content, and then the target language file is reloaded from the multi-language platform, the target language file content is written into the newly created PropertiesHolder instance, and then the content in the PropertiesHolder instance is written into the cache. If not reached, the target language file is read directly in PropertiesHolder.
[0074] In an illustrated embodiment, before searching for the target language file corresponding to the target language type in the multi-language files stored in the cache, the method further includes: loading the full multi-language file from the multi-language platform to the local, and writing the local multi-language file to the cache; reloading the target language file from the multi-language platform to the multi-language file stored in the cache includes: loading the incremental target language file from the multi-language platform from the last loading moment to the current moment to the multi-language file stored in the cache.
[0075] For example, a website supports three languages: Chinese, English, and Spanish. The website administrator predefines the update cycle of various language files to be updated every 24 hours. The multilingual files include zh_CN.properties, en_US.properties, and es_ES.properties, which are stored in the multilingual files stored in the server's cache. At 00:00:00 on November 15, 2024, the server loads the full set of target language files (zh_CN.properties, en_US.properties, and es_ES.properties) from the multilingual platform (which may be a central file storage or database) to the local for the first time. The server writes these files to the cache for quick access. At 01:00:00 on November 16, 2024, an HTTP access request is received. Since the update cycle has exceeded 24 hours, the server loads the incremental target language files from the multi-language platform from the last loading time (00:00:00 on November 15, 2024) to the current time (01:00:00 on November 16, 2024) into the cache. Assuming that only the zh_CN.properties file is updated during this period, the server only loads the incremental update of zh_CN.properties from the multi-language platform into the cache.
[0076] Among them, full loading means that the server downloads a complete copy of all language files from the multi-language platform, usually implemented through a file transfer protocol or application programming interface. Incremental update means that the server only downloads the part of the file that has changed since the last update, which usually requires the multi-language platform to support version control or timestamp tracking in order to identify which language files have been modified since the last synchronization. The server writes the files downloaded from the multi-language platform to the local cache, and reads the file content from the cache to respond to user requests, both of which involve file I / O operations, which may use standard file reading and writing libraries or frameworks.
[0077] In this embodiment, the server not only loads the full file from the multi-language platform to the local and writes it to the cache when it is first loaded, but also only loads the incremental update file from the last loading time to the current time to the cache when the HTTP request is received and the update cycle arrives. This method can reduce unnecessary data transmission, improve update efficiency, and ensure that users can always access the latest translation content.
[0078] In one embodiment shown, the method of loading the incremental target language file from the last loading moment to the current moment from the multilingual platform to the multilingual file stored in the cache includes: obtaining the incremental target language file from the last loading moment to the current moment from the multilingual platform; overwriting the local multilingual file with the obtained incremental target language file in the original format; and writing the overwritten local multilingual file into the cache.
[0079] For example, the server loads the incremental multi-language files from the multi-language platform from the last loading time (November 15, 2024 00:00:00) to the current time (November 16, 2024 01:00:00) into the cache. Assuming that only the zh_CN.properties file is updated during this period, the server only obtains the target language file zh_CN.properties from the multi-language platform. The server will overwrite the local multi-language files with the obtained incremental zh_CN.properties file in the original format. The multi-language files include language files such as zh_CN.properties and en_US.properties. This means that only the changed parts will be updated, and the other unchanged parts will remain as they are. The server will rewrite the overwritten zh_CN.properties file into the cache to replace the old cache file. In this way, when the user requests Chinese content, the server can read the zh_CN.properties file from the cache to quickly provide the latest Chinese translation.
[0080] Among them, the "original format" mentioned in this embodiment generally refers to the data structure and encoding format of the target language file, which determines how the file organizes and stores data. There are many data structures and encoding formats for files, such as the .properties format, which is the format used by Java property files and is generally used to store key-value pairs. Each line contains a key-value pair, and the key and value are separated by an equal sign (=), such as greeting.message=Welcome to our website. In addition, there are .JSON format, .XML format, etc., and the present disclosure does not limit the specific format selection. During the overwrite process, it is necessary to ensure that the data structure and encoding format of the file remain unchanged, as well as all comments, blank lines, original organizational structure, etc., and only the changed data will be updated.
[0081] In one embodiment shown, the multi-language platform provides a software development kit SDK, the dependency of the software development kit SDK is added to the local project and the information of the multi-language platform is configured; the loading of the full multi-language files from the multi-language platform to the local and writing the local multi-language files to the cache includes: loading the full multi-language files from the multi-language platform to the local through the interface of the software development kit SDK, and writing the local multi-language files to the cache.
[0082] For example, the multi-language platform provides an SDK (Software Development Kit) to help developers integrate multi-language support into their applications. Add the SDK dependency in the pom.xml file of the local Spring Boot project. In this way, the local Spring Boot project can use the functions provided by the SDK. In addition, the access information of the multi-language platform, including the API (Application Programming Interface) key, project ID, etc., must be configured in the configuration file of the Spring Boot project. When the Spring Boot project starts, the SDK is initialized and the configuration information is set. Then, the interface provided by the SDK is used to load the full amount of multi-language files from the multi-language platform to the local, and finally the multi-language files loaded to the local are written to the cache.
[0083] Among them, the software development kit SDK is a set of tools and libraries that help developers integrate specific functions into their applications. In this embodiment, the SDK provided by the multilingual platform allows the Spring Boot project to communicate with the multilingual platform to obtain multilingual files. API is a set of rules and definitions for interaction between software components. SDK interacts with the multilingual platform through API and requests to obtain multilingual files. In software development, dependency refers to external libraries or modules that a project needs to use. In the Spring Boot project, the functions provided by the SDK are used by adding the SDK dependencies in the pom.xml file.
[0084] In one embodiment shown, the multi-language platform provides a software development kit SDK, a dependency of the software development kit SDK is added to a local project and information of the multi-language platform is configured; the incremental target language files between the last loading moment and the current moment are loaded from the multi-language platform to the multi-language files stored in the cache, including: loading the incremental target language files between the last loading moment and the current moment from the multi-language platform to the multi-language files stored in the cache through an interface of the software development kit SDK.
[0085] For example, the e-commerce platform Spring Boot project integrates the SDK provided by the multi-language platform. The local SpringBoot project can use the functions provided by the SDK, which is used to help the Spring Boot project communicate with the multi-language platform. In addition, the access information of the multi-language platform, including API keys, project IDs, etc., must be configured in the configuration file of the Spring Boot project so that the multi-language platform can be identified and accessed. The Spring Boot project records the last time a file was loaded from the multi-language platform to help determine which files have been updated since the last load. When the Spring Boot project needs to update the target language file, it uses the SDK interface to request the multi-language platform for the incremental target language file from the last load time to the current time.
[0086] Among them, incremental update means loading and updating only the data that has changed since the last load, rather than reloading all the data. Through incremental update, unnecessary data transmission can be reduced and update efficiency can be improved.
[0087] In this embodiment, the processing contents of full loading and incremental loading are encapsulated into an SDK, which can be reused in multiple projects, so that other business developers can quickly get started, reduce duplication of work, and thus reduce development and maintenance costs.
[0088] In order to help those skilled in the art better understand the above embodiments, Figure 3 This method is described.
[0089] See also Figure 3 , Figure 3 FIG. 1 is a schematic diagram of a multi-language platform file update according to an exemplary embodiment. Figure 3 As shown, first, the development or operation and maintenance personnel configure the multi-language files on the multi-language platform management end, and the multi-language platform management end stores the multi-language files in the database of the multi-language system after review. When the business system backend receives the HTTP request, it calls the API of the multi-language platform through the SDK provided by the multi-language platform to load the incremental target language file from the multi-language platform. Finally, the obtained incremental target language file is updated to the business system cache, and the obtained content is returned to the client.
[0090] Based on the same concept as the above method, the present disclosure also provides a computer-readable storage medium on which computer instructions are stored. When the instructions are executed by a processor, the steps of the method described in any of the above embodiments are implemented.
[0091] Based on the same concept as the above method, the present disclosure also provides a computer program product, including a computer program / instruction, which implements the steps of the method described in any of the above embodiments when executed by a processor.
[0092] Based on the same concept as the above method, the present disclosure also provides an embodiment of a multi-language document reading device.
[0093] See also Figure 4 , Figure 4 It is a hardware structure diagram of an electronic device shown in an exemplary embodiment. At the hardware level, the device includes a processor 402, an internal bus 404, a network interface 406, a memory 408 and a non-volatile memory 410, and of course may also include other required hardware. One or more embodiments of the present disclosure can be implemented based on software, such as the processor 402 reading the corresponding computer program from the non-volatile memory 410 into the memory 408 and then running it. Of course, in addition to the software implementation, one or more embodiments of the present disclosure do not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0094] See also Figure 5 , Figure 5 FIG. 5 is a block diagram of a target language file reading device according to an exemplary embodiment. The target language file reading device 500 can be applied to Figure 4 In the electronic device shown, the technical solution of the present disclosure is implemented; the device includes:
[0095] The receiving unit 502 is used to receive an HTTP request to obtain the target language type of the page content desired by the user, wherein the request header of the HTTP request includes the language type of the page content desired by the user;
[0096] A searching unit 504 is configured to search for a target language file corresponding to the target language type in the multi-language files stored in the cache, wherein the multi-language files include language files corresponding to a plurality of language types respectively;
[0097] A loading unit 506, configured to reload the target language file from the multilingual platform to the multilingual files stored in the cache if the target language file is not found in the multilingual files stored in the cache, or if the difference between the current time and the predefined initial time reaches a predefined update period;
[0098] The reading unit 508 is used to read the reloaded target language file in the cache to obtain data of the target language type of the page content desired by the user.
[0099] In some embodiments, the apparatus further comprises:
[0100] The searching unit is used to read the found target language file from the multi-language files stored in the cache if the target language file is found in the multi-language files stored in the cache and the difference between the current time and the predefined initial time does not reach the predefined update period, so as to obtain the data of the target language type of the page content expected by the user.
[0101] In some embodiments, the predefined initial time is set in a cache, and after reloading the target language file from the multilingual platform to the multilingual file stored in the cache, the method further includes:
[0102] Records the moment when the target language file is reloaded from the multi-language platform into the multi-language file stored in the cache;
[0103] The predefined initial time set in the cache is updated to the recorded time of reloading the target language file from the multi-language platform to the multi-language file stored in the cache.
[0104] In some embodiments, before searching the multi-language files stored in the cache for the target language file corresponding to the target language category, the method further includes:
[0105] Load all multi-language files from the multi-language platform to the local computer, and write the local multi-language files into the cache;
[0106] The step of reloading the target language file from the multilingual platform to the multilingual file stored in the cache includes:
[0107] Load the incremental target language files from the last loading time to the current time from the multi-language platform to the multi-language files stored in the cache.
[0108] In some embodiments, loading the incremental target language file from the last loading time to the current time from the multi-language platform to the multi-language file stored in the cache includes:
[0109] Obtain the incremental target language file from the multi-language platform from the last loading time to the current time;
[0110] Overwriting the local multi-language file with the acquired incremental target language file in the original format;
[0111] Write the overwritten local multi-language file to the cache.
[0112] In some embodiments, the multi-language platform provides a software development kit SDK, and the dependency of the software development kit SDK is added to the local project and the information of the multi-language platform is configured;
[0113] The method of loading all multi-language files from the multi-language platform to the local computer and writing the local multi-language files into the cache includes:
[0114] Through the interface of the software development kit SDK, the full amount of multi-language files are loaded from the multi-language platform to the local, and the local multi-language files are written into the cache.
[0115] In some embodiments, the multi-language platform provides a software development kit SDK, and the dependency of the software development kit SDK is added to the local project and the information of the multi-language platform is configured;
[0116] The step of loading the incremental target language file from the last loading time to the current time from the multi-language platform to the multi-language file stored in the cache includes:
[0117] The incremental target language files between the last loading time and the current time are loaded from the multi-language platform to the multi-language files stored in the cache through the interface of the software development kit SDK.
[0118] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0119] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the disclosed solution. A person of ordinary skill in the art can understand and implement it without paying any creative work.
[0120] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0121] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0122] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0123] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0124] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0125] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0126] The above describes specific embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0127] The terms used in one or more embodiments of the present disclosure are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present disclosure. The singular forms of "a", "said" and "the" used in one or more embodiments of the present disclosure and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0128] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of the present disclosure, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determination".
[0129] The above description is only a preferred embodiment of one or more embodiments of the present disclosure and is not intended to limit one or more embodiments of the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present disclosure shall be included in the scope of protection of one or more embodiments of the present disclosure.
Claims
1. A method for reading a target language file, characterized in that: The method comprises: Receiving an HTTP request to obtain a target language type of a page content desired by a user, wherein a request header of the HTTP request includes the language type of the page content desired by the user; Searching for a target language file corresponding to the target language type in the multi-language files stored in the cache, wherein the multi-language files include language files corresponding to a plurality of language types respectively; If the target language file is not found in the multi-language files stored in the cache, or the difference between the current time and the predefined initial time reaches a predefined update period, the target language file is reloaded from the multi-language platform to the multi-language files stored in the cache; The reloaded target language file is read from the multi-language files stored in the cache to obtain data of the target language of the page content desired by the user.
2. The method according to claim 1, characterized in that The method further comprises: If the target language file is found in the multi-language files stored in the cache, and the difference between the current moment and the predefined initial moment does not reach the predefined update period, the found target language file is read from the multi-language files stored in the cache to obtain data of the target language type of the page content desired by the user.
3. The method according to claim 1, characterized in that The predefined initial time is set in the cache, and after the target language file is reloaded from the multilingual platform to the multilingual file stored in the cache, the method further includes: Records the moment when the target language file is reloaded from the multi-language platform into the multi-language file stored in the cache; The predefined initial time set in the cache is updated to the recorded time of reloading the target language file from the multi-language platform to the multi-language file stored in the cache.
4. The method according to claim 1, characterized in that: Before searching the multi-language files stored in the cache for the target language file corresponding to the target language type, the method further includes: Load all multi-language files from the multi-language platform to the local computer, and write the local multi-language files into the cache; The step of reloading the target language file from the multilingual platform to the multilingual file stored in the cache includes: Load the incremental target language files from the last loading time to the current time from the multi-language platform to the multi-language files stored in the cache.
5. The method according to claim 4, characterized in that The step of loading the incremental target language file from the last loading time to the current time from the multi-language platform to the multi-language file stored in the cache includes: Obtain the incremental target language file from the multi-language platform from the last loading time to the current time; Overwriting the local multi-language file with the acquired incremental target language file in the original format; Write the overwritten local multi-language file to the cache.
6. The method according to claim 4, characterized in that The multi-language platform provides a software development kit SDK, and the dependency of the software development kit SDK is added to the local project and the information of the multi-language platform is configured; The method of loading all multi-language files from the multi-language platform to the local computer and writing the local multi-language files into the cache includes: Through the interface of the software development kit SDK, the full amount of multi-language files are loaded from the multi-language platform to the local, and the local multi-language files are written into the cache.
7. The method according to claim 4, characterized in that The multi-language platform provides a software development kit SDK, and the dependency of the software development kit SDK is added to the local project and the information of the multi-language platform is configured; The step of loading the incremental target language file from the last loading time to the current time from the multi-language platform to the multi-language file stored in the cache includes: The incremental target language files between the last loading time and the current time are loaded from the multi-language platform to the multi-language files stored in the cache through the interface of the software development kit SDK.
8. A target language file reading device, characterized in that: The device comprises: A receiving unit, configured to receive an HTTP request to obtain a target language type of a page content desired by a user, wherein a request header of the HTTP request includes the language type of the page content desired by the user; A search unit, configured to search for a target language file corresponding to the target language type in the multi-language files stored in the cache, wherein the multi-language files include language files corresponding to a plurality of language types respectively; A loading unit, configured to reload the target language file from the multilingual platform to the multilingual files stored in the cache if the target language file is not found in the multilingual files stored in the cache, or if the difference between the current time and the predefined initial time reaches a predefined update period; The reading unit is used to read the reloaded target language file in the cache to obtain data of the target language type of the page content expected by the user.
9. An electronic device, characterized in that: It includes a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are interconnected via the bus; The memory stores machine-readable instructions, and the processor executes the method according to any one of claims 1 to 7 by calling the machine-readable instructions.
10. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-readable instructions, and when the machine-readable instructions are called and executed by a processor, the method according to any one of claims 1 to 7 is implemented.