Language-Aware Lowercasing in Title Case Conversion

edited 5 days ago
Now, in the context menu of the title field, the "Sentence Capitalization" call Zotero.Utilities.sentenceCase internally uses String.prototype.toLowerCase(), which can cause errors in certain languages, such as Turkish.

Details can be read here: https://github.com/northword/zotero-format-metadata/issues/308
(Although this is feedback for the plugin, the built-in sentenceCase method in Zotero also has the same issue).

Perhaps we should use String.prototype.toLocaleLowerCase() to solve this problem?

> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase

Here is a simple example:


const dotted = "İstanbulI";

console.log(`EN-US: ${dotted.toLocaleLowerCase("en-US")}`);
console.log(` ${dotted.toLowerCase()}`);

console.log(`TR: ${dotted.toLocaleLowerCase("tr")}`);
console.log(` ${dotted.toLowerCase()}`);

"EN-US: i̇stanbuli"
" i̇stanbuli"
"TR: istanbulı" // Expected in tr
" istanbuli"


By the way, if you think it's acceptable to use `String.prototype.toLocaleLowerCase()` and introduce an optional parameter `locale` for `Zotero.Utilities.sentenceCase`, I'd be happy to send a PR.
Sign In or Register to comment.