-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(i18n-ptBR): 🔥 add first, last and full name randomizer
- Loading branch information
1 parent
68dbb27
commit 62e92a8
Showing
6 changed files
with
177 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { NameOptions } from '../../full-name'; | ||
import { randFirstName as randFirstNameDefault } from '../../first-name'; | ||
import { data as locale } from './first-name.i18n.json'; | ||
|
||
/** | ||
* Generate a random first name. | ||
* | ||
* @category person | ||
* | ||
* @example | ||
* | ||
* randFirstName() | ||
* | ||
* @example | ||
* | ||
* randFirstName({ withAccents: true }) | ||
* | ||
* @example | ||
* | ||
* randFirstName({ gender: 'female' }) // Emma | ||
* | ||
* @example | ||
* | ||
* randFirstName({ length: 10 }) | ||
* | ||
*/ | ||
export function randFirstName<Options extends NameOptions = never>( | ||
options?: Options | ||
) { | ||
const _options = { | ||
...options, | ||
locale, | ||
}; | ||
|
||
return randFirstNameDefault(_options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { fake } from '../../core/core'; | ||
import { randFirstName } from '../../first-name'; | ||
import { NameOptions } from '../../full-name'; | ||
import { randLastName } from '../../last-name'; | ||
|
||
import { data as localeFirstName } from './first-name.i18n.json'; | ||
import { data as localeLastName } from './last-name.i18n.json'; | ||
|
||
/** | ||
* Generate a random full name. | ||
* | ||
* @category person | ||
* | ||
* @example | ||
* | ||
* randFullName() | ||
* | ||
* @example | ||
* | ||
* randFullName({ gender: 'female' }) // Emma Marková | ||
* | ||
* @example | ||
* | ||
* randFullName({ withAccents: false }) // return full name without special symbols like â, î or ô and etc | ||
* | ||
* @example | ||
* | ||
* randFullName({ length: 10 }) | ||
* | ||
*/ | ||
export function randFullName<Options extends NameOptions = never>( | ||
options?: Options | ||
) { | ||
const nameOptions = { | ||
withAccents: options?.withAccents, | ||
gender: options?.gender, | ||
}; | ||
|
||
const firstName = randFirstName({ | ||
...nameOptions, | ||
locale: localeFirstName, | ||
}); | ||
|
||
const lastName = randLastName({ | ||
...nameOptions, | ||
locale: localeLastName, | ||
}); | ||
|
||
return fake(() => `${firstName} ${lastName}`, options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { NameOptions } from '../../full-name'; | ||
import { randLastName as randLastNameDefault } from '../../last-name'; | ||
import { data as locale } from './last-name.i18n.json'; | ||
|
||
/** | ||
* Generate a random last name. | ||
* | ||
* @category person | ||
* | ||
* @example | ||
* | ||
* randLastName() | ||
* | ||
* @example | ||
* | ||
* randLastName({ withAccents: false }) | ||
* | ||
* @example | ||
* | ||
* randLastName({ length: 10 }) | ||
* | ||
*/ | ||
export function randLastName<Options extends NameOptions = never>( | ||
options?: Options | ||
) { | ||
const _options = { | ||
...options, | ||
locale, | ||
}; | ||
|
||
return randLastNameDefault(_options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters