From 2690931bf881195aa139ddee46f8feba25d0b557 Mon Sep 17 00:00:00 2001 From: kabrunko-dev Date: Wed, 13 Dec 2023 23:55:25 -0300 Subject: [PATCH 1/4] =?UTF-8?q?feat(i18n):=20=F0=9F=94=A5=20add=20new=20la?= =?UTF-8?q?nguage=20support=20for=20pt-BR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add birds, first name, last name and full name --- .../falso/src/lib/i18n/pt-br/bird.i18n.json | 28 ++ packages/falso/src/lib/i18n/pt-br/bird.ts | 22 + .../src/lib/i18n/pt-br/first-name.i18n.json | 383 ++++++++++++++++++ .../falso/src/lib/i18n/pt-br/first-name.ts | 45 ++ .../falso/src/lib/i18n/pt-br/full-name.ts | 44 ++ packages/falso/src/lib/i18n/pt-br/index.ts | 4 + .../src/lib/i18n/pt-br/last-name.i18n.json | 228 +++++++++++ .../falso/src/lib/i18n/pt-br/last-name.ts | 31 ++ 8 files changed, 785 insertions(+) create mode 100644 packages/falso/src/lib/i18n/pt-br/bird.i18n.json create mode 100644 packages/falso/src/lib/i18n/pt-br/bird.ts create mode 100644 packages/falso/src/lib/i18n/pt-br/first-name.i18n.json create mode 100644 packages/falso/src/lib/i18n/pt-br/first-name.ts create mode 100644 packages/falso/src/lib/i18n/pt-br/full-name.ts create mode 100644 packages/falso/src/lib/i18n/pt-br/index.ts create mode 100644 packages/falso/src/lib/i18n/pt-br/last-name.i18n.json create mode 100644 packages/falso/src/lib/i18n/pt-br/last-name.ts diff --git a/packages/falso/src/lib/i18n/pt-br/bird.i18n.json b/packages/falso/src/lib/i18n/pt-br/bird.i18n.json new file mode 100644 index 00000000..566dc387 --- /dev/null +++ b/packages/falso/src/lib/i18n/pt-br/bird.i18n.json @@ -0,0 +1,28 @@ +{ + "data": [ + "Arara Azul", + "Arara-vermelha", + "Ararinha-azul", + "Calopsita", + "Canário", + "Beija-flor", + "Bem-te-vi", + "Coruja", + "Corrupião", + "Curió", + "Ema", + "Falcão", + "Garça", + "João-de-barro", + "Papagaio", + "Pardal", + "Periquito", + "Pomba", + "Quero-quero", + "Rolinha", + "Sabiá", + "Tucano", + "Tuiuiú", + "Urubu" + ] +} diff --git a/packages/falso/src/lib/i18n/pt-br/bird.ts b/packages/falso/src/lib/i18n/pt-br/bird.ts new file mode 100644 index 00000000..df834015 --- /dev/null +++ b/packages/falso/src/lib/i18n/pt-br/bird.ts @@ -0,0 +1,22 @@ +import { FakeOptions, fake } from '../../core/core'; +import { data } from './bird.i18n.json'; + +/** + * Generate a random bird. + * + * @category animals + * + * @example + * + * randBird() + * + * @example + * + * randBird({ length: 10 }) + * + */ +export function randBird( + options?: Options +) { + return fake(data, options); +} diff --git a/packages/falso/src/lib/i18n/pt-br/first-name.i18n.json b/packages/falso/src/lib/i18n/pt-br/first-name.i18n.json new file mode 100644 index 00000000..043ead52 --- /dev/null +++ b/packages/falso/src/lib/i18n/pt-br/first-name.i18n.json @@ -0,0 +1,383 @@ +{ + "data": { + "withAccents": { + "male": [ + "Antônio", + "Benício", + "Cauã", + "César", + "Fábio", + "Félix", + "Hélio", + "João", + "Júlio", + "Théo" + ], + "female": [ + "Aléxia", + "Alícia", + "Amália", + "Amélia", + "Ângela", + "Angélica", + "Antónia", + "Bárbara", + "Cátia", + "Cecília", + "Célia", + "Cíntia", + "Cláudia", + "Débora", + "Emília", + "Érica", + "Fabrícia", + "Felícia", + "Flávia", + "Fátima", + "Glória", + "Heloísa", + "Inês", + "Irís", + "Janaína", + "Jéssica", + "Júlia", + "Laís", + "Letícia", + "Lídia", + "Lígia", + "Lília", + "Lívia", + "Lúcia", + "Luísa", + "Maitê", + "Márcia", + "Mônica", + "Nádia", + "Natália", + "Nídia", + "Núbia", + "Ofélia", + "Olívia", + "Patrícia", + "Penélope", + "Pérola", + "Suélen", + "Suéli", + "Sílvia", + "Sónia", + "Tâmara", + "Taís", + "Taísa", + "Taíssa", + "Thaís", + "Tânia", + "Valéria", + "Vânia", + "Verônica", + "Vitória" + ] + }, + "withoutAccents": { + "male": [ + "Alessandro", + "Alexandre", + "Anthony", + "Arthur", + "Benjamin", + "Bernardo", + "Breno", + "Bruno", + "Caetano", + "Caio", + "Carlos", + "Daniel", + "Danilo", + "Davi", + "Eduardo", + "Emanuel", + "Enzo", + "Fabiano", + "Fabrício", + "Felipe", + "Frederico", + "Gabriel", + "Guilherme", + "Gustavo", + "Heitor", + "Henrique", + "Hugo", + "Igor", + "Isaac", + "Isaque", + "Joaquim", + "Kleber", + "Leonardo", + "Lorenzo", + "Lucas", + "Lucca", + "Marcelo", + "Marcos", + "Matheus", + "Miguel", + "Murilo", + "Nataniel", + "Nicolas", + "Pablo", + "Paulo", + "Pedro", + "Pietro", + "Rafael", + "Raul", + "Ricardo", + "Roberto", + "Salvador", + "Vicente", + "Vitor", + "Washington", + "Yago", + "Yuri" + ], + "female": [ + "Abigail", + "Adelaide", + "Adelina", + "Adriana", + "Aisha", + "Alana", + "Alessandra", + "Alexa", + "Alexandra", + "Alexia", + "Alice", + "Alicia", + "Aline", + "Alissa", + "Alma", + "Amanda", + "Ana", + "Anabela", + "Andreia", + "Angelina", + "Anita", + "Anna", + "Antonella", + "Ariana", + "Ariane", + "Ariele", + "Aura", + "Aurora", + "Beatriz", + "Benedita", + "Bianca", + "Brenda", + "Briana", + "Bruna", + "Caetana", + "Camila", + "Carina", + "Carla", + "Carlota", + "Carmen", + "Carol", + "Carolina", + "Caroline", + "Catarina", + "Chiara", + "Clara", + "Clarisse", + "Constança", + "Cristiana", + "Cristina", + "Dalila", + "Daniela", + "Dayane", + "Deise", + "Denise", + "Diana", + "Dora", + "Doriana", + "Eduarda", + "Elena", + "Eliana", + "Eliane", + "Elisa", + "Ellen", + "Elsa", + "Emanuelly", + "Emily", + "Erica", + "Erika", + "Esmeralda", + "Estela", + "Ester", + "Esther", + "Eunice", + "Eva", + "Fabiana", + "Filipa", + "Francisca", + "Frederica", + "Gabriela", + "Giovana", + "Giovanna", + "Graça", + "Helena", + "Hellen", + "Iara", + "Irene", + "Irina", + "Iris", + "Isa", + "Isabel", + "Isabela", + "Isabelly", + "Isadora", + "Isaura", + "Isis", + "Jacinta", + "Jacira", + "Jade", + "Jennifer", + "Jessica", + "Joana", + "Josiane", + "Joyce", + "Juliana", + "Julieta", + "Jussara", + "Karina", + "Karla", + "Kayla", + "Kelly", + "Kiara", + "Lais", + "Lara", + "Larissa", + "Laura", + "Leandra", + "Leila", + "Leticia", + "Lia", + "Liana", + "Liane", + "Liara", + "Liliana", + "Lina", + "Lisandra", + "Liz", + "Lorena", + "Lorraine", + "Lua", + "Luana", + "Luciana", + "Luena", + "Luisa", + "Luiza", + "Luna", + "Luz", + "Madalena", + "Mafalda", + "Maiara", + "Maira", + "Manuela", + "Marcela", + "Margarida", + "Maria", + "Mariana", + "Marina", + "Marisa", + "Marli", + "Marta", + "Martina", + "Matilde", + "Maura", + "Maya", + "Mayara", + "Mayra", + "Maísa", + "Meire", + "Melanie", + "Melina", + "Melissa", + "Mercedes", + "Mia", + "Micaela", + "Michele", + "Mila", + "Milana", + "Milena", + "Miranda", + "Miriam", + "Mirian", + "Morgana", + "Naiara", + "Nair", + "Nancy", + "Naomi", + "Nara", + "Natacha", + "Nayara", + "Neuza", + "Nicole", + "Nina", + "Noemi", + "Oriana", + "Paloma", + "Paula", + "Petra", + "Priscila", + "Rafaela", + "Rafaella", + "Raissa", + "Raquel", + "Rayanne", + "Rayssa", + "Rebeca", + "Rebecca", + "Renata", + "Riana", + "Rita", + "Roberta", + "Rosa", + "Rute", + "Sabrina", + "Safira", + "Samanta", + "Samara", + "Samira", + "Samuel", + "Sandra", + "Sara", + "Sarah", + "Sarah", + "Serena", + "Silas", + "Simara", + "Simone", + "Sofia", + "Solange", + "Sophia", + "Soraia", + "Stella", + "Stephanie", + "Susana", + "Talita", + "Tamara", + "Tatiana", + "Telma", + "Teresa", + "Tiffany", + "Valentina", + "Vanessa", + "Vera", + "Victoria", + "Violeta", + "Viviana", + "Viviane", + "Yara", + "Yasmin", + "Yohanna" + ] + } + } +} diff --git a/packages/falso/src/lib/i18n/pt-br/first-name.ts b/packages/falso/src/lib/i18n/pt-br/first-name.ts new file mode 100644 index 00000000..f6b64347 --- /dev/null +++ b/packages/falso/src/lib/i18n/pt-br/first-name.ts @@ -0,0 +1,45 @@ +// import { fake } from '../core/core'; +import { fake } from '../../core/core'; +import { NameOptions } from '../../full-name'; +import { rand } from '../../rand'; +import { data } 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?: Options +) { + const withAccents = options?.withAccents ?? false; + const gender = options?.gender ?? rand(['male', 'female']); + const locale = options?.locale; + + const names: string[] = withAccents + ? locale + ? locale?.withAccents[gender] + : data.withAccents[gender] + : locale + ? locale?.withoutAccents[gender] + : data.withoutAccents[gender]; + + return fake(names, options); +} diff --git a/packages/falso/src/lib/i18n/pt-br/full-name.ts b/packages/falso/src/lib/i18n/pt-br/full-name.ts new file mode 100644 index 00000000..d34f829e --- /dev/null +++ b/packages/falso/src/lib/i18n/pt-br/full-name.ts @@ -0,0 +1,44 @@ +import { FakeOptions, fake } from '../../core/core'; +import { randLastName } from './last-name'; +import { randFirstName } from './first-name'; + +export interface NameOptions extends FakeOptions { + withAccents?: boolean; + gender?: 'male' | 'female'; +} + +/** + * 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?: Options +) { + const nameOptions = { + withAccents: options?.withAccents, + gender: options?.gender, + }; + + return fake( + () => `${randFirstName(nameOptions)} ${randLastName(nameOptions)}`, + options + ); +} diff --git a/packages/falso/src/lib/i18n/pt-br/index.ts b/packages/falso/src/lib/i18n/pt-br/index.ts new file mode 100644 index 00000000..859ec5f9 --- /dev/null +++ b/packages/falso/src/lib/i18n/pt-br/index.ts @@ -0,0 +1,4 @@ +export { randBird } from './bird'; +export { randFirstName } from './first-name'; +export { randLastName } from './last-name'; +export { randFullName } from './full-name'; diff --git a/packages/falso/src/lib/i18n/pt-br/last-name.i18n.json b/packages/falso/src/lib/i18n/pt-br/last-name.i18n.json new file mode 100644 index 00000000..6a6e0d73 --- /dev/null +++ b/packages/falso/src/lib/i18n/pt-br/last-name.i18n.json @@ -0,0 +1,228 @@ +{ + "data": { + "withAccents": [ + "Apolinário", + "Aragão", + "Araújo", + "Assunção", + "Ávila", + "Belém", + "Conceição", + "Custódio", + "Córdoba", + "Cortês", + "Damásio", + "da Conceição", + "Dinís", + "D'Ávila", + "Guimarães", + "Góis", + "Hilário", + "Hipólito", + "Jordão", + "Magalhães", + "Nóbrega" + ], + "withoutAccents": [ + "Agostinho", + "Aguiar", + "Albuquerque", + "Albuquerque", + "Alegria", + "Alencastro", + "Almada", + "Almeida", + "Alves", + "Alves", + "Alvim", + "Amorim", + "Andrade", + "Antunes", + "Arruda", + "Assis", + "Baptista", + "Barbosa", + "Barreto", + "Barros", + "Barros", + "Barros", + "Batista", + "Beira-Mar", + "Belchior", + "Bernardes", + "Bittencourt", + "Boaventura", + "Bonfim", + "Botelho", + "Braga", + "Brites", + "Brito", + "Caetano", + "Caldeira", + "Camacho", + "Camilo", + "Campos", + "Capelo", + "Cardoso", + "Carvalho", + "Castro", + "Castro", + "Cavalcante", + "Cavalcanti", + "Chaves", + "Corte Real", + "Costa", + "Costa", + "Coutinho", + "Crespo", + "Cunha", + "Curado", + "Dantas", + "da Costa", + "da Cruz", + "da Cunha", + "da Luz", + "da Mata", + "da Mota", + "da Paz", + "da Rocha", + "da Rosa", + "das Neves", + "Dias", + "Dias", + "Domingues", + "dos Reis", + "Drummond", + "Duarte", + "Escobar", + "Espinosa", + "Esteves", + "Evangelista", + "Farias", + "Fernandes", + "Ferrari", + "Ferreira", + "Figueiredo", + "Figueiroa", + "Flores", + "Fogaça", + "Franco", + "Freitas", + "Furtado", + "Garcia", + "Gaspar", + "Gentil", + "Geraldes", + "Gil", + "Godinho", + "Gomes", + "Gonzaga", + "Gonçalves", + "Goulart", + "Gouveia", + "Guedes", + "Hernandes", + "Ilha", + "Infante", + "Jaques", + "Jesus", + "Lacerda", + "Lessa", + "Lima", + "Lopes", + "Macedo", + "Machado", + "Maciel", + "Maia", + "Maldonado", + "Marinho", + "Marques", + "Martins", + "Medeiros", + "Meireles", + "Mello", + "Melo", + "Mendes", + "Menezes", + "Mesquita", + "Modesto", + "Monteiro", + "Moraes", + "Morais", + "Moreira", + "Morgado", + "Moura", + "Muniz", + "Nascimento", + "Neves", + "Nogueira", + "Novaes", + "Novais", + "Nunes", + "Oliveira", + "Ourique", + "Pacheco", + "Padilha", + "Paiva", + "Paris", + "Peixoto", + "Peralta", + "Pereira", + "Peres", + "Pilar", + "Pimenta", + "Pinheiro", + "Pinto", + "Pires", + "Portela", + "Porto", + "Quaresma", + "Quarteira", + "Queiroz", + "Ramires", + "Ramos", + "Rebelo", + "Reis", + "Resende", + "Rezende", + "Ribeiro", + "Rocha", + "Rodrigues", + "Salazar", + "Sales", + "Salgado", + "Salgueiro", + "Sampaio", + "Sanches", + "Santana", + "Santos", + "Saraiva", + "Silva", + "Silveira", + "Siqueira", + "Soares", + "Souza", + "Subtil", + "Tavares", + "Taveira", + "Teixeira", + "Teles", + "Torres", + "Trindade", + "Varela", + "Vargas", + "Vasconcelos", + "Vasques", + "Veiga", + "Veloso", + "Viana", + "Vidal", + "Vieira", + "Vilela", + "Xavier", + "Ximenes", + "Zaganelli", + "Zanette" + ] + } +} diff --git a/packages/falso/src/lib/i18n/pt-br/last-name.ts b/packages/falso/src/lib/i18n/pt-br/last-name.ts new file mode 100644 index 00000000..6032a099 --- /dev/null +++ b/packages/falso/src/lib/i18n/pt-br/last-name.ts @@ -0,0 +1,31 @@ +import { randBoolean } from '../../boolean'; +import { fake } from '../../core/core'; +import { NameOptions } from '../../full-name'; +import { data } 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?: Options +) { + const withAccents = options?.withAccents ?? randBoolean(); + const names = withAccents ? data['withAccents'] : data['withoutAccents']; + + return fake(names, options); +} From 18bd308c1a519a113a4c13d77aa8e603e2f597b3 Mon Sep 17 00:00:00 2001 From: kabrunko-dev Date: Thu, 14 Dec 2023 09:18:24 -0300 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20remove=20data=20?= =?UTF-8?q?for=20lastName=20and=20some=20generators?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../falso/src/lib/i18n/pt-br/first-name.ts | 45 ---- .../falso/src/lib/i18n/pt-br/full-name.ts | 44 ---- packages/falso/src/lib/i18n/pt-br/index.ts | 3 - .../src/lib/i18n/pt-br/last-name.i18n.json | 228 ------------------ .../falso/src/lib/i18n/pt-br/last-name.ts | 31 --- 5 files changed, 351 deletions(-) delete mode 100644 packages/falso/src/lib/i18n/pt-br/first-name.ts delete mode 100644 packages/falso/src/lib/i18n/pt-br/full-name.ts delete mode 100644 packages/falso/src/lib/i18n/pt-br/last-name.i18n.json delete mode 100644 packages/falso/src/lib/i18n/pt-br/last-name.ts diff --git a/packages/falso/src/lib/i18n/pt-br/first-name.ts b/packages/falso/src/lib/i18n/pt-br/first-name.ts deleted file mode 100644 index f6b64347..00000000 --- a/packages/falso/src/lib/i18n/pt-br/first-name.ts +++ /dev/null @@ -1,45 +0,0 @@ -// import { fake } from '../core/core'; -import { fake } from '../../core/core'; -import { NameOptions } from '../../full-name'; -import { rand } from '../../rand'; -import { data } 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?: Options -) { - const withAccents = options?.withAccents ?? false; - const gender = options?.gender ?? rand(['male', 'female']); - const locale = options?.locale; - - const names: string[] = withAccents - ? locale - ? locale?.withAccents[gender] - : data.withAccents[gender] - : locale - ? locale?.withoutAccents[gender] - : data.withoutAccents[gender]; - - return fake(names, options); -} diff --git a/packages/falso/src/lib/i18n/pt-br/full-name.ts b/packages/falso/src/lib/i18n/pt-br/full-name.ts deleted file mode 100644 index d34f829e..00000000 --- a/packages/falso/src/lib/i18n/pt-br/full-name.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { FakeOptions, fake } from '../../core/core'; -import { randLastName } from './last-name'; -import { randFirstName } from './first-name'; - -export interface NameOptions extends FakeOptions { - withAccents?: boolean; - gender?: 'male' | 'female'; -} - -/** - * 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?: Options -) { - const nameOptions = { - withAccents: options?.withAccents, - gender: options?.gender, - }; - - return fake( - () => `${randFirstName(nameOptions)} ${randLastName(nameOptions)}`, - options - ); -} diff --git a/packages/falso/src/lib/i18n/pt-br/index.ts b/packages/falso/src/lib/i18n/pt-br/index.ts index 859ec5f9..5110b00d 100644 --- a/packages/falso/src/lib/i18n/pt-br/index.ts +++ b/packages/falso/src/lib/i18n/pt-br/index.ts @@ -1,4 +1 @@ export { randBird } from './bird'; -export { randFirstName } from './first-name'; -export { randLastName } from './last-name'; -export { randFullName } from './full-name'; diff --git a/packages/falso/src/lib/i18n/pt-br/last-name.i18n.json b/packages/falso/src/lib/i18n/pt-br/last-name.i18n.json deleted file mode 100644 index 6a6e0d73..00000000 --- a/packages/falso/src/lib/i18n/pt-br/last-name.i18n.json +++ /dev/null @@ -1,228 +0,0 @@ -{ - "data": { - "withAccents": [ - "Apolinário", - "Aragão", - "Araújo", - "Assunção", - "Ávila", - "Belém", - "Conceição", - "Custódio", - "Córdoba", - "Cortês", - "Damásio", - "da Conceição", - "Dinís", - "D'Ávila", - "Guimarães", - "Góis", - "Hilário", - "Hipólito", - "Jordão", - "Magalhães", - "Nóbrega" - ], - "withoutAccents": [ - "Agostinho", - "Aguiar", - "Albuquerque", - "Albuquerque", - "Alegria", - "Alencastro", - "Almada", - "Almeida", - "Alves", - "Alves", - "Alvim", - "Amorim", - "Andrade", - "Antunes", - "Arruda", - "Assis", - "Baptista", - "Barbosa", - "Barreto", - "Barros", - "Barros", - "Barros", - "Batista", - "Beira-Mar", - "Belchior", - "Bernardes", - "Bittencourt", - "Boaventura", - "Bonfim", - "Botelho", - "Braga", - "Brites", - "Brito", - "Caetano", - "Caldeira", - "Camacho", - "Camilo", - "Campos", - "Capelo", - "Cardoso", - "Carvalho", - "Castro", - "Castro", - "Cavalcante", - "Cavalcanti", - "Chaves", - "Corte Real", - "Costa", - "Costa", - "Coutinho", - "Crespo", - "Cunha", - "Curado", - "Dantas", - "da Costa", - "da Cruz", - "da Cunha", - "da Luz", - "da Mata", - "da Mota", - "da Paz", - "da Rocha", - "da Rosa", - "das Neves", - "Dias", - "Dias", - "Domingues", - "dos Reis", - "Drummond", - "Duarte", - "Escobar", - "Espinosa", - "Esteves", - "Evangelista", - "Farias", - "Fernandes", - "Ferrari", - "Ferreira", - "Figueiredo", - "Figueiroa", - "Flores", - "Fogaça", - "Franco", - "Freitas", - "Furtado", - "Garcia", - "Gaspar", - "Gentil", - "Geraldes", - "Gil", - "Godinho", - "Gomes", - "Gonzaga", - "Gonçalves", - "Goulart", - "Gouveia", - "Guedes", - "Hernandes", - "Ilha", - "Infante", - "Jaques", - "Jesus", - "Lacerda", - "Lessa", - "Lima", - "Lopes", - "Macedo", - "Machado", - "Maciel", - "Maia", - "Maldonado", - "Marinho", - "Marques", - "Martins", - "Medeiros", - "Meireles", - "Mello", - "Melo", - "Mendes", - "Menezes", - "Mesquita", - "Modesto", - "Monteiro", - "Moraes", - "Morais", - "Moreira", - "Morgado", - "Moura", - "Muniz", - "Nascimento", - "Neves", - "Nogueira", - "Novaes", - "Novais", - "Nunes", - "Oliveira", - "Ourique", - "Pacheco", - "Padilha", - "Paiva", - "Paris", - "Peixoto", - "Peralta", - "Pereira", - "Peres", - "Pilar", - "Pimenta", - "Pinheiro", - "Pinto", - "Pires", - "Portela", - "Porto", - "Quaresma", - "Quarteira", - "Queiroz", - "Ramires", - "Ramos", - "Rebelo", - "Reis", - "Resende", - "Rezende", - "Ribeiro", - "Rocha", - "Rodrigues", - "Salazar", - "Sales", - "Salgado", - "Salgueiro", - "Sampaio", - "Sanches", - "Santana", - "Santos", - "Saraiva", - "Silva", - "Silveira", - "Siqueira", - "Soares", - "Souza", - "Subtil", - "Tavares", - "Taveira", - "Teixeira", - "Teles", - "Torres", - "Trindade", - "Varela", - "Vargas", - "Vasconcelos", - "Vasques", - "Veiga", - "Veloso", - "Viana", - "Vidal", - "Vieira", - "Vilela", - "Xavier", - "Ximenes", - "Zaganelli", - "Zanette" - ] - } -} diff --git a/packages/falso/src/lib/i18n/pt-br/last-name.ts b/packages/falso/src/lib/i18n/pt-br/last-name.ts deleted file mode 100644 index 6032a099..00000000 --- a/packages/falso/src/lib/i18n/pt-br/last-name.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { randBoolean } from '../../boolean'; -import { fake } from '../../core/core'; -import { NameOptions } from '../../full-name'; -import { data } 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?: Options -) { - const withAccents = options?.withAccents ?? randBoolean(); - const names = withAccents ? data['withAccents'] : data['withoutAccents']; - - return fake(names, options); -} From 1d27fda44197bffe59f56d1389e96694d20183a4 Mon Sep 17 00:00:00 2001 From: kabrunko-dev Date: Thu, 14 Dec 2023 09:26:22 -0300 Subject: [PATCH 3/4] =?UTF-8?q?test(i18n-ptBR):=20=F0=9F=A5=B3=20add=20tes?= =?UTF-8?q?t=20for=20bird?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/falso/src/tests/bird.spec.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/falso/src/tests/bird.spec.ts b/packages/falso/src/tests/bird.spec.ts index 9bbcc2bf..d727ad1f 100644 --- a/packages/falso/src/tests/bird.spec.ts +++ b/packages/falso/src/tests/bird.spec.ts @@ -10,6 +10,9 @@ import { data as esData } from '../../src/lib/i18n/es/bird.i18n.json'; import { randBird as koRandBird } from '../../src/lib/i18n/ko'; import { data as koData } from '../../src/lib/i18n/ko/bird.i18n.json'; +import { randBird as ptBrRandBird } from '../../src/lib/i18n/pt-br'; +import { data as ptBrData } from '../../src/lib/i18n/pt-br/bird.i18n.json'; + describe('randBird', () => { describe('EN', () => { it('should create one random bird', () => { @@ -50,4 +53,14 @@ describe('randBird', () => { expect(koData).toEqual(expect.arrayContaining([randomBird])); }); }); + + describe('PT-BR', () => { + it('should create one random bird', () => { + const randomBird = ptBrRandBird(); + + expect(randomBird).toBeTruthy(); + expect(typeof randomBird).toEqual('string'); + expect(ptBrData).toEqual(expect.arrayContaining([randomBird])); + }); + }); }); From e353b10aca51d11c67f5b1b3132e24d2f960458a Mon Sep 17 00:00:00 2001 From: kabrunko-dev Date: Thu, 14 Dec 2023 09:49:27 -0300 Subject: [PATCH 4/4] =?UTF-8?q?test(i18n-ptBR):=20=F0=9F=A5=B3=20add=20tes?= =?UTF-8?q?t=20for=20firstName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/falso/src/tests/first-name.spec.ts | 76 +++++++++++++++++++-- 1 file changed, 71 insertions(+), 5 deletions(-) diff --git a/packages/falso/src/tests/first-name.spec.ts b/packages/falso/src/tests/first-name.spec.ts index 580965f2..334d1916 100644 --- a/packages/falso/src/tests/first-name.spec.ts +++ b/packages/falso/src/tests/first-name.spec.ts @@ -1,6 +1,9 @@ import { randFirstName } from '../lib/first-name'; import { data } from '../lib/first-name.json'; -import { data as locale } from '../lib/i18n/ru/first-name.i18n.json'; + +import { data as locale_ru } from '../lib/i18n/ru/first-name.i18n.json'; +import { data as locale_ptBR } from '../lib/i18n/pt-br/first-name.i18n.json'; +import { NameOptions } from '../lib/full-name'; describe('firstName', () => { let specialCharRegex: RegExp; @@ -137,13 +140,13 @@ describe('firstName', () => { }); }); - describe('with provided locale data', () => { - const data = locale; + describe('with provided locale RU data', () => { + const data = locale_ru; it('should works with female gender and provided data', () => { const result = randFirstName({ gender: 'female', - locale, + locale: data, }); expect(data.withoutAccents.female.includes(result)).toBe(true); @@ -152,10 +155,73 @@ describe('firstName', () => { it('should works with male gender and provided data', () => { const result = randFirstName({ gender: 'male', - locale, + locale: data, }); expect(data.withoutAccents.male.includes(result)).toBe(true); }); }); + + describe('with provided locale PT-BR data', () => { + const data = locale_ptBR; + let options: NameOptions; + + describe('female name', () => { + beforeEach(() => { + options = { + gender: 'female', + locale: data, + }; + }); + + it('should return a firstName with at least 1 accented character', () => { + const result = randFirstName({ + ...options, + withAccents: true, + }); + + expect(result.match(specialCharRegex)).toBeTruthy(); + expect(data.withAccents.female.includes(result)).toBe(true); + }); + + it('should return a firstName with only non-accented characters', () => { + const result = randFirstName({ + ...options, + withAccents: false, + }); + + expect(result.match(specialCharRegex)).toBeFalsy(); + expect(data.withoutAccents.female.includes(result)).toBe(true); + }); + }); + + describe('male name', () => { + beforeEach(() => { + options = { + gender: 'male', + locale: data, + }; + }); + + it('should return a firstName with at least 1 accented character', () => { + const result = randFirstName({ + ...options, + withAccents: true, + }); + + expect(result.match(specialCharRegex)).toBeTruthy(); + expect(data.withAccents.male.includes(result)).toBe(true); + }); + + it('should return a firstName with only non-accented characters', () => { + const result = randFirstName({ + ...options, + withAccents: false, + }); + + expect(result.match(specialCharRegex)).toBeFalsy(); + expect(data.withoutAccents.male.includes(result)).toBe(true); + }); + }); + }); });