-
Notifications
You must be signed in to change notification settings - Fork 1
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
Wrong abbreviation if the name contains accented characters #5
Comments
The problem is this naive regex vcf-avatar-item/src/vcf-avatar-item.js Line 103 in 6730b95
E.g. using my name as the I think the default abbreviation should be limited to 2 characters anyway since more don't really fit (at least with the default styles). |
I think it might not be easy or maybe not even possible to make this work correctly with all possible names automatically. I think this should be updated with a slightly more complex regex with would handle more of common name formats in a better way than now, but the abbreviation computation algorithm should probably be refactored to a new method which could be overridden by the user in case they need to customize it for some special case. |
What about this? this.abbr = this.abbr || this.name.split(' ').map(n => n[0]).join('').toUpperCase(); |
That's actually a good idea. I think that might be a good enough default. Maybe additionally limit it to 2 characters like so: this.name.split(' ').map(n => n[0]).join('').toUpperCase().substr(0, 2) |
Right, then I'd use |
@heruan Minor drawback with limiting the array length is if the name string accidentally contains more than one space after first name (or if the name is prefixed with at least 2 spaces), it would result in only 1 or 0 characters. My version avoids these issues (since the array will have some See: // using substr()
'Foo Bar Baz'.split(' ').map(n => n[0]).join('').toUpperCase().substr(0, 2); // = 'FB'
' Foo Bar Baz'.split(' ').map(n => n[0]).join('').toUpperCase().substr(0, 2); // = 'FB'
// using split(' ', 2)
'Foo Bar Baz'.split(' ', 2).map(n => n[0]).join('').toUpperCase(); // = 'F'
' Foo Bar Baz'.split(' ', 2).map(n => n[0]).join('').toUpperCase(); // = '' |
I noticed you updated your PR to use |
I noticed this while drafting the PR and I fixed trimming the name and using a regex for the split. |
@Haprog Any chance to have the PR merged? |
@heruan I don't know what is the process or who has the permissions to do so for these component factory components (VCF). I have forwarded your question internally, hopefully someone else can answer. |
@Haprog Any news on this being released? |
Names with accented characters (very common in Italy) get wrong abbreviations, e.g.
is rendered as
MCÀ
instead ofMC
.See Glitch: https://glitch.com/edit/#!/low-buckthorn
The text was updated successfully, but these errors were encountered: