Comments (5)
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
from faker.
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 }}]});
from faker.
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
from faker.
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.
from faker.
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')
from faker.
Related Issues (20)
- Phone numbers should support special numbers HOT 1
- Check capitisation of ex_MX/color/human
- Add v9.fakerjs.dev
- [Website] Change Navigation Behaviour HOT 4
- Generate Planet names HOT 9
- More varied product descriptions HOT 2
- Can't use Faker with k6 HOT 16
- Vehicle data is very US-centric HOT 1
- Improve specification of lorem module and definitions HOT 6
- Add plugin support for modules HOT 2
- Check whether complex objects should be frozen HOT 3
- Reevaluate word distribution
- Create Intl based tests for date definitions HOT 3
- Check whether the locale data should use locale aware sorting HOT 6
- Use singular locale definition keys HOT 4
- Modernise buzz- and catch-phrases
- unable to use cell_phone, no API seems to expose it. HOT 1
- Prefer a stable CDN over IPFS HOT 5
- Enhance JSDoc sentences of word module HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faker.