Open oofdie opened 6 months ago
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 }}]});
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
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
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.
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')
Blocked by:
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
Environment Info
Which module system do you use?
Used Package Manager
pnpm