faker icon indicating copy to clipboard operation
faker copied to clipboard

add multi language support

Open easazade opened this issue 5 years ago • 17 comments

it will be great to add support for other languages as well. though I understand that there are alot of languages and comming up with a solution to this problem can be hard.

one problem is that some languages are RTL (like farsi aka persian) unlike english which is LTR. and developers who make their app RTL first will override the flutter app locale to show the entire app in RTL. because of this showing faker's fake text which are read from left to right (LTR) because they are in english in an app which loaded its entire widget tree in (RTL) is very confusing.

easazade avatar Nov 08 '20 19:11 easazade

@easazade Makes sense and sounds like good addition. Feel free to send a PR!

drager avatar Nov 18 '20 17:11 drager

@drager Great, do you have any suggestion on how to approach implementing feature?

I'm thinking something like this for example :

faker.languages.farsi.words(3)

easazade avatar Nov 26 '20 00:11 easazade

Good question! I think we should first of look at other faker implementations and get ideas from them. Do for example the python/ruby package supports LTR? If they do, perhaps their way is a good starting point. If they don't, then perhaps faker.languages can be the way forward.

drager avatar Nov 27 '20 17:11 drager

@drager I checked. Python package supports Localization of Data and implemented it using different Data Providers to provide localized data for each different Locale.

here is what they do :

from faker import Faker
fake = Faker('it_IT')
for _ in range(10):
    print(fake.name())

# 'Elda Palumbo'
# 'Pacifico Giordano'
# 'Sig. Avide Guerra'
# 'Yago Amato'
# 'Eustachio Messina'
# 'Dott. Violante Lombardo'
# 'Sig. Alighieri Monti'
# 'Costanzo Costa'
# 'Nazzareno Barbieri'
# 'Max Coppola'

easazade avatar Nov 27 '20 20:11 easazade

@drager I checked. Python package supports Localization of Data and implemented it using different Data Providers to provide localized data for each different Locale.

here is what they do :

from faker import Faker
fake = Faker('it_IT')
for _ in range(10):
    print(fake.name())

# 'Elda Palumbo'
# 'Pacifico Giordano'
# 'Sig. Avide Guerra'
# 'Yago Amato'
# 'Eustachio Messina'
# 'Dott. Violante Lombardo'
# 'Sig. Alighieri Monti'
# 'Costanzo Costa'
# 'Nazzareno Barbieri'
# 'Max Coppola'

Awesome, that seems like a good way of doing it? Or what do you think? :blush:

drager avatar Nov 29 '20 14:11 drager

@drager I was thinking we should add LocaleDataProvider for each locale (which falls to the community to do so). but also allow user to add its own CustomDataProvider. this is really helpful for demo purposes when creating Flutter apps and creating fake data which is more relevent to the app. So I think starting with the CustomDataProvider makes more sense

easazade avatar Nov 30 '20 15:11 easazade

@drager thanks for the merge. I will start adding DataProvider to the rest of the faker features that can be customized by localizations or etc.

easazade avatar Dec 12 '20 13:12 easazade

@easazade Thank you! Sounds great!

drager avatar Dec 12 '20 13:12 drager

I would like to help with portuguese br translation when available.

rumbleh avatar Mar 16 '21 11:03 rumbleh

@rumbleh Feel free to work on it!

drager avatar Mar 21 '21 12:03 drager

next time I contributed in order to finish this. I remember to add some documentation.

easazade avatar Mar 28 '21 05:03 easazade

Is anyone working on this? I would love to give it a go if nobody is working on it.

I'm wanting to localize it for randomizing Spanish data

nombrekeff avatar Jun 26 '21 10:06 nombrekeff

@nombrekeff thank you for the comment. reminded me there is unfinished work to be done here. I decided to add the rest of the data providers to other data generators like address , food job and etc. after that everyone can add their own customized DataProviders like SpanishLoremProvider or SpanishAddressProvider and so force

easazade avatar Jun 26 '21 10:06 easazade

I should also update the docs

easazade avatar Jun 26 '21 11:06 easazade

Ohh cool 👍

Thanks for the info, I will check it out when it's ready. Let me know if I can help in any other way, adding translations, docs, etc... I have some free time at the moment and would be glad to help out!

nombrekeff avatar Jun 26 '21 12:06 nombrekeff

hey @nombrekeff I added the rest of the DataProviders in here (#49) . feel free to check it

easazade avatar Jul 04 '21 11:07 easazade