Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Check use of the #{pattern}s in the locales #725

Closed
ST-DDT opened this issue Mar 29, 2022 · 5 comments · Fixed by #927
Closed

Check use of the #{pattern}s in the locales #725

ST-DDT opened this issue Mar 29, 2022 · 5 comments · Fixed by #927
Assignees
Labels
c: bug Something isn't working c: locale Permutes locale definitions p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug

Comments

@ST-DDT
Copy link
Member

ST-DDT commented Mar 29, 2022

Describe the bug

A lot of locale files such as https://github.com/faker-js/faker/blob/main/src/locales/en/address/city.ts contain a #{pattern}

These files aren't used anywhere and faker does not have a method to use/resolve them with.

Did faker.fake() support this syntax at some point or have they been forgotten during a refactor related to faker.fake()?

I'm not sure what to do with them.

Reproduction

export default [
'#{city_prefix} #{Name.first_name}#{city_suffix}',
'#{city_prefix} #{Name.first_name}',
'#{Name.first_name}#{city_suffix}',
'#{Name.last_name}#{city_suffix}',
];

Additional Info

There are almost 200 locale files that contain these.

@ST-DDT ST-DDT added c: bug Something isn't working p: 1-normal Nothing urgent s: needs decision Needs team/maintainer decision c: locale Permutes locale definitions labels Mar 29, 2022
@Shinigami92
Copy link
Member

Never recognized this #{ before 🤔

@ST-DDT
Copy link
Member Author

ST-DDT commented Mar 29, 2022

I traced it back to this commit:

faker/lib/locales/en.js

Lines 1027 to 1032 in 0048b9f

"city": [
"#{city_prefix} #{Name.first_name}#{city_suffix}",
"#{city_prefix} #{Name.first_name}",
"#{Name.first_name}#{city_suffix}",
"#{Name.last_name}#{city_suffix}"
],

[api] First pass at adding localization data definitions. #116

(14 Sep 2014) which was included in v2.0.0

I searched a few files and commits, but didn't find any method ever dealing with this syntax.

@cxcorp
Copy link

cxcorp commented Apr 11, 2022

I'm not sure if this is related, but the en_GH locale seems to produce a lot of strings with those in them:

faker.locale = 'en_GH';
faker.internet.exampleEmail();
// 'male_first_name22@example.com'
faker.internet.userName()
// '#{female_first_name}.Akowua'

@ST-DDT
Copy link
Member Author

ST-DDT commented Apr 12, 2022

https://github.com/faker-js/faker/blob/main/src/locales/en_GH/name/first_name.ts
https://github.com/faker-js/faker/blob/main/src/locales/en/name/first_name.ts

In this case its more like a bug. The file contains bad data.
You could create a PR that imports both male and female, sorts and exports them instead.
Otherwise it might take a while before we can fix these.

@ST-DDT ST-DDT linked a pull request May 5, 2022 that will close this issue
@ST-DDT
Copy link
Member Author

ST-DDT commented May 5, 2022

Will hopefully be fixed by #927

@ST-DDT ST-DDT moved this to Awaiting Review in Faker Roadmap May 5, 2022
@ST-DDT ST-DDT added s: accepted Accepted feature / Confirmed bug and removed s: needs decision Needs team/maintainer decision labels May 5, 2022
@ST-DDT ST-DDT self-assigned this May 5, 2022
Repository owner moved this from Awaiting Review to Done in Faker Roadmap May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working c: locale Permutes locale definitions p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants