How to use the faker.locale function in faker

To help you get started, we’ve selected a few faker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paintedbicycle / sketch-data-faker / src / faker.js View on Github external
// Sketch already knows the layer it's going to apply to so we don't
      // actually need the full layer
      originalLayerName = item.override.affectedLayer.name;
    }

    let search = originalLayerName.split("|")[0];
    let locale = originalLayerName.split("|")[1];

    // Set up search string
    let searchTerm = "{{" + search + "}}";

    // Set up locale
    if (locale) {
      faker.locale = locale;
    } else {
      faker.locale = "en";
    }

    switch (type) {
      case "fullName":
        newLayerData = faker.name.findName();
        break;
      case "firstName":
        newLayerData = faker.name.firstName();
        break;
      case "lastName":
        newLayerData = faker.name.lastName();
        break;
      case "email":
        newLayerData = faker.internet.email();
        break;
      case "phoneNumber":
github letterpad / letterpad / src / api / seed / seed.js View on Github external
import bcrypt from "bcryptjs";
import Faker from "faker";
import rimraf from "rimraf";
import path from "path";
import mkdirp from "mkdirp";
import posts from "./posts";
import { promisify } from "util";
import copydir from "copy-dir";
import generatePost from "./contentGenerator";

const mkdirpAsync = promisify(mkdirp);
const rimrafAsync = promisify(rimraf);
const copydirAsync = promisify(copydir);

Faker.locale = "en_US";

// All paths are relative to this file
const dataDir = "../../../data";
const publicUploadsDir = "../../public/uploads";
const uploadsSourceDir = "./uploads";

function absPath(p) {
  return path.join(__dirname, p);
}

let models = null;
export const seed = async (dbModels, autoExit = true) => {
  models = dbModels;

  console.time("ensure data directories");
  await Promise.all([
github bigcompany / hooks / examples-javascript-fake-data / index.js View on Github external
module['exports'] = function fakeData (hook) {
  var faker = require('faker');
  // supports multiple locales
  faker.locale = 'en'; // try: 'de', 'es'
  // supports all faker.js methods
  var result = faker.name.findName();
  hook.res.end(result);
};
github Cambalab / fake-data-generator / models / transit.js View on Github external
import faker from 'faker'
import moment from 'moment'
import { getLocation, numbers } from '../lib/helpers'

faker.locale = 'es'
const { randomize } = faker.helpers

const vehicleBrands = require('./../fixtures/vehicle-brands.json')
const vehicleModels = require('./../fixtures/vehicle-models.json')

const Model = () => {
  const vehicleName = randomize(vehicleBrands)
  const vehicleBrand = randomize(vehicleModels[vehicleName])
  const createdAt = faker.date.past()
  const formmatedCreatedAt = moment(createdAt).format()
  const updatedAt = faker.date.recent()
  const formmatedUpdatedAt = moment(updatedAt).format()
  const originPackage = {
    coordinates: getLocation(),
    address: {
      city: faker.address.city(),
github 2rhop / vollk / core / utils.js View on Github external
function buildFaker(str, lang) {
    const faker = require('faker')
    faker.locale = lang;
    return faker.fake('{{' + str + '}}')
}
github adazzle / react-data-grid / examples / scripts / example13-all-features.js View on Github external
import React from 'react';
import ReactDataGrid from 'react-data-grid';
import { Editors, Toolbar, Formatters } from 'react-data-grid-addons';
import update from 'immutability-helper';
import faker from 'faker';

import exampleWrapper from '../components/exampleWrapper';

const { DropDownEditor } = Editors;
const { ImageFormatter } = Formatters;

faker.locale = 'en_GB';

const titles = ['Dr.', 'Mr.', 'Mrs.', 'Miss', 'Ms.'];

class Example extends React.Component {
  constructor(props, context) {
    super(props, context);
    this._columns = [
      {
        key: 'id',
        name: 'ID',
        width: 80,
        resizable: true
      },
      {
        key: 'avartar',
        name: 'Avartar',
github adazzle / react-data-grid / scripts / example21-grouping.js View on Github external
const faker = require('faker');
const ReactDataGrid = require('react-data-grid');
const exampleWrapper = require('../components/exampleWrapper');
const React = require('react');
const {
  ToolsPanel: { AdvancedToolbar: Toolbar, GroupedColumnsPanel },
  Data: { Selectors },
  Draggable: { Container: DraggableContainer },
  Formatters: { ImageFormatter }
} = require('react-data-grid-addons');

import PropTypes from 'prop-types';

faker.locale = 'en_GB';

const createFakeRowObjectData = (index) => ({
  id: 'id_' + index,
  avartar: faker.image.avatar(),
  county: faker.address.county(),
  email: faker.internet.email(),
  title: faker.name.prefix(),
  firstName: faker.name.firstName(),
  lastName: faker.name.lastName(),
  street: faker.address.streetName(),
  zipCode: faker.address.zipCode(),
  date: faker.date.past().toLocaleDateString(),
  bs: faker.company.bs(),
  catchPhrase: faker.company.catchPhrase(),
  companyName: faker.company.companyName(),
  words: faker.lorem.words(),
github fabsrc / artillery-plugin-faker / index.js View on Github external
function FakerPlugin (script, events) {
  this.script = script;
  this.events = events;
  this.locale = this.script.config.plugins.faker.locale;

  if (this.locale) {
    faker.locale = this.locale;
    debug('Locale set to', this.locale);
  }

  script.config.processor = script.config.processor || {};
  script.config.processor.fakerPluginCreateVariables = fakerPluginCreateVariables;

  script.scenarios.forEach(scenario => {
    scenario.beforeRequest = scenario.beforeRequest || [];
    scenario.beforeRequest.push('fakerPluginCreateVariables');
  });

  debug('Plugin initialized');
  return this;
}
github Cambalab / fake-data-generator / lib / parse-model.js View on Github external
function configureFaker(config) {
  const { locale = 'en' } = config
  faker.locale = locale
}
github APIs-guru / graphql-faker / src / fake.ts View on Github external
export function fakeValue(type, options?, locale?) {
  const fakeGenerator = fakeFunctions[type];
  const argNames = fakeGenerator.args;
  //TODO: add check
  const callArgs = argNames.map(name => options[name]);

  const localeBackup = faker.locale;
  //faker.setLocale(locale || localeBackup);
  faker.locale = locale || localeBackup;
  const result = fakeGenerator.func(...callArgs);
  //faker.setLocale(localeBackup);
  faker.locale = localeBackup;
  return result;
}