-
-
Notifications
You must be signed in to change notification settings - Fork 944
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
feat(locale): add hyphenated names to English locales #1872
feat(locale): add hyphenated names to English locales #1872
Conversation
- default en locale gets 95% non-hyphenated 5% hyphenated - other locales without existing last_name_patterns get 100% non-hyphenated - locales with split male_last_name and female_last_names get split patterns - existing locales with last_name_patterns (e.g. lv, en_GB) are not changed.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## next #1872 +/- ##
==========================================
- Coverage 99.64% 99.62% -0.02%
==========================================
Files 2384 2450 +66
Lines 238992 239274 +282
Branches 1231 1228 -3
==========================================
+ Hits 238132 238387 +255
- Misses 838 865 +27
Partials 22 22
|
this exposed a bug in the test for commitEntry, the local part of the email addresses was not allowing hyphens. i changed the regex to match the one we use in the emailAddress method https://github.com/faker-js/faker/blob/add2254ca31434af3003c0051064bdb27713992d/src/modules/internet/index.ts |
Please lets extract this to its own PR, so
|
I considered that, but the test doesn't fail on the next branch because email addresses in en never contain hyphens. |
You are free to add static tests that handles special cases in the random seeded test cases (second part of each test file) Maybe we need to change something here instead of the test faker/src/modules/git/index.ts Line 123 in 11a5f51
We are already starting to pollute this PR with unrelated discussions, please lets stop this and extract it so we can have dedicated discussions |
This reverts commit 6e93826.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are now somewhat mandatory:
faker/src/modules/person/index.ts
Lines 120 to 135 in 11a5f51
if ( | |
last_name_patterns != null || | |
male_last_name_patterns != null || | |
female_last_name_patterns != null | |
) { | |
const pattern = selectDefinition( | |
this.faker, | |
this.faker.helpers.weightedArrayElement, | |
sex, | |
{ | |
generic: last_name_patterns, | |
female: female_last_name_patterns, | |
male: male_last_name_patterns, | |
} | |
); | |
return this.faker.helpers.fake(pattern); |
So IMO the other code branch could be removed.
Also the PR does more than the PR title suggests IMO.
Not sure whether it is worth splitting into two PRs:
- Make last_name_patterns required/Generate last_name_patterns for all locales
- add hyphenated names to English locales
It's not mandatory if you create a new locale which doesn't extend en. |
# Conflicts: # test/__snapshots__/internet.spec.ts.snap
Please fix the merge conflicts. |
# Conflicts: # src/locales/zh_TW/person/index.ts
Please adjust the PR title to reflect the current. It also changes non English locales. |
it doesn't add any hyphenated patterns to any non-English locales, the changes are to prevent hyphenated patterns from propagating to the other non-English locales unexpectedly. |
could append ", add last_name_patterns to all locales" maybe? but makes it a bit long |
fix #691
If additional information about hyphenation rules in other locales can be found, this can be added in a subsequent PR. I kept this one formulaic to make it easy to review.