Git Product home page Git Product logo

Comments (5)

oofdie avatar oofdie commented on June 20, 2024 1

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.

ST-DDT avatar ST-DDT commented on June 20, 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 }}]});

from faker.

ST-DDT avatar ST-DDT commented on June 20, 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

from faker.

matthewmayer avatar matthewmayer commented on June 20, 2024

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.

oofdie avatar oofdie commented on June 20, 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')

from faker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.