xref: /base/global/i18n/README.md (revision 9596a2c1)
19596a2c1Sopenharmony_ci# i18n<a name="EN-US_TOPIC_0000001101364976"></a>
29596a2c1Sopenharmony_ci
39596a2c1Sopenharmony_ci-   [Introduction](#section11660541593)
49596a2c1Sopenharmony_ci-   [Directory Structure](#section1464106163817)
59596a2c1Sopenharmony_ci-   [Constraints](#section1718733212019)
69596a2c1Sopenharmony_ci-   [Usage](#section894511013511)
79596a2c1Sopenharmony_ci-   [Repositories Involved](#section15583142420413)
89596a2c1Sopenharmony_ci
99596a2c1Sopenharmony_ci## Introduction<a name="section11660541593"></a>
109596a2c1Sopenharmony_ci
119596a2c1Sopenharmony_ciThe i18n module provides a wide array of internationalization \(i18n\) APIs for implementing functions such as date and time formatting.
129596a2c1Sopenharmony_ci
139596a2c1Sopenharmony_ci## Directory Structure<a name="section1464106163817"></a>
149596a2c1Sopenharmony_ci
159596a2c1Sopenharmony_ciThe directory structure for the i18n module is as follows:
169596a2c1Sopenharmony_ci
179596a2c1Sopenharmony_ci```
189596a2c1Sopenharmony_ci/base/global/
199596a2c1Sopenharmony_ci├── i18n                    # Code repository for the i18n framework
209596a2c1Sopenharmony_ci│   ├── frameworks          # Core code of the i18n framework
219596a2c1Sopenharmony_ci│   ├── interfaces          # APIs
229596a2c1Sopenharmony_ci│   │   ├── js              # JavaScript APIs
239596a2c1Sopenharmony_ci│   │   └── native          # Native APIs
249596a2c1Sopenharmony_ci```
259596a2c1Sopenharmony_ci
269596a2c1Sopenharmony_ci## Constraints<a name="section1718733212019"></a>
279596a2c1Sopenharmony_ci
289596a2c1Sopenharmony_ci**Development language**: JavaScript
299596a2c1Sopenharmony_ci
309596a2c1Sopenharmony_ci**Language, script, and country codes**: The supported language must be represented by a two- or three-letter code defined in the ISO 639 standard; the supported script must be represented by a four-letter code defined in the ISO 15924 standard; the supported country must be represented by a two-letter code defined in the ISO 3166 standard.
319596a2c1Sopenharmony_ci
329596a2c1Sopenharmony_ci## Usage<a name="section894511013511"></a>
339596a2c1Sopenharmony_ci
349596a2c1Sopenharmony_ciChange the date and time formats \(such as the sequence of year, month, and day, month and week names, and 12-hour or 24-hour system\) following the system settings to adapt to the cultural habits of users in different locales. For details, see the API reference. The sample code is as follows:
359596a2c1Sopenharmony_ci
369596a2c1Sopenharmony_ci```
379596a2c1Sopenharmony_ciconst date = new Date(2021, 11, 17, 3, 24, 0); // Create a Date object containing date and time information.
389596a2c1Sopenharmony_cifmt = new Intl.DateTimeFormat('en-US') // Create a DateTimeFormat instance.
399596a2c1Sopenharmony_ciconsole.log(fmt.format(date)); // Format the date and time by using the DateTimeFormat instance.
409596a2c1Sopenharmony_ci```
419596a2c1Sopenharmony_ci
429596a2c1Sopenharmony_ci## Repositories Involved<a name="section15583142420413"></a>
439596a2c1Sopenharmony_ci
449596a2c1Sopenharmony_ciGlobalization subsystem
459596a2c1Sopenharmony_ci
469596a2c1Sopenharmony_ci**global\_i18n\_standard**
479596a2c1Sopenharmony_ci
489596a2c1Sopenharmony_ciglobal\_resmgr\_standard
499596a2c1Sopenharmony_ci
50