A resource loading method and apparatus
By dividing application resources into general, language, and regional resource packs and using a relative path matching mechanism to dynamically load target resources, the problem of copyright restrictions and compliance review for applications in different regions is solved, and efficient, flexible management and customization of resources are achieved.
Patent Information
- Application Number
- CN202610425689.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-01
- Publication Date
- 2026-06-26
AI Technical Summary
Existing application localization technologies have failed to effectively address the cross-regional copyright restrictions and compliance reviews, resulting in chaotic version management, high operating costs, and a lack of flexibility, making it impossible to achieve precise content customization for a single region.
By dividing application resources into initial general resources, multilingual resources, and multi-regional resource packages, and using a relative path matching mechanism, the target language and region resource packages are dynamically loaded to replace the initial resources, thereby achieving resource decoupling and collaboration and supporting on-demand loading of the target application.
It reduces the storage space occupied by application resource packages, enables precise isolation and replacement for different regions, solves the problem of copyright restrictions, simplifies version management for multi-regional localized operations, and supports flexible independent content customization.
Smart Images

Figure CN122285284A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a resource loading method. This application also relates to a resource loading apparatus, a computing device, and a computer-readable storage medium. Background Technology
[0002] With the rapid development of computer and internet technologies, various applications have emerged. Since application users come from different regions, and these regions have significant differences in relevant regulations, copyright restrictions, and user cultural preferences, application localization has evolved from simple language translation to a complex content adaptation process. Specifically, this not only requires adjusting the text of the user interface to conform to local language habits, but also customizing and replacing interface elements, functional modules, and even specific materials according to the compliance requirements of specific regions.
[0003] However, current application localization typically packages all supported language resources into a single installation package. This ignores the user's actual language resource needs, forcing them to download an installation package containing all language resources, increasing download time and data costs, and also consuming storage space on the user's device. Secondly, at the level of deep regional customization, current installation package construction is often limited to switching between multiple languages, lacking a fine-grained isolation mechanism for individual regions. This mechanism cannot effectively address the cross-regional copyright restrictions. At the same time, due to the lack of an independent regional resource architecture, existing localization operations find it extremely difficult to provide independent content customization services based on the characteristics of a single region. Once regional compliance adjustments or special operations are required, multiple independent application versions often need to be developed and maintained for different regions, resulting in extremely chaotic version management, high localization operation costs, and a lack of flexibility. Summary of the Invention
[0004] In view of this, embodiments of this application provide a resource loading method. This application also relates to a resource loading apparatus, a computing device, and a computer-readable storage medium, to solve the aforementioned problems existing in the prior art.
[0005] According to a first aspect of the embodiments of this application, a resource loading method is provided, including: In response to a startup operation for a target application, an initial general resource package is loaded, and a general resource relative path corresponding to at least one initial general resource is obtained based on the initial general resource package; Obtain target language information and target region information, and load a target language resource package that matches the target language information and a target region resource package that matches the target region information; Obtain at least one relative path of a first resource corresponding to a first resource based on the target language resource package, and obtain at least one relative path of a second resource corresponding to a second resource based on the target region resource package; The matching results between each relative path of the first resource and each relative path of the second resource and each relative path of the general resource are obtained, and based on the matching results, each first resource and each second resource replaces at least a portion of the initial general resource in memory, so as to load the target application according to the replaced resources.
[0006] According to a second aspect of the embodiments of this application, a resource loading apparatus is provided, comprising: The response module is configured to load an initial general resource package in response to a startup operation for the target application, and obtain a general resource relative path corresponding to at least one initial general resource based on the initial general resource package; The first acquisition module is configured to acquire target language information and target region information, and load a target language resource package that matches the target language information and a target region resource package that matches the target region information; The second acquisition module is configured to acquire at least one relative path of a first resource corresponding to a first resource according to the target language resource package, and to acquire at least one relative path of a second resource corresponding to a second resource according to the target region resource package. The replacement module is configured to obtain the matching information between each first resource relative path and each second resource relative path and each general resource relative path, and to replace at least a portion of the initial general resources with each first resource and each second resource in memory based on the matching information, so as to load the target application according to the replaced resources.
[0007] According to a third aspect of the embodiments of this application, a computing device is provided, comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, which, when executed by the processor, implement the steps of the resource loading method described above.
[0008] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided that stores a computer program / instructions, which, when executed by a processor, implement the steps of the resource loading method described above.
[0009] The resource loading method provided in this application can load an initial general resource package in response to a startup operation for a target application; obtain target language information and target region information, and load a target language resource package matching the target language information and a target region resource package matching the target region information; then, through a relative path matching mechanism, replace the resources in the initial general resource package with resources from the target language resource package and the target region resource package, thereby achieving dynamic on-demand loading of application resources based on the target language and target region. This solution not only eliminates the need to download all resources, significantly reducing the storage space occupied by the application's resource package; more importantly, by independently loading the target region resource package, it enables precise isolation and replacement of resources in specific regions, effectively solving the problems of copyright restrictions and compliance reviews in different regions; at the same time, this mechanism allows the application to flexibly adapt to independent localized customization services in a single region based on a unified underlying architecture, without maintaining multiple independent application versions for different regions, greatly reducing the complexity of version management for multi-regional localized operations, and supporting rapid independent content deployment based on regional characteristics. Attached Figure Description
[0010] Figure 1 This is a flowchart of a resource loading method provided in an embodiment of this application; Figure 2 This is a flowchart of a resource loading method provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of a resource loading device provided in an embodiment of this application; Figure 4 This is a structural block diagram of a computing device provided in one embodiment of this application. Detailed Implementation
[0011] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below.
[0012] The terminology used in one or more embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this application. The singular forms “a,” “the,” and “the” used in one or more embodiments of this application and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” used in one or more embodiments of this application refers to and includes any or all possible combinations of one or more associated listed items.
[0013] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this application, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this application, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0014] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0015] As described in the background section, the number of various applications has increased dramatically, and their service scope now covers different users in various regions. Significant differences exist among user groups in terms of language habits, cultural preferences, etc., making application localization crucial. Application localization can be understood as the process of adapting an application product to a target region through translation, cultural adaptation, and functional adjustments. In one or more embodiments of this specification, application localization may involve adjusting the text, images, and other content in the application's user interface to conform to the language habits of a specific target user group and the relevant legal requirements of the region where that target user group resides.
[0016] Currently, most application localization solutions package all language resources into the application's resource package. Regardless of the user's actual language requirement, they have to download the resource package containing all language resources, which not only increases the size of the resource package but also increases user loading time and data consumption, occupies user terminal storage space, and affects user experience.
[0017] Furthermore, current localization technologies often load the default language resources at the beginning of application startup, and then update the language resources after detecting the user's actual language needs. This mechanism of displaying first and then switching will cause obvious content flickering in the user interface, thus affecting the user's visual and interactive experience.
[0018] Furthermore, as described in the background section, current application localization solutions are often limited to shallow replacements across multiple languages, lacking sophisticated resource isolation and replacement mechanisms for individual regions, and even more so, lacking an architecture for collaborative processing of multilingual and multi-regional resources. This technological limitation prevents existing applications from achieving precise adaptation when facing cross-regional copyright restrictions or special compliance reviews; simultaneously, it makes it difficult for localization operations to flexibly and quickly develop independent content customization services tailored to specific regions based on a unified application architecture, often forcing them to adopt the inefficient method of maintaining multiple independent versions to address regionally differentiated needs.
[0019] Based on this, this specification provides a resource loading method that, in response to a startup operation for a target application, loads an initial general resource package; obtains a general resource relative path corresponding to at least one initial general resource based on the initial general resource package; obtains target language information and target region information, and loads a target language resource package matching the target language information and a target region resource package matching the target region information; obtains a first resource relative path corresponding to at least one first resource based on the target language resource package, and obtains a second resource relative path corresponding to at least one second resource based on the target region resource package; obtains the matching status between each first resource relative path and each second resource relative path and each general resource relative path, and, based on the matching status, replaces at least a portion of the initial general resources with each first resource and each second resource in memory, so as to load the target application based on the replaced resources.
[0020] The resource loading method provided in this manual decouples and coordinates application resources at the general, language, and regional layers. This solution not only enables dynamic, on-demand resource loading based on user needs, significantly reducing application installation package size and terminal storage overhead; more importantly, by introducing independent target region resource packages for precise replacement, it provides the application with resource isolation capabilities at the single-region level. This effectively addresses and meets the cross-regional copyright restrictions and compliance review requirements present in different regions. Simultaneously, the unified resource architecture allows localized operations to flexibly and quickly deploy customized content for a single region without needing to build multiple independent application versions for different regions. This fundamentally solves the technical dilemma of high version management complexity and low iteration efficiency when operating in parallel across multiple regions.
[0021] Specifically, since the resources corresponding to the target application are divided into an initial general resource package containing initial general resources, a language resource package containing the first resource, and a regional resource package containing the second resource, the initial general resources can be loaded first. Then, based on the user's actual language and regional needs, the language resource package and regional resource package can be loaded on demand. Then, the initial general resources can be replaced through the relative path of the resources. This can realize dynamic on-demand loading of the target application resources based on the target language and target region, without downloading the full language resources, reducing the storage space occupied by the application's resource package, and also realizing application localization processing for different regions.
[0022] It should be noted that the executing entity of the resource loading method in this specification can be any computing device with computing capabilities, such as a server, terminal, etc. When the executing entity of this resource loading method is a server, the resource loading method can be implemented and executed through end-to-cloud interaction, wherein the end-to-cloud interaction system includes a server and a terminal device.
[0023] It should be understood that when the execution entity is the server, the resource package can be stored on the server, and the terminal does not need to store the game resource package, thus reducing the storage pressure on the terminal device. However, for the server, there is still a lack of methods for application localization processing for different regions, as well as a lack of methods for integrating multilingual and multi-regional resources for application localization processing. It is worth noting that although cloud applications and local applications differ in resource storage and data processing locations—that is, resource storage and data processing in cloud applications are handled by the server, while in local applications they are handled by the local terminal device—the resource configuration layering upon which the resource loading method relies—namely, the initial general resource package, language resource package, and regional resource package, and the mechanism of replacing the initial general resource with the first and / or second resources corresponding to the language and regional resource packages based on the relative storage path of the resources—applies to both cases.
[0024] In summary, regardless of whether the execution entity of the resource loading method is located on the server or the terminal device, the resource loading method provided in this specification can achieve application localization for multi-language resources and multi-regional resources by matching the relative storage paths of resources contained in different resource packages. It can dynamically load target application resources on demand based on the target language and target region.
[0025] The following section provides a detailed description of the resource loading method in this manual, using a terminal device as the execution subject as an example.
[0026] This application provides a resource loading method, and also relates to a resource loading apparatus, a computing device, a computer-readable storage medium, and a computer program product, which will be described in detail in the following embodiments.
[0027] Figure 1 A flowchart of a resource loading method according to an embodiment of this application is shown, which specifically includes the following steps: Step 102: In response to the startup operation for the target application, load the initial general resource package and obtain the relative path of at least one general resource corresponding to the initial general resource based on the initial general resource package.
[0028] The target application is the application that requires localized resource loading. The terminal device can respond to the user's launch operation for the target application and load the initial general resources from the installation package corresponding to the application.
[0029] It should be noted that, in one or more embodiments of this specification, the resources corresponding to the application can be pre-divided into three types, including initial general resources, first resources (i.e., multilingual resources), and second resources (i.e., multi-regional resources). In practical applications, the resources corresponding to the application can be divided based on actual needs and circumstances to obtain general resources, multilingual resources, and multi-regional resources.
[0030] Initial general resources can be understood as default resources shared by all users. In other words, initial general resources provide the target application with resource content in its default language environment. Specifically, these can include user interface elements, text, images, audio, etc. These initial general resources support the basic operation and core content of the application, and the resource content can be specified according to a particular language (e.g., Chinese, English). In practical applications, these initial general resources can be packaged in the application's installation package to facilitate the subsequent on-demand resource loading process, in conjunction with multilingual and multi-regional resources.
[0031] The first resource, namely multilingual resources, can be understood as resources adapted to different languages. In other words, each language resource is used to provide localized resource content for a specific language. It can be used to replace the language-related resource content in the initial general resource package as needed. Specifically, it can include icons, images, audio, etc. adapted to different languages.
[0032] The second type of resource, namely multi-regional resources, can be understood as resources adapted to different regions. In other words, regional resources provide customized content for specific regions. Specifically, this can be achieved by further adapting multilingual resources to specific regions, including adapting user interface elements, text, images, audio, etc., to different regions. Currently, application localization primarily focuses on multilingual processing, often prioritizing displaying user interface content in different languages while neglecting regional differences. In practice, for users with the same language requirements, the display of resource content can vary depending on their region. For example, if the application's language is set to English, for the same interface's lottery function resource, region A might require the replacement of the slot machine icon in the general English package with a treasure chest icon and corresponding specific text due to strict local regulations (such as prohibitions on elements implying gambling). Region B, however, might require replacing the icon with a specific anime collaboration style icon for specific localized operational activities (such as IP copyright collaborations). Such differentiated display requirements arising from regional compliance reviews or independent operational customization needs, even within the same language, cannot be fully met by existing multilingual resource packages. Therefore, this manual also includes multi-regional resources to enable application localization for different regions during application startup and application resource loading.
[0033] In practical applications, before loading resources, initial general resources, multilingual resources, and multi-regional resources can be stored in separate resource files within a designated storage space. This designated storage space can be pre-defined, such as cloud storage. Then, these resources can be packaged into resource bundles, meaning the three types of resources corresponding to the application can be pre-packaged into various types of resource bundles. Specifically, an initial general resource bundle can be built based on the initial general resources, a multilingual resource bundle can be built based on the language resources corresponding to each language, and a multi-regional resource bundle can be built based on the regional resources corresponding to each region, thus obtaining the initial general resource bundle, the multilingual resource bundle, and the multi-regional resource bundle.
[0034] When loading the initial general resource package, obtain the relative path of the general resource corresponding to at least one initial general resource in the initial general resource package.
[0035] In one or more embodiments of this specification, to achieve resource replacement, the corresponding resources in the initial general resource package, language resource package, and regional resource package are configured during the resource package construction phase to contain the same matching relative path. In practical applications, during the construction of any resource package, the resource files containing the resources can be path-standardized so that resources with the same function or semantics contain the same relative path in different types of resource packages.
[0036] For example, an icon (icon.png) has a relative path of Assets / UI / icon.png in the initial general asset bundle; In the multilingual asset pack, the relative path of the English version of this resource is En / Assets / UI / icon.png, which is the same relative path Assets / UI / icon.png with the language prefix En added. Similarly, if a regional version of the icon exists in region A, the relative path of the resource in the region A asset bundle can be Area_A / En / Assets / UI / icon.png, which also contains the same relative path Assets / UI / icon.png, but with the region prefix Area_A / En added. In other words, resources with the same function or semantics are configured to have the same matching relative path in the initial universal asset bundle, multilingual asset bundle, and / or multi-region asset bundle.
[0037] Furthermore, after loading the initial general resource package and obtaining the general resource relative path corresponding to at least one initial general resource, a general resource mapping relationship is constructed in memory between each general resource relative path and the resource identifier of each initial general resource. The resource identifier can be set manually or automatically generated by the development engine, such as a UUID. The resource identifier is used to identify each resource and is a unique identifier for each resource.
[0038] Specifically, when mapping general resources, a mapping table is constructed with the relative path of the general resource as the key and the initial general resource identifier as the value, thereby obtaining the general resource mapping table. For example, assuming the relative path of the initial general resource icon.png is Assets / UI / icon.png and its initial general resource identifier is UUID_1, their mapping relationship in the general resource mapping table is shown in Table 1 below: Table 1
[0039] In one or more embodiments of this specification, an initial general resource package may be pre-packaged into the application's installation package to provide basic data for the application's basic operation. Multilingual and multi-regional resource packages may not need to be packaged into the installation package; that is, they reside outside the application's installation package and can be stored as remote resources on the application's corresponding cloud server or content delivery network. When the terminal device runs the application, it can dynamically download the required language or region resource packages from the cloud server or content delivery network as needed to update and replace resources in the initial general resource package.
[0040] It should be understood that resources with the same function or semantics may appear in multilingual resource packs or multiregional resource packs in different language forms or in forms that meet the relevant regional requirements.
[0041] Step 104: Obtain target language information and target region information, and load the target language resource package that matches the target language information and the target region resource package that matches the target region information.
[0042] In one or more embodiments of this specification, the method of obtaining target language information and target region information is not specifically limited. For example, the language and region used by the user who launched the target application can be obtained through the device platform API corresponding to the application, thus obtaining target language information and target region information. Alternatively, target region information and target language information can be determined based on the terminal device account or other associated account corresponding to the user who launched the target application. Alternatively, if the user who launched the target application is a historical user of the target application, the target language information and target region information can also be obtained based on the language preferences and region preferences set by the user who launched the target application.
[0043] In one or more embodiments of this specification, after obtaining target region information and target language information, a target language resource package matching the target language information and a target region resource package matching the target region information can be loaded as needed. Specifically, a target language resource package corresponding to the target language information can be determined from a multilingual resource package, and a target region resource package corresponding to the target region information can be determined from a multi-region resource package.
[0044] Those skilled in the art should know that after loading the target language resource package and the target region resource package, corresponding resource identifiers are also allocated in memory for the above resources. The resources of the target language resource package have a first resource identifier, and the resources of the target region resource package have a second resource identifier.
[0045] For example, the target language resource package includes an English version of the icon icon.png, which has a first resource identifier UUID_2 when loaded into memory; For example, in the target region resource package, the A region version of the icon.png icon has a corresponding second resource identifier UUID_3 after being loaded into memory; For example, in the target region resource package, the B region version of the notify.png icon has a corresponding second resource identifier UUID_4 after being loaded into memory.
[0046] Those skilled in the art should know that the process of allocating resource identifiers to memory as described above can be completed automatically based on the development engine.
[0047] In one or more embodiments of this specification, the language used by the user can be determined based on the target language information, and the region where the user is located can be determined based on the target region information. This allows the loading of a target language resource package corresponding to the user's language and a target region resource package corresponding to the user's region from a server where the remote resource is located or other content delivery network.
[0048] Step 106: Obtain at least one relative path of a first resource corresponding to a first resource based on the target language resource package, and obtain at least one relative path of a second resource corresponding to a second resource based on the target region resource package.
[0049] As mentioned above, the resources are divided into three categories, and each category is encapsulated into a resource package. Resources with the same function or semantics within a resource package are configured to contain the same relative path. Therefore, by parsing each resource package, the relative path of each resource within the resource package can be obtained. That is, in one or more embodiments of this specification, a target language resource package can be parsed to obtain the relative path of at least one first resource in the target language resource package, and a target region resource package can be parsed to obtain the relative path of at least one second resource in the target region resource package.
[0050] For illustration purposes, the relative path of the English version icon icon.png in the multilingual asset pack is En / Assets / UI / icon.png; and the relative path of the region-specific notification icon notify.png in region A asset pack is Area_A / En / Assets / UI / notify.png.
[0051] Specifically, in this embodiment of the application, after scanning the relative path of icon.png in the multilingual resource package as En / Assets / UI / icon.png, the language prefix En is removed to obtain the first resource relative path of the resource as Assets / UI / icon.png; Similarly, after scanning the relative path of the icon notify.png in the target region's resource package, Area_A / En / Assets / UI / notify.png, its region prefix Area_A / En is removed to obtain the second resource relative path Assets / UI / notify.png.
[0052] Step 108: Obtain the matching status between each first resource relative path and each second resource relative path and each general resource relative path, and based on the matching status, replace at least a portion of the initial general resources with each first resource and each second resource in memory, so as to load the target application according to the replaced resources.
[0053] In practical applications, resource replacement can be carried out in stages based on the matching status between the first resource relative path and each second resource relative path and each general resource relative path.
[0054] Corresponding to the foregoing, a general resource mapping relationship can be constructed based on the initial general resource package and the initial general resource identifier for replacement. Therefore, in one or more embodiments of this specification, the replacement of at least a portion of the initial general resource by each first resource and each second resource in memory is completed based on the matching situation in the mapping relationship, including: Based on the matching situation, at least some of the initial general resource identifiers in the general resource mapping table are replaced with each first resource identifier and each second resource identifier to obtain the target resource mapping relationship, so as to complete the replacement of at least some of the initial general resources by each first resource and each second resource.
[0055] Specifically, each obtained first resource relative path is traversed. If a first resource relative path matches a general resource relative path in the general resource mapping table, the initial general resource identifier corresponding to that general resource relative path is replaced with the first resource identifier corresponding to the current first resource relative path. For example: After scanning and finding the English version icon.png in the first resource relative path Assets / UI / icon.png of the target language resource pack, and discovering that the same element Assets / UI / icon.png exists in the general resource mapping table, the Value UUID_1 corresponding to Assets / UI / icon.png in the general resource mapping table is replaced with the first resource identifier UUID_2 of the English version icon.png corresponding to the first resource relative path Assets / UI / icon.png, as shown in Table 2 below: Table 2
[0056] Similarly, when traversing each obtained second resource relative path, if the second resource relative path matches a certain general resource relative path in the general resource mapping table, the initial general resource identifier corresponding to that general resource relative path is replaced with the second resource identifier corresponding to the current second resource relative path. For example: After scanning and finding the first resource relative path Assets / UI / notify.png of the icon notify.png in the target region's resource package, and discovering that the same element Assets / UI / notify.png exists in the general resource mapping table, the value UUID_3 corresponding to Assets / UI / notify.png in the general resource mapping table is replaced with the second resource identifier UUID_4 of the icon notify.png corresponding to the second resource relative path Assets / UI / notify.png, as shown in Table 3 below: Table 3
[0057] Preferably, if the first resource relative path is the same as the second resource relative path, that is, if a resource has both a target language version and a target region version, then the second resource identifier is used to override the first resource identifier in the general resource mapping table.
[0058] For example, after scanning the English version icon icon.png in the first resource relative path Assets / UI / icon.png of the target language resource package, and replacing the value of Assets / UI / icon.png in the general resource mapping table with UUID_1 and then scanning the target region resource package to find the region version of the icon Area_A / En / Assets / UI / icon.png, the second resource identifier corresponding to Area_A / En / Assets / UI / icon.png is used to overwrite the first resource identifier that has been replaced in the general resource mapping table, as shown in Table 4 below: Table 4
[0059] When different expressions of the same semantic resource exist, the second resource in the target region resource package has a higher priority than the first resource in the target language resource package. In one or more embodiments of this specification, the mapping relationship after replacing the resource identifier of the general resource mapping relationship based on the target language resource package can be denoted as an intermediate resource mapping relationship. The intermediate resource mapping relationship includes at least one mapping relationship with the intermediate resource relative path as the key and the intermediate resource identifier as the value. Correspondingly, the resource identifier of the intermediate resource mapping relationship can be replaced based on the target region resource package.
[0060] In the above resource loading method, since the resource package of the target application is divided into an initial general resource package, a multi-language resource package, and a multi-regional resource package, and since resources with the same function or semantics in each resource package are configured with the same relative path, the initial general resource package can be loaded first, and then the required target language resource package and target region resource package can be loaded on demand. Based on the consistency of relative paths, the resources in the target language resource package and target region resource package can be used to replace the resources in the initial general resource package. This enables dynamic on-demand loading of target application resources based on target language information and target region information, without downloading the full language resources. This reduces the storage space occupied by the resource package corresponding to the application and enables localized resource loading for applications in different regions.
[0061] Furthermore, in one or more embodiments of this specification, after the resource replacement is completed, the target application is loaded based on the replaced user's resources, that is, the application localization resource loading is performed based on the replaced resources.
[0062] like Figure 2 As shown, Figure 2 The flowchart of a resource loading method according to an embodiment of this application is shown, which specifically includes the following steps: Step 202: Upon receiving a resource loading request, obtain the relative path of the resource carried in the resource loading request.
[0063] It should be noted that the resource loading request can be a request to load actual resource content locally on the terminal device. In one or more embodiments of this specification, the resource loading request may carry a request resource identifier, which is typically represented as a resource path. For example, for a UI icon resource, its request resource identifier is Assets / UI / icon.png.
[0064] Furthermore, the requested resource identifier can be one or more; that is, the requested resource can be one or more target resources from the replaced resources. Specifically, the requested resource identifier carried in the resource loading request can be the requested resource identifier corresponding to all resources in the replaced resources, or it can be the requested resource identifier corresponding to some resources in the replaced resources.
[0065] In practical applications, the resource loading request can be generated by the startup operation in step 102 above. That is to say, when the user starts the target application, a resource loading request can be automatically generated. In response to the resource loading request, the aforementioned resource replacement and other operations are performed according to the target language information and target region information. Finally, based on the replaced resource configuration, the actual resource content corresponding to the requested resource identifier carried in the resource loading request is loaded, and the user interface corresponding to the actual resource content is generated and displayed.
[0066] Furthermore, the resource loading request can also be initiated by the user through the resource loading controls displayed on the aforementioned user interface, and this specification does not impose specific restrictions on this.
[0067] Step 204: Obtain the target resource identifier corresponding to the relative path of the resource from the general resource mapping table, and load the corresponding resource based on the target resource identifier.
[0068] In one or more embodiments of this application, a general resource mapping table stores the mapping relationship between the unique resource identifier and the relative path of each resource. Therefore, the unique resource identifier of the requested target resource can be obtained based on the relative path of the resource. The unique resource identifier is one of the aforementioned initial general resource identifier, first resource identifier and second resource identifier.
[0069] Furthermore, the actual resource content is loaded based on the unique resource identifier of the target resource to complete the loading of the target application.
[0070] In one feasible implementation, when loading resources, after obtaining the unique resource identifier of the target resource, the development engine uses the unique resource identifier to query the internally maintained resource registry, and then locates the real physical path to complete the resource loading.
[0071] In the above method, the resource content loaded to display the user interface is the resource content that meets the user's language and regional requirements, and does not contain redundant other language or regional resources. It can meet the localization resource customization requirements and ensure that the loaded resources are adapted to the user's language and region.
[0072] In one or more embodiments of this specification, in order to avoid screen text flickering and improve the user's visual experience, a text resource mapping relationship can be constructed in memory based on the configuration information of various types of text resources before the user interface corresponding to the target application is rendered and displayed, that is, before the target application is loaded. The target application is then loaded based on the text resource mapping relationship and the aforementioned replaced resources.
[0073] Specifically, before loading the target application based on the replaced resources, the process also includes: Obtain general text resource configuration information, target language text resource configuration information corresponding to the target language information, and target region text resource configuration information corresponding to the target region information, wherein the text resource configuration information includes the mapping relationship between text identifiers and text resource content; Based on the general text resource configuration information, an initial text resource mapping relationship is constructed in memory; An intermediate text resource mapping relationship is obtained by updating the initial text resource mapping relationship based on the text identifier and the target language text resource configuration information; and a target text resource mapping relationship is obtained by updating the intermediate text resource mapping relationship based on the text identifier and the target region text resource configuration information. Load the target application based on the replaced resources, including: The target application is loaded based on the target text resource mapping relationship and the replaced resources.
[0074] In practical applications, the text resources corresponding to the target application can be pre-divided into general text resources, multilingual text resources, and multiregional text resources. Then, text resource configuration information is constructed, including mappings between general text identifiers and general text resource content; multilingual text resource configuration information is constructed, including mappings between first text identifiers and language text resource content; and multiregional text resource configuration information is constructed, including mappings between second text identifiers and regional text resource content. Here, general text resources can be understood as the default text resources corresponding to the target application, language text resources can be understood as text resources in a specific language, and regional text resource configuration information can be understood as text resources in a specific region.
[0075] It should be noted that text identifiers (general text identifier, first text identifier, and second text identifier) can be understood as the names of text resources, and are unrelated to the specific form of the text resource, i.e., the language type and region to which the text resource corresponds.
[0076] In practical applications, after the user launches the target application and before the user interface corresponding to the target application is loaded and displayed, general text resource configuration information can be obtained, as well as target language text resource configuration information matching the target language information can be obtained based on the obtained target language information, and target region text resource configuration information matching the target region information can be obtained based on the obtained target region information.
[0077] Then, an initial text resource mapping relationship can be constructed in memory based on the general text resource configuration information. Specifically, the initial text resource mapping relationship can be constructed in memory based on the mapping relationship between the general text resource identifier and the general text resource content in the general text resource configuration information. The initial text resource mapping relationship represents the mapping relationship between the general text identifier and the general text resource content corresponding to the general text identifier.
[0078] It should be noted that in practical applications, the specific form of text resource mapping relationships can be a hash table or a dictionary structure. That is, a hash table or dictionary corresponding to text identifiers and their corresponding text resource content can be constructed in memory.
[0079] In one or more embodiments of this specification, the target language text configuration file information may include a mapping relationship between a first text resource identifier and the corresponding language text resource content in the target language.
[0080] Therefore, when obtaining an intermediate text resource mapping relationship by updating the initial text resource mapping relationship based on the text identifier and the target language text resource configuration information, each general text resource identifier and each first text resource identifier can be compared. If it is determined that the target first text resource identifier and the target general text resource identifier are the same, the language text resource content corresponding to the target first text resource identifier can be used to replace the general text resource content corresponding to the general text resource identifier in the initial text resource mapping relationship. And / or, if it is determined that the target first text resource identifier is not the same as any general text resource identifier, the mapping relationship between the target first text resource identifier and the language text resource content corresponding to the target first text resource identifier is added to the initial text resource mapping relationship to obtain the intermediate text resource mapping relationship. In this specification, the text resources in the intermediate text resource mapping relationship are referred to as intermediate text resources, and the text resource identifiers are referred to as intermediate text resource identifiers.
[0081] In one or more embodiments of this specification, the target region text configuration file information may include a mapping relationship between a second text resource identifier and the second text resource content corresponding to the second text resource identifier in the target region.
[0082] Therefore, when obtaining the target text resource mapping relationship by updating the intermediate text resource mapping relationship based on the text identifier and the target region text resource configuration information, each second text resource identifier and each intermediate text resource identifier can be compared. If it is determined that the target second text resource identifier and the target intermediate text resource identifier are the same, the region text resource content corresponding to the target second text resource identifier is used to replace the intermediate text resource content corresponding to the target intermediate text resource identifier in the intermediate text resource mapping relationship. And / or, if it is determined that the target second text resource identifier is not the same as any intermediate text resource identifier, the mapping relationship between the target second text resource identifier and the region text resource content corresponding to the target second text resource identifier is added to the intermediate text resource mapping relationship to obtain the target text resource mapping relationship.
[0083] It should be noted that the resources in this embodiment can be understood as text resources, as mentioned above. Figure 1 The corresponding resources can be non-text resources.
[0084] In one or more embodiments of this specification, after obtaining the target text resource mapping relationship, the target application can be loaded according to the target text resource mapping relationship and the replaced resources. Specifically, the target application can be loaded according to the text resource content contained in the target text resource mapping relationship and the replaced resources to render and display the user interface.
[0085] For example, the initial text resource configuration information may include a mapping relationship from text 1 to AA. That is, the initial text resource mapping relationship in memory includes the mapping relationship from text 1 to AA. Assuming the target language text resource configuration information includes a mapping relationship from text 1 to AB, then based on the same text identifier as text 1, AB can be replaced with AA to obtain an intermediate text resource mapping relationship containing the mapping relationship from text 1 to AB. Further assuming the target region text resource configuration information includes a mapping relationship from text 1 to BB, then again based on the same text identifier as text 1, BB can be replaced with AB to obtain a target text resource mapping relationship containing the mapping relationship from text 1 to BB. The text resource mapping relationship in memory is then updated to the mapping relationship from text 1 to BB, and the resource content corresponding to text 1 is updated to BB. During loading and display, BB can be directly displayed without the screen flickering from AA to AB and / or from AB to BB, improving the user's visual experience.
[0086] In practical applications, before the target application is loaded, text-related content in the user interface of the target application can be replaced with text identifiers. Thus, when the actual resource content is loaded, or when it is necessary to display text resource content, a text resource loading request is generated. This text resource loading request can carry a request text identifier. Then, based on the request text identifier, the target text resource content corresponding to the request text identifier can be obtained from the target text resource mapping relationship in memory and loaded for display.
[0087] Based on the above text resource loading method, since the text resource content in the target text resource mapping relationship in memory is text resource content that meets the user's language and regional requirements, and the text resource content is loaded and displayed before the target application is fully loaded or before the corresponding user interface of the target application is displayed, it can be guaranteed that the first frame of the user interface displayed is text resource content that fully meets the user's language and regional requirements, thereby eliminating text flickering and improving the user's visual experience.
[0088] Corresponding to the above method embodiments, this application also provides resource loading device embodiments. Figure 3 A schematic diagram of a resource loading device according to an embodiment of this application is shown. Figure 3 As shown, the device includes: The response module 302 is configured to load an initial general resource package in response to a startup operation for a target application, and obtain a general resource relative path corresponding to at least one initial general resource based on the initial general resource package; The first acquisition module 304 is configured to acquire target language information and target region information, and load a target language resource package that matches the target language information and a target region resource package that matches the target region information; The second acquisition module 306 is configured to acquire at least one first resource relative path corresponding to a first resource according to the target language resource package and to acquire at least one second resource relative path corresponding to a second resource according to the target region resource package. The replacement module 308 is configured to obtain the matching information between each first resource relative path and each second resource relative path and each general resource relative path, and to replace at least a portion of the initial general resources with each first resource and each second resource in memory based on the matching information, so as to load the target application according to the replaced resources.
[0089] The aforementioned resource loading device can replace resources in the initial general resource package with resources from the target language resource package and the target region resource package based on relative path matching, thereby achieving dynamic on-demand loading of target application resources based on the target language and target region. This eliminates the need to download the full set of language resources, reducing the storage space occupied by the application's corresponding resource package. It can also achieve localization processing of applications for different regions.
[0090] The above is an illustrative scheme of a resource loading device according to this embodiment. It should be noted that the technical solution of this resource loading device and the technical solution of the resource loading method described above belong to the same concept. For details not described in detail in the technical solution of the resource loading device, please refer to the description of the technical solution of the resource loading method described above.
[0091] Figure 4 A structural block diagram of a computing device 400 according to an embodiment of this application is shown. The components of the computing device 400 include, but are not limited to, a memory 410 and a processor 420. The processor 420 is connected to the memory 410 via a bus 430, and a database 450 is used to store data.
[0092] The computing device 400 also includes an access device 440, which enables the computing device 400 to communicate via one or more networks 460. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 440 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0093] In one embodiment of this application, the aforementioned components of the computing device 400 and Figure 4Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 4 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this application. Those skilled in the art can add or replace other components as needed.
[0094] The computing device 400 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 400 can also be a mobile or stationary server.
[0095] The processor 420 is used to execute the following computer program / instructions, which, when executed by the processor, implement the steps of the resource loading method described above.
[0096] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the resource loading method described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the resource loading method described above.
[0097] An embodiment of this specification also provides a computer-readable storage medium storing a computer program / instructions that, when executed by a processor, implement the steps of the resource loading method described above.
[0098] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the resource loading method described above belong to the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the resource loading method described above.
[0099] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0100] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added or removed according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0101] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0102] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0103] The preferred embodiments disclosed above are merely illustrative of this application. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this application. These embodiments are selected and specifically described in this application to better explain the principles and practical applications of this application, thereby enabling those skilled in the art to better understand and utilize this application. This application is limited only by the claims and their full scope and equivalents.
Claims
1. A resource loading method, characterized in that, include: In response to a startup operation for a target application, an initial general resource package is loaded, and a general resource relative path corresponding to at least one initial general resource is obtained based on the initial general resource package; Obtain target language information and target region information, and load a target language resource package that matches the target language information and a target region resource package that matches the target region information; Obtain at least one relative path of a first resource corresponding to a first resource based on the target language resource package, and obtain at least one relative path of a second resource corresponding to a second resource based on the target region resource package; The matching results between each relative path of the first resource and each relative path of the second resource and each relative path of the general resource are obtained, and based on the matching results, each first resource and each second resource replaces at least a portion of the initial general resource in memory, so as to load the target application according to the replaced resources.
2. The method as described in claim 1, characterized in that, Obtaining at least one relative path of a general resource corresponding to an initial general resource based on the initial general resource package includes: Scan the initial general resource package and construct a general resource mapping table in memory between the general resource relative paths of each initial general resource and the resource identifiers of each initial general resource.
3. The method according to claim 2, characterized in that, Obtaining at least one relative path to a first resource corresponding to a first resource based on the target language resource package, and obtaining at least one relative path to a second resource corresponding to a second resource based on the target region resource package, including: Scan the target language resource package to obtain the original path of at least one first resource, and obtain the relative path of the first resource after deleting its language prefix directory; Scan the resource package in the target region to obtain the original path corresponding to at least one second resource. After deleting the region prefix directory, the relative path of the second resource is obtained.
4. The method as described in claim 2, characterized in that, Obtain the matching results between each relative path of the first resource and each relative path of the second resource and each relative path of the general resource, and based on the matching results, complete the replacement of at least a portion of the initial general resource by each first resource and each second resource in memory, including: Traverse each first resource relative path. If a first resource relative path matches a general resource relative path in the general resource mapping table, then replace the resource identifier of the initial general resource corresponding to the current general resource relative path with the first resource identifier corresponding to the current first resource relative path in the general resource mapping table; and... Traverse each second resource relative path. If a second resource relative path matches a general resource relative path in the general resource mapping table, then replace the resource identifier of the initial general resource corresponding to the current general resource relative path with the second resource identifier corresponding to the current second resource relative path in the general resource mapping table.
5. The method as described in claim 4, characterized in that, The method further includes: During the replacement process, if the first resource relative path is the same as the second resource relative path, the second resource identifier corresponding to the second resource relative path is used to overwrite the first resource identifier corresponding to the first resource relative path in the general resource mapping table.
6. The method as described in claim 5, characterized in that, Load the target application based on the replaced resources, including: Upon receiving a resource loading request, obtain the relative path of the resource carried in the resource loading request; Obtain the target resource identifier corresponding to the relative path of the resource from the general resource mapping table, and load the corresponding resource based on the target resource identifier.
7. The method according to any one of claims 1 to 6, characterized in that, The resources in the initial general resource pack, language resource pack, and region resource pack are configured in the resource pack to contain the same matching relative path.
8. The method according to any one of claims 1 to 6, characterized in that, Before loading the target application based on the replaced resources, the following is also included: Obtain general text resource configuration information, target language text resource configuration information corresponding to the target language information, and target region text resource configuration information corresponding to the target region information, wherein the text resource configuration information includes the mapping relationship between text identifiers and text resource content; Based on the general text resource configuration information, an initial text resource mapping relationship is constructed in memory; An intermediate text resource mapping relationship is obtained by updating the initial text resource mapping relationship based on the text identifier and the target language text resource configuration information; and a target text resource mapping relationship is obtained by updating the intermediate text resource mapping relationship based on the text identifier and the target region text resource configuration information. Load the target application based on the replaced resources, including: The target application is loaded based on the target text resource mapping relationship and the replaced resources.
9. A resource loading device, characterized in that, include: The response module is configured to load an initial general resource package in response to a startup operation for the target application, and obtain a general resource relative path corresponding to at least one initial general resource based on the initial general resource package; The first acquisition module is configured to acquire target language information and target region information, and load a target language resource package that matches the target language information and a target region resource package that matches the target region information; The second acquisition module is configured to acquire at least one relative path of a first resource corresponding to a first resource according to the target language resource package, and to acquire at least one relative path of a second resource corresponding to a second resource according to the target region resource package. The replacement module is configured to obtain the matching information between each first resource relative path and each second resource relative path and each general resource relative path, and to replace at least a portion of the initial general resources with each first resource and each second resource in memory based on the matching information, so as to load the target application according to the replaced resources.
10. A computing device, characterized in that, include: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, which, when executed by the processor, implement the steps of the method according to any one of claims 1 to 8.
11. A computer-readable storage medium storing a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 8.