1.0.2 • Published 1 year ago

@mbardakov/localize-names v1.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

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:

{
    prefix: string, // optional
    givenName: string, // optional
    middleName: string, // optional
    surname: string, // optional
    suffix: string, // optional
}

and the locale is one of:

'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:

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);

> '张明'
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago