# @daai/i18n

> Javascript i18n core

Latest version **1.0.5** (published 2025-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @daai/i18n
pnpm add @daai/i18n
yarn add @daai/i18n
bun add @daai/i18n
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2025-06-06 |
| First published | 2020-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 41 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | daai |
| Maintainers | daai |
| Keywords | Javascript i18n |

## Links

- npm: https://www.npmjs.com/package/@daai/i18n
- npm.io page: https://npm.io/package/@daai/i18n

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2025-06-06
- 1.0.4 — 2022-05-05
- 1.0.3 — 2021-05-05
- 1.0.2 — 2021-05-05
- 1.0.1 — 2020-11-13
- 1.0.0 — 2020-10-30

## README

# i18n

## Installation
```html
...
<head>
<script type="text/javascript" src="i18n.min.js"></script>
</head>
...
```

## Configure
```javascript
i18n.set({
  'lang': '"ISO639-1-ISO3166-1" language code', //e.g. en-us, zh-tw. Default is auto detect from browser.
  'path': 'language file\'s path' // Default is empty (same level as i18n.js)
});
```
## Usage
```javascript

var s = i18n.t('LANGUAGE ID');
var s = i18n.datetime();
var s = i18n.datetime('Date time');

```
## Language file
### File contents in JSON format
```json
{
    "setting": {
        "DST": 8,
        "format": "Y 年 m 月 d 日 (l) H:i:s",
        "AM": "上午",
        "PM": "下午"
    },
    "shortMonths": ["1 月", "2 月", "3 月", "4 月", "5 月", "6 月", "7 月", "8 月", "9 月", "10 月", "11 月", "12 月"],
    "longMonths": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
    "shortDays": ["日", "一", "二", "三", "四", "五", "六"],
    "longDays": ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],

    "Hello World": "世界您好！",
    "Hello %1, Nice to meet you": "你好 %1, 很高興認識您",
    "KEY": {
        "ID": "........"
    }
}
```
### Filename rule
Filename must be same as language code. e.g. `zh-tw.js`, `zh-cn.js`...

## Examples
### String
```javascript
// Use above JSON content.

// String without variables.
i18n.t('Hellow World');
// return 您好世界！

// String with variables.
i18n.t('Hello %1, Nice to meet you', 'John');
// return 你好 John, 很高興認識你

i18n.t('KEY.ID');
i18n.t('KEY.ID', 'hello');
// Nested
```
### Date time
```javascript
i18n.datetime();
// return Current datetime

i18n.datetime('2020-10-30 12:00:00');
// return '2020 年 10 月 30 日 12:00:00' datetime format.
```
## License
i18n was release under [MIT License](http://opensource.org/licenses/MIT).

---
_Source: https://npm.io/package/@daai/i18n · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
