-
Notifications
You must be signed in to change notification settings - Fork 29
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
First version of Dutch Lang #6
base: master
Are you sure you want to change the base?
Conversation
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.
Wow, that is some comprehensive work. Thank you. Can you please add a unit test for this class and look at the inline comments i made? Thank you.
|
||
public function getSuffixes(): array | ||
{ | ||
return self::SUFFIXES; |
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.
Since you are not doing any transformations in here, the mappers would try to match the suffixes by the keys provided in the array above (see https://github.com/theiconic/name-parser/blob/master/src/Mapper/SuffixMapper.php#L42). This means the input would have to contain e.g. bacc.alaureus
for the suffix to be recognised and it would then be normalised to 'bacc.'. I'm pretty sure that's not what you'd want and a solution like the array_combine
below, with provision of properly normalised array values could be a solution.
public function getLastnamePrefixes(): array | ||
{ | ||
$prefixMap = []; | ||
foreach(self::LASTNAME_PREFIXES as $prefix){ |
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.
Please add spaces before and after the parenthesis to keep a consistent code style.
$prefixMap[$key] = $prefix; | ||
|
||
// add version with ' instead of ’ | ||
if(strpos($prefix, '’') !== false){ |
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.
Please add a space after if
to keep consistent code style.
foreach(self::LASTNAME_PREFIXES as $prefix){ | ||
$key = strtolower($prefix); | ||
// $key = str_replace(' ', '-', $key); | ||
// $key = str_replace('’', '', $key); |
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.
If you decide these aren't needed, please drop these two lines.
// $key = str_replace('’', '', $key); | ||
$prefixMap[$key] = $prefix; | ||
|
||
// add version with ' instead of ’ |
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.
We prefer to let the code speak for itself unless a comment is required to explain the background/reasoning of the implementation. I would suggest to drop this comment.
@micschk are you ok if we finish your PR in order to get it merged? |
@rvanlaak That'd be great, thanks! |
I've created a Dutch version, it's just not totally clear to me what's the purpose & specific requirements to the keys of the language arrays. I figured they're just references but they may have something to do with 'normalizing'(?) Not sure, hope they're OK like this.