# langcode-info

> Lightweight module to get language info by: code, hex code or decimal code;

Latest version **1.1.4** (published 2023-03-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install langcode-info
pnpm add langcode-info
yarn add langcode-info
bun add langcode-info
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2023-03-07 |
| First published | 2020-12-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 160.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Yohanson555 |
| Maintainers | yohanson555 |
| Keywords | language, lang, js, node, code |

## Links

- npm: https://www.npmjs.com/package/langcode-info
- Repository: https://github.com/Yohanson555/langcode-info
- Homepage: https://github.com/Yohanson555/langcode-info#readme
- Issues: https://github.com/Yohanson555/langcode-info/issues
- npm.io page: https://npm.io/package/langcode-info

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.4 (latest) — 2023-03-07
- 1.1.3 — 2023-02-05
- 1.1.2 — 2023-02-05
- 1.1.1 — 2022-07-12
- 1.1.0 — 2022-07-12
- 1.0.4 — 2020-12-16
- 1.0.3 — 2020-12-16
- 1.0.2 — 2020-12-15
- 1.0.1 — 2020-12-15
- 1.0.0 — 2020-12-15

## README

## Overview

Lightweight module to get language info by: code, hex code or decimal code;

Also allows to receive all know languages as an array, a map, or a hex codes list;

## Methods

All methods of `LangInform` are static and can be called directly.

- `LangInform.langByCode(code)` - returns `Lang` object for language by it's code(string expected). Watch examples section for use cases.

- `LangInform.langByHex(code)` - returns `Lang` object for language by it's hex code (string expected). Watch examples section for use cases.

- `LangInform.langByDec(code)` - returns `Lang` object for language by it's decimal code(string or number expected). Watch examples section for use cases.

- `LangInform.list()` - returns all known languages as an array of pure objects (not a Lang objects).

- `LangInform.map()` - returns all known languages as an map of pure objects (not a Lang objects), where key is a hex code of language.

- `LangInform.codes()` - returns all known hex codes as an array


## `Lang` object methods

- `Lang.name()` - returns language short name as a `string`;
- `Lang.fullName()` - returns language full name as a `string`;
- `Lang.code()` - returns language code as a `string`;
- `Lang.hex()` - returns language hex code as a `string`;
- `Lang.dec()` - returns language decimal code as a `string`;
- `Lang.locale()` - returns language locale as a `string`;

## Examples

`LangInform.langByCode()` method exampels: 

```js
    LangInform.langByCode("es-US").name(); //"Spanish"
    LangInform.langByCode("es-US").code(); //"es-US"
    LangInform.langByCode("es-US").fullName(); //"Spanish – United States"
    LangInform.langByCode("es-US").hex(); //"540A"
    LangInform.langByCode("es-US").dec(); //"21514"
    LangInform.langByCode("es-US").locale(); //"es"
```

`LangInform.` method examples:

```js
    LangInform.langByHex("540A").name(); //"Spanish"
    LangInform.langByHex("540A").code(); //"es-US"
    LangInform.langByHex("540A").fullName(); //"Spanish – United States"
    LangInform.langByHex("540A").hex(); //"540A"
    LangInform.langByHex("540A").dec(); //"21514"
    LangInform.langByHex("540A").locale(); //"es"
```

`LangInform.` method examples:

```js
    LangInform.langByDec("21514").name(); //"Spanish"
    LangInform.langByDec(21514).code(); //"es-US"
    LangInform.langByDec("21514").fullName(); //"Spanish – United States"
    LangInform.langByDec(21514).hex(); //"540A"
    LangInform.langByDec("21514").dec(); //"21514"
    LangInform.langByDec(21514).locale(); //"es"
```

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