1e41f4b71Sopenharmony_ci# Resource Categories and Access
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciDuring application development, you may need to use different resources, such as colors, fonts, spacing, and images, based on the device or configuration. Depending on the resource type, you can achieve this using the following methods:
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci- Application resources: Configure device- or configuration-specific resources in the resource files.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci- System resources: Use the preset resource definitions<!--Del--> (that is, [layered parameters](../../design/ux-design/design-resources.md), with which each resource ID is assigned different values under different configurations, including device types and color modes)<!--DelEnd-->.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Resource Categories
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciResource files used during application development must be stored in specified directories for management. There are two types of resource directories, namely, resource directories and resource group directories. The resource directories are the **base**, qualifiers, **rawfile**, and **resfile** directories. The resource group directories are the **element**, **media**, and **profile** directories.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci> **NOTE**
14e41f4b71Sopenharmony_ci>
15e41f4b71Sopenharmony_ci> The common resource files used across projects in the stage model are stored in the **resources** directory under **AppScope**.
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciExample of the **resources** directory:
18e41f4b71Sopenharmony_ci```
19e41f4b71Sopenharmony_ciresources
20e41f4b71Sopenharmony_ci|---base
21e41f4b71Sopenharmony_ci|   |---element
22e41f4b71Sopenharmony_ci|   |   |---string.json
23e41f4b71Sopenharmony_ci|   |---media
24e41f4b71Sopenharmony_ci|   |   |---icon.png
25e41f4b71Sopenharmony_ci|   |---profile
26e41f4b71Sopenharmony_ci|   |   |---test_profile.json
27e41f4b71Sopenharmony_ci|---en_US  // Default directory. When the device language is en-us, resources in this directory are preferentially matched.
28e41f4b71Sopenharmony_ci|   |---element
29e41f4b71Sopenharmony_ci|   |   |---string.json
30e41f4b71Sopenharmony_ci|   |---media
31e41f4b71Sopenharmony_ci|   |   |---icon.png
32e41f4b71Sopenharmony_ci|   |---profile
33e41f4b71Sopenharmony_ci|   |   |---test_profile.json
34e41f4b71Sopenharmony_ci|---zh_CN  // Default directory. When the device language is zh-cn, resources in this directory are preferentially matched.
35e41f4b71Sopenharmony_ci|   |---element
36e41f4b71Sopenharmony_ci|   |   |---string.json
37e41f4b71Sopenharmony_ci|   |---media
38e41f4b71Sopenharmony_ci|   |   |---icon.png
39e41f4b71Sopenharmony_ci|   |---profile
40e41f4b71Sopenharmony_ci|   |   |---test_profile.json
41e41f4b71Sopenharmony_ci|---en_GB-vertical-car-mdpi // Example of a qualifiers directory, which needs to be created on your own.
42e41f4b71Sopenharmony_ci|   |---element
43e41f4b71Sopenharmony_ci|   |   |---string.json
44e41f4b71Sopenharmony_ci|   |---media
45e41f4b71Sopenharmony_ci|   |   |---icon.png
46e41f4b71Sopenharmony_ci|   |---profile
47e41f4b71Sopenharmony_ci|   |   |---test_profile.json
48e41f4b71Sopenharmony_ci|---rawfile // Other types of files are saved as raw files and will not be integrated into the resources.index file. You can customize the file name as needed.
49e41f4b71Sopenharmony_ci|---resfile // Other types of files are saved as raw files and will not be integrated into the resources.index file. You can customize the file name as needed.
50e41f4b71Sopenharmony_ci```
51e41f4b71Sopenharmony_ci### Resource Directories
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci#### base Directory
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ciThe **base** directory is provided by default. Under this directory, the **element** subdirectory stores basic elements such as strings, colors, and boolean values, and the **media** and **profile** subdirectories store resource files such as media, animations, and layouts.<br>
56e41f4b71Sopenharmony_ciResource files in the subdirectories are compiled into binary files, and each resource file is assigned an ID. Resource files in the subdirectories are referenced based on the resource type and resource name.
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci#### Qualifiers Directory
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci**en_US** and **zh_CN** are two default qualifiers directories. You need to create other qualifiers directories on your own. Under this directory, the subdirectories store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts.<br>Resource files in the subdirectories are compiled into binary files, and each resource file is assigned an ID. Resource files in the subdirectories are referenced based on the resource type and resource name.
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci**Naming Conventions for Qualifiers Directories**
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ciThe name of a qualifiers directory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code (MCC), mobile network code (MNC), language, script, country or region, screen orientation, device type, night mode, and screen density. The qualifiers are separated using underscores (\_) or hyphens (\-). Before creating a qualifiers directory, familiarize yourself with the directory naming conventions.
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci- Qualifiers are ordered in the following sequence: **\_MCC_MNC-language_script_country/region-orientation-device-color mode-density_**. You can select one or multiple qualifiers to name your subdirectory based on your application scenarios and device characteristics.
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci- Separation between qualifiers: The language, script, and country/region qualifiers are separated using underscores (\_); the MNC and MCC qualifiers are also separated using underscores (\_); other qualifiers are separated using hyphens (\-). For example, **zh_Hant_CN** and **zh_CN-car-ldpi**.
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci- Value range of qualifiers: The value of each qualifier must meet the requirements specified in the following table. Otherwise, the resource files in the resources directory cannot be matched.
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ciTable 2 Requirements for qualifier values
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci| Qualifier Type      | Description and Value Range                                 |
75e41f4b71Sopenharmony_ci| ----------- | ---------------------------------------- |
76e41f4b71Sopenharmony_ci| MCC&MNC| Indicates the MCC and MNC, which are obtained from the network where the device is registered.<br>The MCC can be either followed by the MNC with an underscore (_) in between or be used independently. For example, **mcc460** represents China, and **mcc460_mnc00** represents China Mobile.<br>For details about the value range, see [ITU-T E.212](https://www.itu.int/rec/T-REC-E.212) (the international identification plan for public networks and subscriptions).|
77e41f4b71Sopenharmony_ci| Language         | Indicates the language used by the device. The value consists of two or three lowercase letters. For example, **zh** indicates Chinese, **en** indicates English, and **mai** indicates Maithili.<br>For details about the value range, see [ISO 639](https://www.iso.org/iso-639-language-code) (codes for the representation of names of languages).|
78e41f4b71Sopenharmony_ci| Text         | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters. For example, **Hans** indicates simplified Chinese, and **Hant** indicates traditional Chinese.<br>For details about the value range, see [ISO 15924](https://www.iso.org/standard/81905.html) (codes for the representation of names of scripts).|
79e41f4b71Sopenharmony_ci| Country/Region      | Indicates the country or region where the user is located. The value consists of two or three uppercase letters or three digits. For example, **CN** indicates China, and **GB** indicates the United Kingdom.<br>For details about the value range, see [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) (codes for the representation of names of countries and their subdivisions).|
80e41f4b71Sopenharmony_ci| Screen orientation        | Indicates the screen orientation of the device. The value can be:<br>- **vertical**: portrait orientation<br>- **horizontal**: landscape orientation|
81e41f4b71Sopenharmony_ci| Device type       | <!--RP1-->Indicates the device type. The value can be:<br>- **car**: head unit<br>- **tablet**: tablet<br>- **tv**: smart TV<br>- **wearable**: smart wearable<!--RP1End--> |
82e41f4b71Sopenharmony_ci| Color mode       | Indicates the color mode of the device. The value can be:<br>- **dark**: dark mode<br>- **light**: light mode|
83e41f4b71Sopenharmony_ci| Screen density       | Indicates the screen density of the device, in dpi. The value can be:<br>- **sdpi**: screen density with small-scale dots per inch (SDPI). This value is applicable for devices with a DPI range of (0, 120].<br>- **mdpi**: medium-scale screen density (Medium-scale&nbsp;Dots&nbsp;Per&nbsp;Inch), applicable to DPI whose value is (120, &nbsp;160] device.<br>- **ldpi**: screen density with large-scale dots per inch (LDPI). This value is applicable for devices with a DPI range of (160, 240].<br>- **xldpi**: screen density with extra-large-scale dots per inch (XLDPI). This value is applicable for devices with a DPI range of (240, 320].<br>- **xxldpi**: screen density with extra-extra-large-scale dots per inch (XXLDPI). This value is applicable for devices with a DPI range of (320, 480].<br>- **xxxldpi**: screen density with extra-extra-extra-large-scale dots per inch (XXXLDPI). This value is applicable for devices with a DPI range of (480, 640].|
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci#### rawfile Directory
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ciYou can create multiple levels of subdirectories with custom names to store various resource files.<br>Resource files in the subdirectories are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. The subdirectories are referenced based on the specified file path and file name.
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci#### resfile Directory
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ciYou can create multiple levels of subdirectories with custom names to store various resource files.<br>Resource files in the subdirectories are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. After an application is installed, the **resfile** directory is decompressed to the application sandbox path. You can obtain the path through the [resourceDir](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis-ability-kit/js-apis-inner-application-context.md#properties) attribute of **Context**.
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci### Resource Group Directories
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ciResource group directories include **element**, **media**, and **profile**, which are used to store resources of specific types.
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci  **Table 3** Resource group directories
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci| Directory   | Description                                    | Resource File                                    |
100e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---------------------------------------- |
101e41f4b71Sopenharmony_ci| element | Element resources. Each type of data is represented by a JSON file. (Only files are supported in this directory.) The options are as follows:<br>- **boolean**: boolean data<br>- **color**: color data<br>- **float**: floating point number ranging from -2^128 to 2^128<br>- **intarray**: array of integers<br>- **integer**: integer ranging from -2^31 to 2^31-1<!--Del--><br>- **pattern**: style (for system applications only)<!--DelEnd--><br>- **plural**: plural form data<br>- **strarray**: array of strings<br>- **string**: string. [See descriptions for formatting strings.](../reference/apis-localization-kit/js-apis-resource-manager.md#getstringsync10)<!--Del--><br>- **theme**: theme (for system applications only)<!--DelEnd-->| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:<br>-&nbsp;boolean.json<br>-&nbsp;color.json<br>-&nbsp;float.json<br>-&nbsp;intarray.json<br>-&nbsp;integer.json<!--Del--><br>-&nbsp;pattern.json<!--DelEnd--><br>-&nbsp;plural.json<br>-&nbsp;strarray.json<br>-&nbsp;string.json |
102e41f4b71Sopenharmony_ci| media   | Indicates media resources, including non-text files such as images, audios, and videos. (Only files are supported in this directory.)<br>Table 4 and Table 5 describe the types of images, audios, and videos.             | The file name can be customized, for example, **icon.png**.                    |
103e41f4b71Sopenharmony_ci| profile  | Indicates a custom configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis-ability-kit/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. (Only JSON files are supported in this directory.)      | The file name can be customized, for example, **test_profile.json**.          |
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci**Media Resource Types**
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ciTable 4 Image resource types
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci| Format  | File Name Extension|
110e41f4b71Sopenharmony_ci| ---- | ----- |
111e41f4b71Sopenharmony_ci| JPEG | .jpg  |
112e41f4b71Sopenharmony_ci| PNG  | .png  |
113e41f4b71Sopenharmony_ci| GIF  | .gif  |
114e41f4b71Sopenharmony_ci| SVG  | .svg  |
115e41f4b71Sopenharmony_ci| WEBP | .webp |
116e41f4b71Sopenharmony_ci| BMP  | .bmp  |
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ciTable 5 Audio and video resource types
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci| Format                                  | File Name Extension        |
121e41f4b71Sopenharmony_ci| ------------------------------------ | --------------- |
122e41f4b71Sopenharmony_ci| H.264 AVC |.3gp |
123e41f4b71Sopenharmony_ci| Baseline Profile (BP) | .mp4   |
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci**Resource File Examples**
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ciThe content of the **color.json** file is as follows:
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci```json
130e41f4b71Sopenharmony_ci{
131e41f4b71Sopenharmony_ci    "color": [
132e41f4b71Sopenharmony_ci        {
133e41f4b71Sopenharmony_ci            "name": "color_hello",
134e41f4b71Sopenharmony_ci            "value": "#ffff0000"
135e41f4b71Sopenharmony_ci        },
136e41f4b71Sopenharmony_ci        {
137e41f4b71Sopenharmony_ci            "name": "color_world",
138e41f4b71Sopenharmony_ci            "value": "#ff0000ff"
139e41f4b71Sopenharmony_ci        }
140e41f4b71Sopenharmony_ci    ]
141e41f4b71Sopenharmony_ci}
142e41f4b71Sopenharmony_ci```
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ciThe content of the **float.json** file is as follows:
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci```json
147e41f4b71Sopenharmony_ci{
148e41f4b71Sopenharmony_ci    "float":[
149e41f4b71Sopenharmony_ci        {
150e41f4b71Sopenharmony_ci            "name":"font_hello",
151e41f4b71Sopenharmony_ci            "value":"28.0fp"
152e41f4b71Sopenharmony_ci        },
153e41f4b71Sopenharmony_ci	      {
154e41f4b71Sopenharmony_ci            "name":"font_world",
155e41f4b71Sopenharmony_ci            "value":"20.0fp"
156e41f4b71Sopenharmony_ci        }
157e41f4b71Sopenharmony_ci    ]
158e41f4b71Sopenharmony_ci}
159e41f4b71Sopenharmony_ci```
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ciThe content of the **string.json** file is as follows:
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci```json
164e41f4b71Sopenharmony_ci{
165e41f4b71Sopenharmony_ci    "string":[
166e41f4b71Sopenharmony_ci        {
167e41f4b71Sopenharmony_ci            "name":"string_hello",
168e41f4b71Sopenharmony_ci            "value":"Hello"
169e41f4b71Sopenharmony_ci        },
170e41f4b71Sopenharmony_ci	      {
171e41f4b71Sopenharmony_ci            "name":"string_world",
172e41f4b71Sopenharmony_ci            "value":"World"
173e41f4b71Sopenharmony_ci        },
174e41f4b71Sopenharmony_ci	      {
175e41f4b71Sopenharmony_ci            "name":"message_arrive",
176e41f4b71Sopenharmony_ci            "value":"We will arrive at %1$s."
177e41f4b71Sopenharmony_ci        },
178e41f4b71Sopenharmony_ci        {
179e41f4b71Sopenharmony_ci            "name":"message_notification",
180e41f4b71Sopenharmony_ci            "value":"Hello, %1$s!,You have %2$d new messages."
181e41f4b71Sopenharmony_ci        }
182e41f4b71Sopenharmony_ci    ]
183e41f4b71Sopenharmony_ci}
184e41f4b71Sopenharmony_ci```
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ciThe content of the **plural.json** file is as follows:
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci```json
189e41f4b71Sopenharmony_ci{
190e41f4b71Sopenharmony_ci    "plural":[
191e41f4b71Sopenharmony_ci        {
192e41f4b71Sopenharmony_ci            "name":"eat_apple",
193e41f4b71Sopenharmony_ci            "value":[
194e41f4b71Sopenharmony_ci                {
195e41f4b71Sopenharmony_ci                    "quantity":"one",
196e41f4b71Sopenharmony_ci                    "value":"%d apple"
197e41f4b71Sopenharmony_ci                },
198e41f4b71Sopenharmony_ci                {
199e41f4b71Sopenharmony_ci                    "quantity":"other",
200e41f4b71Sopenharmony_ci                    "value":"%d apples"
201e41f4b71Sopenharmony_ci                }
202e41f4b71Sopenharmony_ci            ]
203e41f4b71Sopenharmony_ci        }
204e41f4b71Sopenharmony_ci    ]
205e41f4b71Sopenharmony_ci}
206e41f4b71Sopenharmony_ci```
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci## Creating a Resource Directory and Resource File
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ciYou can create a directory and its files under the **resources** directory based on the preceding descriptions of the qualifiers directories and resource group directories. DevEco Studio provides a wizard for you to create resource directories and resource files.
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci### Creating a Resource Directory and Resource File
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ciRight-click the **resources** directory and choose **New** > **Resource File**. If no qualifier is selected, the file is created in a resource group directory under **base**. If one or more qualifiers are selected, the system automatically generates a subdirectory and creates the file in this subdirectory.
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ciIn **File name**, enter the name of the resource file to create. In **Resource type**, select the type of the resource group, which is **element** by default. In **Root Element**, select a resource type. To select a qualifier, highlight it under **Available qualifiers** and click the right arrow. To deselect a qualifier, highlight it under **Selected qualifiers** and click the left arrow.<br>The created directory is automatically named in the format of *Qualifiers.Resource group type*. For example, if you create a subdirectory by setting **Color Mode** to **Dark** and **Resource type** to **Element**, the system automatically generates a subdirectory named **dark.element**.
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci  ![create-resource-file-1](figures/create-resource-file-1.png)
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci### Creating a Resource Directory
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ciRight-click the **resources** directory and choose **New** > **Resource Directory** to create a directory only. By default, the **base** directory is created. You can create qualifiers directories as required, by specifying the qualifier and resource group type.
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci  ![create-resource-file-2](figures/create-resource-file-2.png)
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci### Creating a Resource File
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ciRight-click a directory under **resources** and choose **New** > **XXX Resource File**. This operation creates a resource file under this directory. For example, you can create an element resource file in the **element** subdirectory.
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci  ![create-resource-file-3](figures/create-resource-file-3.png)
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci## Using the attr Attribute for Resource Translation
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci### Function Description
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ciYou can use the **attr** attribute to specify whether a string should be translated and the translation status. The **attr** attribute is not involved in resource compilation.
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ciIf the **attr** attribute is not configured, a string is translated by default.
239e41f4b71Sopenharmony_ci```
240e41f4b71Sopenharmony_ci"attr": {
241e41f4b71Sopenharmony_ci  "translatable": false|true
242e41f4b71Sopenharmony_ci  "priority": "code|translate|LT|customer"
243e41f4b71Sopenharmony_ci}
244e41f4b71Sopenharmony_ci```
245e41f4b71Sopenharmony_ci**Parameters of attr**
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci| Name       | Type                   |  Description  |
248e41f4b71Sopenharmony_ci| --------- | ----------------------- |  ---- |
249e41f4b71Sopenharmony_ci| translatable |  boolean |  Whether the string needs to be translated.<br>  **true**: The string needs to be translated.<br> **false**: The string does not need to be translated.|
250e41f4b71Sopenharmony_ci| priority    | string   |  Translation status of the string.<br>**code**: untranslated<br>**translate**: translated but not verified<br>**LT**: translated and verified<br>**customer**: custom  |
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci### Constraints
253e41f4b71Sopenharmony_ciThe **attr** attribute applies to the string, strarray, and plural resources in the **base** directory.
254e41f4b71Sopenharmony_ci```
255e41f4b71Sopenharmony_ciresources
256e41f4b71Sopenharmony_ci|---base
257e41f4b71Sopenharmony_ci|   |---element
258e41f4b71Sopenharmony_ci|   |   |---string.json
259e41f4b71Sopenharmony_ci|   |   |---strarray.json
260e41f4b71Sopenharmony_ci|   |   |---plural.json
261e41f4b71Sopenharmony_ci```
262e41f4b71Sopenharmony_ci### Example
263e41f4b71Sopenharmony_ciThis example sets the **attr** attribute for strings.
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci```json
266e41f4b71Sopenharmony_ci{
267e41f4b71Sopenharmony_ci  "string": [
268e41f4b71Sopenharmony_ci    {
269e41f4b71Sopenharmony_ci      "name": "string1",
270e41f4b71Sopenharmony_ci      "value": "1",
271e41f4b71Sopenharmony_ci      "attr": {
272e41f4b71Sopenharmony_ci        "translatable": false
273e41f4b71Sopenharmony_ci      }
274e41f4b71Sopenharmony_ci    },
275e41f4b71Sopenharmony_ci    {
276e41f4b71Sopenharmony_ci      "name": "string2",
277e41f4b71Sopenharmony_ci      "value": "Hello world!",
278e41f4b71Sopenharmony_ci      "attr": {
279e41f4b71Sopenharmony_ci        "translatable": true,
280e41f4b71Sopenharmony_ci        "priority": "LT"
281e41f4b71Sopenharmony_ci      }
282e41f4b71Sopenharmony_ci    }
283e41f4b71Sopenharmony_ci  ]
284e41f4b71Sopenharmony_ci}
285e41f4b71Sopenharmony_ci```
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci## Resource Access
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ci### HAP Resources
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ci - Use **$r** or **$rawfile** to reference resources.<br>To reference resources of the color, float, string, plural, media, or profile type, use the "$r('app.type.name')" format, where **app** indicates the resource defined in the **resources** directory, **type** indicates the resource type or resource save path, and **name** indicates the name you assign to the resource.<br>To reference strings with multiple placeholders in the **string.json** file, use the "$r('app.string.label','aaa','bbb',444)" format.<br>To reference resources in the **rawfile** subdirectory, use the "$rawfile('filename')" format. Wherein **filename** indicates the relative path of a file in the **rawfile** subdirectory, which must contain the file name extension and cannot start with a slash (/).
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci   > **NOTE**
294e41f4b71Sopenharmony_ci   >
295e41f4b71Sopenharmony_ci   > For details about how to use native APIs to access raw files, see [Raw File Development](../napi/rawfile-guidelines.md).
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci  As described in [Resource Group Directories](#resource-group-directories), you can reference .json resource files, including **color.json**, **string.json**, and** plural.json**.<br>The usage is as follows:
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci  ```ts
300e41f4b71Sopenharmony_ci    Text('Hello')
301e41f4b71Sopenharmony_ci    .fontColor($r('app.color.ohos_id_color_emphasize'))
302e41f4b71Sopenharmony_ci    .fontSize($r('app.float.ohos_id_text_size_headline1'))
303e41f4b71Sopenharmony_ci    .fontFamily($r('app.string.ohos_id_text_font_family_medium'))
304e41f4b71Sopenharmony_ci    .backgroundColor($r('app.color.ohos_id_color_palette_aux1'))
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci    Image($r('app.media.ohos_app_icon'))
307e41f4b71Sopenharmony_ci    .border({
308e41f4b71Sopenharmony_ci      color: $r('app.color.ohos_id_color_palette_aux1'),
309e41f4b71Sopenharmony_ci      radius: $r('app.float.ohos_id_corner_radius_button'), width: 2
310e41f4b71Sopenharmony_ci    })
311e41f4b71Sopenharmony_ci    .margin({
312e41f4b71Sopenharmony_ci      top: $r('app.float.ohos_id_elements_margin_horizontal_m'),
313e41f4b71Sopenharmony_ci      bottom: $r('app.float.ohos_id_elements_margin_horizontal_l')
314e41f4b71Sopenharmony_ci    })
315e41f4b71Sopenharmony_ci    .height(200)
316e41f4b71Sopenharmony_ci    .width(300)
317e41f4b71Sopenharmony_ci  ```
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ci- Obtain a **ResourceManager** object through the application context, and then call [resource management APIs](../reference/apis-localization-kit/js-apis-resource-manager.md) to access different resources.<br>For example, call **getContext().resourceManager.getStringByNameSync('test')** to obtain string resources; call **getContext().resourceManager.getRawFd('rawfilepath')** to obtain the descriptor of the HAP where a raw file is located, and then use the descriptor ({fd, offset, length}) to access the raw file.
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci### Cross-HAP/HSP Resources
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci<!--Del-->
324e41f4b71Sopenharmony_ci#### Cross-Bundle Access (for System Applications Only)
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci- Call **createModuleContext(bundleName, moduleName)** to obtain the context of the target HAP/HSP module in another application. Obtain a **ResourceManager** object through the context, and then call [resource management APIs](../reference/apis-localization-kit/js-apis-resource-manager.md) to access different resources.<br>Example: **getContext().createModuleContext(bundleName, moduleName).resourceManager.getStringByNameSync('test')**.
327e41f4b71Sopenharmony_ci<!--DelEnd-->
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci#### Inter-Bundle, Cross-Module Access
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci- Call **createModuleContext(moduleName)** to obtain the context of the target HAP/HSP module in the same application. Obtain a **ResourceManager** object through the context, and then call resource management APIs to access different resources.<br>Example: **getContext().createModuleContext(moduleName).resourceManager.getStringByNameSync('test')**.
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci- Use **$r** or **$rawfile** to reference resources. Specifically, perform either of the following:
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci  1. Use *[hsp].type.name*, where **hsp** indicates the HSP module name, **type** indicates the resource type, and **name** indicates the resource name. The following is an example:
336e41f4b71Sopenharmony_ci  
337e41f4b71Sopenharmony_ci    ```ts
338e41f4b71Sopenharmony_ci      Text($r('[hsp].string.test_string'))
339e41f4b71Sopenharmony_ci        .fontSize($r('[hsp].float.font_size'))
340e41f4b71Sopenharmony_ci        .fontColor($r('[hsp].color.font_color'))  
341e41f4b71Sopenharmony_ci      Image($rawfile('[hsp].icon.png'))
342e41f4b71Sopenharmony_ci    ```
343e41f4b71Sopenharmony_ci  2. Use variables. The following is an example:
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci   ```ts
346e41f4b71Sopenharmony_ci    @Entry
347e41f4b71Sopenharmony_ci    @Component
348e41f4b71Sopenharmony_ci    struct Index {
349e41f4b71Sopenharmony_ci      text: string = '[hsp].string.test_string';
350e41f4b71Sopenharmony_ci      fontSize: string = '[hsp].float.font_size';
351e41f4b71Sopenharmony_ci      fontColor: string = '[hsp].color.font_color';
352e41f4b71Sopenharmony_ci      image: string = '[hsp].media.string';
353e41f4b71Sopenharmony_ci      rawfile: string = '[hsp].icon.png';
354e41f4b71Sopenharmony_ci  
355e41f4b71Sopenharmony_ci      build() {
356e41f4b71Sopenharmony_ci        Row() {
357e41f4b71Sopenharmony_ci          Text($r(this.text))
358e41f4b71Sopenharmony_ci            .fontSize($r(this.fontSize))
359e41f4b71Sopenharmony_ci            .fontColor($r(this.fontColor))
360e41f4b71Sopenharmony_ci  
361e41f4b71Sopenharmony_ci          Image($r(this.image))
362e41f4b71Sopenharmony_ci  
363e41f4b71Sopenharmony_ci          Image($rawfile(this.rawfile))
364e41f4b71Sopenharmony_ci        }
365e41f4b71Sopenharmony_ci      }
366e41f4b71Sopenharmony_ci    }
367e41f4b71Sopenharmony_ci   ```
368e41f4b71Sopenharmony_ci  > **NOTE**
369e41f4b71Sopenharmony_ci  >
370e41f4b71Sopenharmony_ci  > The HSP module name must be placed in the brackets ([]). If the **rawfile** directory contains multiple levels of folders, the path must start from the first level, for example, **\$rawfile('[hsp].oneFile/twoFile/icon.png')**. When **$r** or **$rawfile** is used for cross-HSP resource access, resource verification is not available at compile time, and you need to manually check that the target resources exist in the corresponding location.
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci### System Resources
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ciApart from custom resources, you can use system resources to maintain a consistent visual style throughout your application. <!--Del-->For details about the system resource IDs and their values in different configurations, see [Resources](../../design/ux-design/design-resources.md).<!--DelEnd-->
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ciDuring development, the usage of layered parameters is basically the same as that of qualifiers. To reference a system resource, use the "$r('sys.type.resource_id')" format. Wherein: **sys** indicates a system resource; **type** indicates the resource type, which can be **color**, **float**, **string**, or **media**; **resource_id** indicates the resource ID.
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci> **NOTE**
379e41f4b71Sopenharmony_ci>
380e41f4b71Sopenharmony_ci> - The use of system resources is only supported in the declarative development paradigm.
381e41f4b71Sopenharmony_ci>
382e41f4b71Sopenharmony_ci> - For preset applications, you are advised to use system resources.<!--Del--> For third-party applications, you can choose to use system resources or custom application resources as required.<!--DelEnd-->
383e41f4b71Sopenharmony_ci>
384e41f4b71Sopenharmony_ci> - You can view the fonts for the system resources in the **system/etc/fontconfig.json** file. The default font is **'HarmonyOS Sans'**.
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ci```ts
387e41f4b71Sopenharmony_ciText('Hello')
388e41f4b71Sopenharmony_ci  .fontColor($r('sys.color.ohos_id_color_emphasize'))
389e41f4b71Sopenharmony_ci  .fontSize($r('sys.float.ohos_id_text_size_headline1'))
390e41f4b71Sopenharmony_ci  .fontFamily($r('sys.string.ohos_id_text_font_family_medium'))
391e41f4b71Sopenharmony_ci  .backgroundColor($r('sys.color.ohos_id_color_palette_aux1'))
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ciImage($r('sys.media.ohos_app_icon'))
394e41f4b71Sopenharmony_ci  .border({
395e41f4b71Sopenharmony_ci    color: $r('sys.color.ohos_id_color_palette_aux1'),
396e41f4b71Sopenharmony_ci    radius: $r('sys.float.ohos_id_corner_radius_button'), width: 2
397e41f4b71Sopenharmony_ci  })
398e41f4b71Sopenharmony_ci  .margin({
399e41f4b71Sopenharmony_ci    top: $r('sys.float.ohos_id_elements_margin_horizontal_m'),
400e41f4b71Sopenharmony_ci    bottom: $r('sys.float.ohos_id_elements_margin_horizontal_l')
401e41f4b71Sopenharmony_ci  })
402e41f4b71Sopenharmony_ci  .height(200)
403e41f4b71Sopenharmony_ci  .width(300)
404e41f4b71Sopenharmony_ci```
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_ci## Resource Matching
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ciWhen your application needs to use a resource, the system preferentially searches the qualifiers subdirectories that match the current device state. The system searches the **base** subdirectory for the target resource only when the **resources** directory does not contain any qualifiers subdirectories that match the current device state or the target resource is not found in the qualifiers subdirectories. The **rawfile** directory is not searched for resources.
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci### Rules for Matching Qualifiers Subdirectories and Device Resources
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci- Qualifiers are matched with the device resources in the following priorities: MCC&MNC > locale (options: language, language_script, language_country/region, and language_script_country/region) > screen orientation > device type > color mode > screen density
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci- If the qualifiers subdirectories contain the MCC, MNC, language, script, screen orientation, device type, and color mode qualifiers, their values must be consistent with the current device status so that the subdirectories can be used for matching the device resources. For example, the qualifiers subdirectory **zh_CN-car-ldpi** cannot be used for matching the resource files labeled **en_US**.
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci- If there are multiple qualifiers subdirectories for the screen density, the closest qualifiers are matched upwards; otherwise, downwards. For example, if qualifiers directories **xldpi** and **xxldpi** exist and the device screen density is **xxldpi**, the qualifier directory **xxldpi** will be matched.
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ciFor more information about how resources are loaded in applications, see the internationalization and localization documents.
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci### Obtaining Resources for a Specific Configuration
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci#### Background
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ciWhen using [qualifiers directories](#qualifiers-directory) to apply configuration-specific resources, you may find some resources fail to be obtained due to matching rules of the qualifiers directories.
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ciIf this is the case, you can use the following APIs to obtain resources for a specific configuration.
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ci#### Available APIs
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ci| API                                                      | Description                                                        |
431e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | ------------------------------------------------------------ |
432e41f4b71Sopenharmony_ci| [getOverrideResourceManager](../reference/apis-localization-kit/js-apis-resource-manager.md#getoverrideresourcemanager12)(configuration?: [Configuration](../reference/apis-localization-kit/js-apis-resource-manager.md#configuration)) : [ResourceManager](../reference/apis-localization-kit/js-apis-resource-manager.md#resourcemanager) | Obtains a **ResourceManager** object for loading resources for a specific configuration. This API returns the result synchronously.|
433e41f4b71Sopenharmony_ci| [getOverrideConfiguration](../reference/apis-localization-kit/js-apis-resource-manager.md#getoverrideconfiguration12)() : [Configuration](../reference/apis-localization-kit/js-apis-resource-manager.md#configuration) | Obtains the specified configuration. This API returns the result synchronously.                            |
434e41f4b71Sopenharmony_ci| [updateOverrideConfiguration](../reference/apis-localization-kit/js-apis-resource-manager.md#updateoverrideconfiguration12)(configuration: [Configuration](../reference/apis-localization-kit/js-apis-resource-manager.md#configuration)) : void | Updates the specified configuration.                                              |
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ci#### Example
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ciThe following example demonstrates how to obtain the resources for languages other than the one in use. Assume that the following resource files with the same name are defined in the **resources** directories for Chinese, English, and German:
439e41f4b71Sopenharmony_ci
440e41f4b71Sopenharmony_ci- entry/src/main/resources/zh_CN/element/string.json
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ci```json
443e41f4b71Sopenharmony_ci{
444e41f4b71Sopenharmony_ci  "string": [
445e41f4b71Sopenharmony_ci    {
446e41f4b71Sopenharmony_ci      "name": "greetings",
447e41f4b71Sopenharmony_ci      "value": "你好,世界"
448e41f4b71Sopenharmony_ci    }
449e41f4b71Sopenharmony_ci  ]
450e41f4b71Sopenharmony_ci}
451e41f4b71Sopenharmony_ci```
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_ci- entry/src/main/resources/en_US/element/string.json
454e41f4b71Sopenharmony_ci
455e41f4b71Sopenharmony_ci```json
456e41f4b71Sopenharmony_ci{
457e41f4b71Sopenharmony_ci  "string": [
458e41f4b71Sopenharmony_ci    {
459e41f4b71Sopenharmony_ci      "name": "greetings",
460e41f4b71Sopenharmony_ci      "value": "Hello, world"
461e41f4b71Sopenharmony_ci    }
462e41f4b71Sopenharmony_ci  ]
463e41f4b71Sopenharmony_ci}
464e41f4b71Sopenharmony_ci```
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_ci- entry/src/main/resources/de_DE/element/string.json
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci```json
469e41f4b71Sopenharmony_ci{
470e41f4b71Sopenharmony_ci  "string": [
471e41f4b71Sopenharmony_ci    {
472e41f4b71Sopenharmony_ci      "name": "greetings",
473e41f4b71Sopenharmony_ci      "value": "Hallo, Welt"
474e41f4b71Sopenharmony_ci    }
475e41f4b71Sopenharmony_ci  ]
476e41f4b71Sopenharmony_ci}
477e41f4b71Sopenharmony_ci```
478e41f4b71Sopenharmony_ci
479e41f4b71Sopenharmony_ciIn **Index.ets**, add code to obtain the resources of the three languages and display them in the text box. The current system language is Chinese. The following is sample code in **entry/src/main/ets/pages/Index.ets**:
480e41f4b71Sopenharmony_ci
481e41f4b71Sopenharmony_ci```ts
482e41f4b71Sopenharmony_ci@Entry
483e41f4b71Sopenharmony_ci@Component
484e41f4b71Sopenharmony_cistruct Index {
485e41f4b71Sopenharmony_ci  @State englishString: string = ""
486e41f4b71Sopenharmony_ci  @State germanString: string = ""
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_ci  getString(): string {
489e41f4b71Sopenharmony_ci    let resMgr = getContext().resourceManager
490e41f4b71Sopenharmony_ci    let resId = $r('app.string.greetings').id
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci    // Obtain resources that match the current system configuration, including the color mode and resolution, for the current system language.
493e41f4b71Sopenharmony_ci    let currentLanguageString = resMgr.getStringSync(resId)
494e41f4b71Sopenharmony_ci
495e41f4b71Sopenharmony_ci    // Obtain resources that match the current system configuration, including the color mode and resolution, for the English language.
496e41f4b71Sopenharmony_ci    let overrideConfig = resMgr.getOverrideConfiguration()
497e41f4b71Sopenharmony_ci    overrideConfig.locale = "en_US" // Set the language to English and locale to US.
498e41f4b71Sopenharmony_ci    let overrideResMgr = resMgr.getOverrideResourceManager(overrideConfig)
499e41f4b71Sopenharmony_ci    this.englishString = overrideResMgr.getStringSync(resId)
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ci    // Obtain resources that match the current system configuration, including the color mode and resolution, for the German language.
502e41f4b71Sopenharmony_ci    overrideConfig.locale = "de_DE" // Set the language to German and locale to DE.
503e41f4b71Sopenharmony_ci    overrideResMgr.updateOverrideConfiguration(overrideConfig) // Equivalent to resMgr.updateOverrideConfiguration(overrideConfig).
504e41f4b71Sopenharmony_ci    this.germanString = overrideResMgr.getStringSync(resId)
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci    return currentLanguageString
507e41f4b71Sopenharmony_ci  }
508e41f4b71Sopenharmony_ci
509e41f4b71Sopenharmony_ci  build() {
510e41f4b71Sopenharmony_ci    Row() {
511e41f4b71Sopenharmony_ci      Column() {
512e41f4b71Sopenharmony_ci        Text(this.getString())
513e41f4b71Sopenharmony_ci          .fontSize(50)
514e41f4b71Sopenharmony_ci          .fontWeight(FontWeight.Bold)
515e41f4b71Sopenharmony_ci        Text(this.englishString)
516e41f4b71Sopenharmony_ci          .fontSize(50)
517e41f4b71Sopenharmony_ci          .fontWeight(FontWeight.Bold)
518e41f4b71Sopenharmony_ci        Text(this.germanString)
519e41f4b71Sopenharmony_ci          .fontSize(50)
520e41f4b71Sopenharmony_ci          .fontWeight(FontWeight.Bold)
521e41f4b71Sopenharmony_ci      }
522e41f4b71Sopenharmony_ci      .width('100%')
523e41f4b71Sopenharmony_ci    }
524e41f4b71Sopenharmony_ci    .height('100%')
525e41f4b71Sopenharmony_ci  }
526e41f4b71Sopenharmony_ci}
527e41f4b71Sopenharmony_ci```
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci### Overlay Mechanism
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ciOverlay is a resource replacement mechanism. With overlay resource packages, you enable your application GUI to adapt to different styles of various brands and products, without having to repack your application HAPs. The overlay mechanism works in dynamic and static modes. Overlay resource packages contain only resource files, resource index files, and configuration files.
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ci- Using overlay in dynamic mode
534e41f4b71Sopenharmony_ci
535e41f4b71Sopenharmony_ci1. Place the overlay resource package in the target application installation path and install the package using **hdc install**. For example, for the com.example.overlay application, place the overlay resource package in **data/app/el1/bundle/public/com.example.overlay/**.
536e41f4b71Sopenharmony_ci
537e41f4b71Sopenharmony_ci2. The application uses [addResource(path)](../reference/apis-localization-kit/js-apis-resource-manager.md#addresource10) to load overlay resources and uses [removeResource(path)](../reference/apis-localization-kit/js-apis-resource-manager.md#removeresource10) to remove overlay resources. The path to an overlay resource consists of the application's sandbox root directory (obtained through **getContext().BundleCodeDir**) and the overlay resource package name. For example, **let path = getContext().bundleCodeDir + "Overlay resource package name"**, such as **/data/storage/el1/bundle/overlayResourcePackageName**.
538e41f4b71Sopenharmony_ci
539e41f4b71Sopenharmony_ci- Using overlay in static mode
540e41f4b71Sopenharmony_ci
541e41f4b71Sopenharmony_ciThe **module.json5** file in the inter-application overlay resource package supports the following fields:
542e41f4b71Sopenharmony_ci```{
543e41f4b71Sopenharmony_ci  "app":{
544e41f4b71Sopenharmony_ci    "bundleName": "com.example.myapplication.overlay",
545e41f4b71Sopenharmony_ci    "vendor" : "example",
546e41f4b71Sopenharmony_ci    "versinCode": "1000000",
547e41f4b71Sopenharmony_ci    "versionName": "1.0.0.1",
548e41f4b71Sopenharmony_ci    "icon": "$media:app_icon",
549e41f4b71Sopenharmony_ci    "label": "$string:app_name",
550e41f4b71Sopenharmony_ci  },
551e41f4b71Sopenharmony_ci  "module":{
552e41f4b71Sopenharmony_ci    "name": "entry_overlay_module_name",
553e41f4b71Sopenharmony_ci    "type": "shared",
554e41f4b71Sopenharmony_ci    "description": "$string:entry_overlay_desc",
555e41f4b71Sopenharmony_ci    "deviceTypes": [
556e41f4b71Sopenharmony_ci      "default",
557e41f4b71Sopenharmony_ci      "tablet",
558e41f4b71Sopenharmony_ci    ],
559e41f4b71Sopenharmony_ci    "deliverywithInstall": true,
560e41f4b71Sopenharmony_ci
561e41f4b71Sopenharmony_ci    "targetModuleName": "entry_module_name",
562e41f4b71Sopenharmony_ci    "targetPriority": 1,
563e41f4b71Sopenharmony_ci  }
564e41f4b71Sopenharmony_ci}
565e41f4b71Sopenharmony_ci```
566e41f4b71Sopenharmony_ci<!--Del-->
567e41f4b71Sopenharmony_ciThe **module.json5** file in the cross-application overlay resource package supports the following fields, which are available for system applications only:
568e41f4b71Sopenharmony_ci```{
569e41f4b71Sopenharmony_ci  "app":{
570e41f4b71Sopenharmony_ci    "bundleName": "com.example.myapplication.overlay",
571e41f4b71Sopenharmony_ci    "vendor" : "example",
572e41f4b71Sopenharmony_ci    "versinCode": "1000000",
573e41f4b71Sopenharmony_ci    "versionName": "1.0.0.1",
574e41f4b71Sopenharmony_ci    "icon": "$media:app_icon",
575e41f4b71Sopenharmony_ci    "label": "$string:app_name",
576e41f4b71Sopenharmony_ci    "targetBundleName": "com.example.myapplication",
577e41f4b71Sopenharmony_ci    "targetPariority": 1,
578e41f4b71Sopenharmony_ci  },
579e41f4b71Sopenharmony_ci  "module":{
580e41f4b71Sopenharmony_ci    "name": "entry_overlay_module_name",
581e41f4b71Sopenharmony_ci    "type": "shared",
582e41f4b71Sopenharmony_ci    "description": "$string:entry_overlay_desc",
583e41f4b71Sopenharmony_ci    "deviceTypes": [
584e41f4b71Sopenharmony_ci      "default",
585e41f4b71Sopenharmony_ci      "tablet",
586e41f4b71Sopenharmony_ci    ],
587e41f4b71Sopenharmony_ci    "deliverywithInstall": true,
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ci    "targetModuleName": "entry_module_name",
590e41f4b71Sopenharmony_ci    "targetPriority": 1,
591e41f4b71Sopenharmony_ci  }
592e41f4b71Sopenharmony_ci}
593e41f4b71Sopenharmony_ci```
594e41f4b71Sopenharmony_ci<!--DelEnd-->
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ci> **NOTE**
597e41f4b71Sopenharmony_ci> - **targetBundleName**: name of the target application to apply the overlay feature. The value is a string.
598e41f4b71Sopenharmony_ci>
599e41f4b71Sopenharmony_ci> - **targetModuleName**: name of the target module to apply the overlay feature. The value is a string.
600e41f4b71Sopenharmony_ci>
601e41f4b71Sopenharmony_ci> - **targetPriority**: overlay priority. The value is an integer.
602e41f4b71Sopenharmony_ci>
603e41f4b71Sopenharmony_ci> - Other fields such as **Ability**, **ExtensionAbility**, and **Permission** are not supported.
604e41f4b71Sopenharmony_ci>
605e41f4b71Sopenharmony_ci> - The overlay feature does not support JSON images.
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ciIf the **module.json5** file of a module contains the **targetModuleName** and **targetPriority** fields during project creation on DevEco Studio, the module is identified as a module with the overlay feature in the installation phase. Modules with the overlay feature generally provide an overlay resource file for other modules on the device, so that the module specified by **targetModuleName** can display different colors, labels, themes, and the like by using the overlay resource file in a running phase.
608e41f4b71Sopenharmony_ci
609e41f4b71Sopenharmony_ciThe overlay feature is enabled by default. For details about how to enable and disable this feature, see [@ohos.bundle.overlay (overlay)](../reference/apis-ability-kit/js-apis-overlay.md).
610e41f4b71Sopenharmony_ci
611e41f4b71Sopenharmony_ci<!--no_check-->