-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Improve world-readiness of initials algorithm #1106
Conversation
This will enable easy unit testing, re-use, etc. going forward.
Add some special-case handling for: 1) Chinese and Korean names for which the rules for latin-alphabet names produce non-sensical results. 2) Arabic names for which the latin-rules produce potentially offensive results due to ligature contraction. Note that both of these world-readiness fixes are guaranteed to keep the existing contract that the initials function returns at most 2 characters.
@c-w, |
Putting this onto the radar of @cliffkoh. |
@c-w Thanks for the PR. Just wondering, did you get a chance to test if 2 asian characters (Chinese or Korean) would fit within the Persona textboy? We could possibly augment the Persona example page to include such an example which would also provide a convenient way to validate this scenario... |
}); | ||
|
||
it('calculates an expected initials for Chinese names', () => { | ||
let result = getInitials('桂英', 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.
Very common for Chinese to have 3 characters, sometimes even 4. It would be great to have one such test, just to ensure for instance that no more than 2 characters are returned.
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.
Good catch. Will add another test.
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.
Added test in f414fd5.
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.
Thank you for this, could you please include a change file as well? (which can be generated using rush change
, or you could copy the change file format from another PR if not using the rush tool)
We need to ensure that even for names with three or more characters, the generated initials don't contain more than two characters.
When I run |
@cliffkoh: Addressed all the comments. Could you please take another look? |
{ | ||
"packageName": "office-ui-fabric-react", | ||
"comment": "Improve abbreviation of non-Latin names in Persona component", | ||
"type": "minor" |
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.
strictly speaking, a patch change because the API surface did not change
Pull request checklist
Description of changes
This change improves the world-readiness of the initials algorithm.
Specifically, it adds some special-case handling for:
Chinese and Korean names for which the rules for latin-alphabet names
produce non-sensical results.
Arabic names for which the latin-rules produce potentially offensive
results due to ligature contraction.
Note that both of these world-readiness fixes are guaranteed to keep the existing contract that the initials function returns at most 2 characters.
Focus areas to test
Persona component, especially with non-Latin scripts.