Skip to content
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

[Bug] 仅当姓名全大写或全小写时执行大写转换 #111

Closed
northword opened this issue Jan 2, 2024 · 4 comments
Closed

[Bug] 仅当姓名全大写或全小写时执行大写转换 #111

northword opened this issue Jan 2, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@northword
Copy link
Owner

northword commented Jan 2, 2024

目前的方法可能会将部分姓名(比如下面的例子)错误地转为大写。按照 APA 的要求 姓名的大小写应遵循本人的偏好。建议限制范围,比如仅当姓(或名)为全大写或全小写时进行转换。

  1. 部分西方人名的 particle,比如“van der Waal, P. N.”、“d’Aubignac”、“Jean de La Fontaine”。
  2. 有的阿拉伯人的姓以小写字母开头,比如“ʿAlāʾ al-Aswānī”。

Originally posted by @zepinglee in #47 (comment)

@github-project-automation github-project-automation bot moved this to 🆕 Needs Triage in @northword's Zotero Jan 2, 2024
@northword northword added the bug Something isn't working label Jan 2, 2024
@northword northword moved this from 🆕 Needs Triage to 🏗 In progress in @northword's Zotero Jan 2, 2024
@zepinglee
Copy link

我又试了一下,发现只有“van der Waal”和“Jean de La Fontaine”会分别被错误地转为“Van Der Waal”和“Jean De La Fontaine”,“d’Aubignac”和“al-Aswānī”保持不变。这是因为 Zotero.Ultilities.capitalizeName 仅转换全大写或全小写的 word(part.toUpperCase() === part || part.toLowerCase() === part)。

我建议将这一条件进一步限制为“lastName(或 firstName)为全大写或全小写”。

https://github.com/zotero/utilities/blob/9c89b23153ce621ed0f1d581a5e32248704c6fb7/utilities.js#L199-L217

@northword
Copy link
Owner Author

    apply(item: Zotero.Item): Zotero.Item | Promise<Zotero.Item> {
        const creators = item.getCreators();

        for (const creator of creators) {
            creator.firstName =
                isFullUpperCase(creator.firstName!) || isFullLowerCase(creator.firstName!)
                    ? Zotero.Utilities.capitalizeName(creator.firstName!.trim())
                    : creator.firstName;
            creator.lastName =
                isFullUpperCase(creator.lastName!) || isFullLowerCase(creator.lastName!)
                    ? Zotero.Utilities.capitalizeName(creator.lastName!.trim())
                    : creator.lastName;
        }
        item.setCreators(creators);
        return item;
    }

@zepinglee
Copy link

    apply(item: Zotero.Item): Zotero.Item | Promise<Zotero.Item> {
        const creators = item.getCreators();

        for (const creator of creators) {
            creator.firstName =
                isFullUpperCase(creator.firstName!) || isFullLowerCase(creator.firstName!)
                    ? Zotero.Utilities.capitalizeName(creator.firstName!.trim())
                    : creator.firstName;
            creator.lastName =
                isFullUpperCase(creator.lastName!) || isFullLowerCase(creator.lastName!)
                    ? Zotero.Utilities.capitalizeName(creator.lastName!.trim())
                    : creator.lastName;
        }
        item.setCreators(creators);
        return item;
    }

LGTM.

@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in @northword's Zotero Jan 2, 2024
Copy link

github-actions bot commented Jan 2, 2024

🚀 This ticket has been resolved in v1.8.0. See Release 1.8.0 for release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants