Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Polish letter and Faker::Internet.user_name (expected: replacement by ASCII letters, what happens: removal) #168

Closed
matkoniecz opened this issue Jan 16, 2014 · 7 comments

Comments

@matkoniecz
Copy link

Faker::Internet.user_name("Łucja")

returns

ucja

I would expect it to return

lucja

Affected signs: ą, Ą ć Ć ę Ę ł Ł ń Ń ó Ó ś Ś ź Ź ż Ż

Commonly accepted and widespread method of dealing with inability of many systems to use proper UTF-8 is to replace this letters with closest ASCII letter.

@matkoniecz
Copy link
Author

I am using following fix in my script:

class Faker::InternetPL < Faker::Internet
    def self.user_name(name)
        changes = {
        "ą" => "a",
        "Ą" => "A",
        "ć" => "c",
        "Ć" => "C",
        "ę" => "e",
        "Ę" => "E",
        "ł" => "l",
        "Ł" => "L",
        "ń" => "n",
        "Ń" => "N",
        "ó" => "o",
        "Ó" => "O",
        "ś" => "s",
        "Ś" => "S",
        "ź" => "z",
        "Ź" => "Z",
        "ż" => "z",
        "Ż" => "Z",
        }
        changes.each do |old, new|
            name = name.gsub(old, new)
        end
        return super(name)
    end
end

@mhutter
Copy link
Contributor

mhutter commented Jan 18, 2014

Note for someone willing to fix this: maybe stringex does the trick

@matkoniecz
Copy link
Author

It seems that Polish is not listed below "Currently, built-in translations are available for the following languages:".

@vbrazo
Copy link
Member

vbrazo commented May 13, 2018

@matkoniecz could we close this issue or you guys need help to solve it?

@matkoniecz
Copy link
Author

@vbrazo At time of reporting it Faker was unable to handle UTF-8 letters, even by converting them to ASCII.

I see no reason to close this unless this issue is now fixed.

@vbrazo
Copy link
Member

vbrazo commented May 13, 2018

@matkoniecz ok cool! Thanks for the quick follow-up. I'm going to take a look at this issue in the next days. Lemme know if you have any new ideas on how to solve it.

@matkoniecz
Copy link
Author

As I reread it - I would expect Faker to just handle UTF-8 text.

Originally mentioned conversion to ASCII is an overcomplicated crutch that should not be necessary.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants