Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization lastName is not working #2833

Closed
8 of 10 tasks
undermuz opened this issue Apr 18, 2024 · 2 comments · Fixed by #2834
Closed
8 of 10 tasks

Localization lastName is not working #2833

undermuz opened this issue Apr 18, 2024 · 2 comments · Fixed by #2834
Labels
c: bug Something isn't working m: person Something is referring to the person module s: pending triage Pending Triage

Comments

@undermuz
Copy link

undermuz commented Apr 18, 2024

Pre-Checks

Describe the bug

This code produces base last names:

import { fakerRU as faker } from "@faker-js/faker";

console.log(faker.person.lastName());

Expected: this code produces localizated last names

Minimal reproduction code

https://codesandbox.io/p/sandbox/faker-js-ru-not-working-forked-cthnpl?file=%2Fsrc%2Findex.ts%3A20%2C41

import { fakerRU, ru as localization } from "@faker-js/faker";

//THIS TEMP FIX:
// import { base, ru, Faker } from "@faker-js/faker";

// const customFaker = new Faker({
//   locale: [ru, base],
// });

const faker = fakerRU;

let maxIterations = 1000;
let found = false;
let i = 0;

console.log(localization);

const allLastNames = [
  ...localization.person.female_last_name,
  ...localization.person.male_last_name,
];

console.log(allLastNames);

while (!found && i++ < maxIterations) {
  const text = faker.person.lastName();

  console.log(text);

  found = allLastNames.some((t) => t === text);

  if (found) {
    console.log("Found", text);
    break;
  }
}

if (!found) console.log("Not found");

Additional Context

No response

Environment Info

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12600
    Memory: 16.03 GB / 31.75 GB
  Binaries:
    Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @faker-js/faker: ^8.4.1 => 8.4.1

Which module system do you use?

  • CJS
  • ESM

Used Package Manager

npm

@undermuz undermuz added c: bug Something isn't working s: pending triage Pending Triage labels Apr 18, 2024
@ST-DDT ST-DDT added the m: person Something is referring to the person module label Apr 18, 2024
@ST-DDT
Copy link
Member

ST-DDT commented Apr 18, 2024

@matthewmayer
Copy link
Contributor

This affects locales that have a male_last_name and female_last_name file but no last_name file.

Specifically:

sk
id_ID
lv
ru
uk
az
uz_UZ_latin

We can solve this by adding a last_name.ts file with mergeArrays. This is already done for these locales:

cs_CZ
dv
mk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working m: person Something is referring to the person module s: pending triage Pending Triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants