# @mbardakov/localize-names

> Localize order of Given Name, Surname, Prefixes, Suffixes, etc.

Latest version **1.0.2** (published 2022-11-29) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @mbardakov/localize-names
pnpm add @mbardakov/localize-names
yarn add @mbardakov/localize-names
bun add @mbardakov/localize-names
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-11-29 |
| First published | 2022-11-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | mbardakovD2L |
| Maintainers | mbardakov |

## Links

- npm: https://www.npmjs.com/package/@mbardakov/localize-names
- Repository: https://github.com/mbardakovD2L/localize-names
- Homepage: https://github.com/mbardakovD2L/localize-names#readme
- Issues: https://github.com/mbardakovD2L/localize-names/issues
- npm.io page: https://npm.io/package/@mbardakov/localize-names

## Recent versions

- 1.0.2 (latest) — 2022-11-29
- 1.0.1 — 2022-11-28
- 1.0.0 — 2022-11-24

## README

# localize-names
Localize order of Given Name, Surname, Prefixes, Suffixes, etc. based on the given locale. Resulting name string will be ordered and formatted accordingly.

## Usage

Call `localizeName` with a name object and a locale, where a name object consists of any combination of the following:
```js
{
    prefix: string, // optional
    givenName: string, // optional
    middleName: string, // optional
    surname: string, // optional
    suffix: string, // optional
}
```
and the locale is one of:
```js
'ar-sa',
'cy-gb',
'da-dk',
'de-de',
'en',
'en-ca',
'en-gb',
'en-us',
'es-es',
'es-mx',
'fr-ca',
'fr-fr',
'hi-in',
'ja-jp',
'ko-kr',
'nl-nl',
'pt-br',
'sv-se',
'tr-tr',
'zh-cn',
'zh-tw'
```
for example:
```js
import { localizeName } from '@mbardakov/localize-names';

const nameString = localizeName({
    suffix: 'PhD',
    surname: 'Ham',
    prefix: 'Dr.',
    givenName: 'Harry',
}, 'en-us');
console.log(nameString);

> 'Dr. Harry Ham, PhD'



const nameString2 = localizeName({
    givenName: '明',
    surname: '张'
}, 'zh-cn');
console.log(nameString2);

> '张明'

```

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