Closed ComeOutToPlay closed 9 years ago
The method that does the conversion is readableColumnName.
The code that appears to cause the problem is:
.replace(/(\w+)/g, function (match) {
return angular.uppercase(match.charAt(0)) + match.slice(1);
})
Regex isn't really my thing, but if we can provide an alternative regex that correctly capitalises the first letter of words, but doesn't have the problem of capitalising letters after an accent, it should be reasonably simple to change it.
I am not an regex expert too, but with your help, I can replace ui-grid code with this code
// Capitalize the first letter of words .replace(/([\wáéíóúüñ]+)/g, function (match) { return angular.uppercase(match.charAt(0)) + match.slice(1); })
And that works for spanish! But I do not know what happens for other languages.
You can test it at https://regex101.com/ References for further research: http://unicode-table.com/en/#00FC
This link gives some other options: http://stackoverflow.com/questions/5436824/matching-accented-characters-with-javascript-regexes
I wonder about something like:
// Capitalize the first letter of words
.replace(/([\w\u00C0-\u017F]+)/g, function (match) {
return angular.uppercase(match.charAt(0)) + match.slice(1);
That doesn't deal properly with upper/lowercase accented characters, but seems to me that in this context it'll probably work fine.
I'm not sure whether angular.uppercase deals with accents.
Hello.
At grid column definition, when I put a name with accent, like Descripción, it capitalizes the last letter.
columnDefs: [ { name:'Descripción', field: 'first-name' }, { name:'1stFriend', field: 'friends[0]' }, { name:'city', field: 'address.city'}, { name:'getZip', field: 'getZip()', enableCellEdit:false} ], Regards,
Fernando
http://plnkr.co/edit/JrTbzI78isMYhJmTk56u?p=preview