Giter Site home page Giter Site logo

Is localization supported? about faker HOT 3 OPEN

bxcodec avatar bxcodec commented on July 30, 2024
Is localization supported?

from faker.

Comments (3)

djk29a avatar djk29a commented on July 30, 2024 1

The only three languages supported with the code so far looks to be English, Chinese, and Russian. A "language" is defined with a rune range including exceptions and an informal language spec label. To support French additional characters would need to be added with a new language spec similar to the built-ins

faker/faker.go

Lines 56 to 63 in 7460bf3

var (
// LangENG is for english language
LangENG = langRuneBoundary{65, 122, []rune{91, 92, 93, 94, 95, 96}}
// LangCHI is for chinese language
LangCHI = langRuneBoundary{19968, 40869, nil}
// LangRUS is for russian language
LangRUS = langRuneBoundary{1025, 1105, nil}
)

Support for ISO 639-1 or IETF locales such as en, fr-TN or fr is thus not present.

from faker.

bxcodec avatar bxcodec commented on July 30, 2024

Maybe you can take a look here for the example https://github.com/bxcodec/faker/blob/master/example_with_tags_lang_test.go

from faker.

frederikhors avatar frederikhors commented on July 30, 2024

I saw that. But I cannot make it work.

E.g., I need french names. I'm trying with this code:

package main

import (
  "fmt"
  "github.com/bxcodec/faker/v3"
)

type SomeStructWithTags struct {
  FirstName       string `faker:"first_name lang=fre"`
  FirstNameMale   string `faker:"first_name_male lang=fre"`
  FirstNameFemale string `faker:"first_name_female lang=fre"`
  LastName        string `faker:"last_name lang=fre"`
}

func main() {
  a := SomeStructWithTags{}
  
  err := faker.FakeData(&a)
  if err != nil {
    println(err)
  }

  fmt.Printf("%+v", a)
}

It prints this:

{FirstName:PMawBtnvaCdgaLvlfuJlPeEWC FirstNameMale:WgxIlLkCJveRsoiblYCCnmauo FirstNameFemale:rilfCEbQUhpdyYpiOMwbkLqDl LastName:tZMFqPivpXktdQLUikuQmhsRl}

Am I wrong?

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.