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

'lorem.words' missing for zh_CN #2907

Open
7 of 10 tasks
oofdie opened this issue May 17, 2024 · 5 comments
Open
7 of 10 tasks

'lorem.words' missing for zh_CN #2907

oofdie opened this issue May 17, 2024 · 5 comments
Labels
c: locale Permutes locale definitions good first issue Good for newcomers has workaround Workaround provided or linked m: lorem Something is referring to the lorem module p: 1-normal Nothing urgent s: awaiting more info Additional information are requested
Milestone

Comments

@oofdie
Copy link

oofdie commented May 17, 2024

Pre-Checks

Describe the bug

@faker-js/faker@8.4.1
const customFaker = new Faker({ locale: [zh_CN] }); customFaker.lorem.paragraphs({ min:2, max:3 }, '\n')
get error "The locale data for 'lorem.words' are missing in this locale.
Please contribute the missing data to the project or use a locale/Faker instance that has these data."

Minimal reproduction code

No response

Additional Context

image

Environment Info

System:
    OS: macOS 13.0
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 112.32 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.20.2 - ~/.nvm/versions/node/v16.20.2/bin/node
    Yarn: 1.22.21 - /usr/local/bin/yarn
    npm: 8.19.4 - ~/.nvm/versions/node/v16.20.2/bin/npm
    pnpm: 7.33.7 - ~/.nvm/versions/node/v16.20.2/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.209
    Safari: 16.1
  npmPackages:
    @faker-js/faker: ^8.4.1 => 8.4.1

Which module system do you use?

  • CJS
  • ESM

Used Package Manager

pnpm

@oofdie oofdie added c: bug Something isn't working s: pending triage Pending Triage labels May 17, 2024
@ST-DDT
Copy link
Member

ST-DDT commented May 17, 2024

What do you expect for lorem data in zh_CN?
Chinese words or latin words?

Ref:

Workaround:

new Faker({ locale: [zh_CN, {lorem: en.lorem}]});
// or
new Faker({ locale: [zh_CN, en]});
// or
new Faker({ locale: [zh_CN, {lorem: {words: zh_CN.word.noun }}]});

@ST-DDT ST-DDT added good first issue Good for newcomers has workaround Workaround provided or linked p: 1-normal Nothing urgent s: awaiting more info Additional information are requested c: locale Permutes locale definitions m: lorem Something is referring to the lorem module and removed s: pending triage Pending Triage c: bug Something isn't working labels May 17, 2024
@ST-DDT ST-DDT added this to the vAnytime milestone May 17, 2024
@ST-DDT ST-DDT changed the title The locale data for 'lorem.words' are missing in this locale 'lorem.words' missing for zh_CN May 17, 2024
@oofdie
Copy link
Author

oofdie commented May 19, 2024

What I expected was to get pure Chinese words. Adding 'en' to the locale indeed solves the error, because Faker automatically generates paragraphs in all English words.

new Faker({ locale: [zh_CN, {lorem: en.lorem}]});  // All English words
// or
new Faker({ locale: [zh_CN, en]}); // All English words
// or
new Faker({ locale: [zh_CN, {lorem: {words: zh_CN.word.noun }}]});  // The locale data for 'lorem.words' are missing in this locale

@ST-DDT
Copy link
Member

ST-DDT commented May 19, 2024

Sorry I didn't notice that zh_CN doesn't have nouns.

new Faker({ locale: [zh_CN, { lorem: { words: zh_CN.word.verb } }] }); // 写 驾驶 拎 拧 捡 舞. 抚 跳 拿 托 挡 坐 吮 抬 擦 搔. 擦 抛 披.

Is this what you expect?

FFR: en lorem = Latin

@matthewmayer
Copy link
Contributor

Chinese doesn't normally put spaces in between words. My feeling is that "Chinese" lorem equivalent would be a long string of real Chinese characters but with nonsense meanings, not necessarily real words.

@oofdie
Copy link
Author

oofdie commented May 22, 2024

Thank you @ST-DDT, your solution indeed solves my problem. It outputs continuous Chinese paragraphs, but they are interspersed with spaces which I need to handle myself. The reason I raised this issue is that I didn't find a similar solution in the demos on the documentation. I hope that in the future, the faker team can include such cases in the documentation or provide better support for Chinese, just like in the demos.

const customFaker = new Faker({
local: [zh_CN]
})
customFaker.lorem.paragraphs({ min: 2, max: 5 }, '\n')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: locale Permutes locale definitions good first issue Good for newcomers has workaround Workaround provided or linked m: lorem Something is referring to the lorem module p: 1-normal Nothing urgent s: awaiting more info Additional information are requested
Projects
None yet
Development

No branches or pull requests

3 participants