Skip to content

Commit

Permalink
feat(fakerjs): Added multilanguaje support
Browse files Browse the repository at this point in the history
  • Loading branch information
danibram committed Oct 16, 2017
1 parent b3f9f7c commit 0b94471
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lib/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ export class Generator {
let faker = f
let db = this.DB
let object = this.object

let re = /(^[a-z_A-Z]*)/ // en_US
let matches = re.exec(cfg.locale)
let strFn
if (matches && matches.length === 2) {
strFn = 'faker.' + cfg.locale
eval(strFn)

if (cfg.locale) {
re = /(^[a-z_A-Z]*)/ // en_US
matches = re.exec(cfg.locale)

if (matches && matches.length === 2) {
faker = require('faker/locale/' + cfg.locale)
}
}

re = /(^[a-zA-Z.]*)/ // aZ.aZ
Expand Down

0 comments on commit 0b94471

Please sign in to comment.