# locale-parser

> YAML based localization system

Latest version **1.1.3** (published 2022-07-23) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install locale-parser
pnpm add locale-parser
yarn add locale-parser
bun add locale-parser
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2022-07-23 |
| First published | 2020-08-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 38.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Barış Demirci |
| Maintainers | leydihavuc |
| Keywords | language, i18n, locale, parser, locales, handler, localization |

## Links

- npm: https://www.npmjs.com/package/locale-parser
- Repository: https://github.com/barbarbar338/locale-parser
- Homepage: https://github.com/barbarbar338/locale-parser#readme
- Issues: https://github.com/barbarbar338/locale-parser/issues
- npm.io page: https://npm.io/package/locale-parser

## Dependencies (1)

- [yaml](https://npm.io/package/yaml.md) ^1.10.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2022-07-23
- 1.1.2 — 2020-11-01
- 1.1.1 — 2020-11-01
- 1.1.0 — 2020-10-16
- 1.0.3 — 2020-09-20
- 1.0.2 — 2020-08-24
- 1.0.1 — 2020-08-24
- 1.0.0 — 2020-08-22

## README

> DEPRECATED: Use @hammerhq/localization
>
> ~barbarbar338

# ✨ Locale Parser by barbarbar338
- This is a YAML based localisation system that will make your job quite easy
- Just create your language folder and seperate everything in files
- Set your constants in `constants.yaml` and apply to everything

# 💡 Example
```js
import { I18n } from "locale-parser";

/*
    options:
        directory?: string;
        defaultLocale: string;
*/
const parser = new I18n({ 
    defaultLocale: "en" 
});

parser.getLocales(); // => [ "en", "tr" ];
parser.getConstant(); // => all constants;
parser.getConstant("owner"); // => "owner" constant;
parser.toJSON(); // => all language data in an object
parser.toJSON({ arg: "this is an argument"}); // => all language data in an object with argument replaced

parser.get("en", "info", "test"); // "test" string in "info" section in "en" folder
parser.get("tr", "messages", "message", { arg: "this is an argument"}); // "message" string in "messages" section in "tr" folder with "arg" argument
```

# 📝 File Structure

### `locales/constants.yaml` example
```yaml
owner: barbarbar338
site: "https://barbarbar338.fly.dev/"
anotherConstant: this is a constant
```

### `locales/{locale}/{section}.yaml` example
```yaml
withConstant: this string uses %{owner} constant
withArgs: this string uses %{argument} argument and %{anotherArgument} argument
withConstantsAndArguments: this string uses %{simpleArgument} argument and %{site} constant
```

# 📁 Folder Structure
```
📂 locales/
├─── 📝 constants.yaml
├─── 📂 en
│    ├─── 📝 info.yaml
│    ├─── 📝 messages.yaml
│    └─── 📝 test.yaml
└─── 📂 tr
     ├─── 📝 info.yaml
     ├─── 📝 messages.yaml
     └─── 📝 test.yaml

```

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