Skip to content

fix(locale): use only common surnames for zh_CN last names - #3938

Merged
ST-DDT merged 3 commits into
faker-js:nextfrom
MahinAnowar:fix/zh-cn-common-last-names
Jul 5, 2026
Merged

ST-DDT merged 3 commits into
faker-js:nextfrom
MahinAnowar:fix/zh-cn-common-last-names

Conversation

@MahinAnowar

Copy link
Copy Markdown
Contributor

Closes #3466

Problem

zh_CN last names are drawn uniformly from a ~1000-entry list in which the large majority are ultra-rare surnames (不, 丑, 九, 业, 之, …) that many Chinese speakers never encounter in real life. As the issue reporter showed, most generated names look unnatural at first glance because the surname is almost always one of these rare ones.

Fix (data-only, per maintainer guidance)

@ST-DDT confirmed in the thread that "both weighting and/or reducing the number of rare last names in that list are valid solutions". With the weighting PoC (#3467) closed, this PR takes the reduction route: replace last_name.generic with the curated list of the most common surnames posted in the issue by @yyz945947732 — 150 single-character surnames plus 12 common compound surnames (欧阳, 诸葛, 司马, …), covering ~85%+ of the population. This mirrors the scope of the existing zh_TW list (~100 common surnames). No code changes; last_name_pattern is untouched.

The file was normalized with pnpm run generate:locales, and the locale-data character-inventory snapshot updated accordingly (one line: zh_CN).

Verification

Added a regression test in test/modules/person.spec.ts asserting the zh_CN list is the curated common set (contains 王/李/张/刘/陈/欧阳, excludes the rare 不/丑/九/业/之, length < 200). It fails on the old data and passes with this change. Full runs green locally: person.spec (214), locale-data (2635), locale-imports (152), all-functional (36k), ts-check, lint.

Credit for the curated list goes to @yyz945947732 in the issue.

The zh_CN surname list held ~1000 entries, most of them ultra-rare
surnames some Chinese speakers never encounter, drawn uniformly — so
most generated names looked unnatural at a glance. Replace it with the
curated list of the most common surnames (including compound surnames),
which cover the vast majority of the population, mirroring the zh_TW
list's scope.

Closes #3466
@MahinAnowar
MahinAnowar requested a review from a team as a code owner July 5, 2026 12:01
@netlify

netlify Bot commented Jul 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for fakerjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit b511eb1
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6a4a517f67a42200084ab956
😎 Deploy Preview https://deploy-preview-3938.fakerjs.dev
��� Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.84%. Comparing base (332b357) to head (b511eb1).

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3938   +/-   ##
=======================================
  Coverage   98.84%   98.84%           
=======================================
  Files         923      923           
  Lines        3216     3216           
  Branches      583      583           
=======================================
  Hits         3179     3179           
  Misses         33       33           
  Partials        4        4           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ST-DDT ST-DDT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing. ❤️

Comment thread test/modules/person.spec.ts
@ST-DDT ST-DDT added p: 1-normal Nothing urgent c: locale Permutes locale definitions m: person Something is referring to the person module labels Jul 5, 2026
@ST-DDT ST-DDT added this to the v10.x milestone Jul 5, 2026
@ST-DDT
ST-DDT added this pull request to the merge queue Jul 5, 2026
Merged via the queue into faker-js:next with commit 58394eb Jul 5, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: locale Permutes locale definitions m: person Something is referring to the person module p: 1-normal Nothing urgent

4 participants