Skip to content

Conversation

@derfalx
Copy link

@derfalx derfalx commented Aug 5, 2025

Within the citation plugin currently the languages is set using the language from the quartz-configuration:

lang: ctx.cfg.configuration.locale ?? "en-US",

But, per default the rehype-citation project only supports en-US, as explained here: timlrx/rehype-citation#12
For other languages one can provide a locale-file either by passing its path or providing an URL. The following repository contains locale files for multiple languages:
https://github.com/citation-style-language/locales

These are used, in case a non en-US language is used in quartz. But this optimistically assumes there is indeed an according locale file.

let lang: string = "en-US"
if (
  ctx.cfg.configuration.locale !== null &&
  ctx.cfg.configuration.locale !== undefined &&
  ctx.cfg.configuration.locale !== "en-US"
) {
  lang =
    "https://raw.githubusercontent.com/citation-style-language/locales/refs/heads/master/locales-" +
    ctx.cfg.configuration.locale +
    ".xml"
}

In the end this solves the problem only partially, since there are still some languages which will not work properly.

P.S. since I am not proficient in typescript / javascript: if there is something wrong / missing, just let me know

derfalx added 2 commits August 5, 2025 21:04
Per default the rehype-citation project only supports en-US, as
explained here: timlrx/rehype-citation#12
For other languages one can provide a locale-file either by passing
its path or providing an URL. The following repository contains locale
files for multiple languages. So, these are used, in case a non en-US
language is used in quarzt. But this optimistically assumes there is
indeed an according locale file.

In summary this solves the problem only partially, since there are
still some languages which will not work properly.
@github-actions
Copy link

github-actions bot commented Aug 5, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
quartz ✅ Ready (View Log) Visit Preview 5488f0e
Comment on lines 34 to 35
ctx.cfg.configuration.locale !== null &&
ctx.cfg.configuration.locale !== undefined &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the default assignment on line 32, these will never be true.

Copy link
Author

@derfalx derfalx Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if I am missing something. But the assignment on line 32 shouldn't influence the content of ctx.cfg.configuration.locale, or am I wrong?

Edit: I just checked it once more and it works as I would expect. But still I may be missing something.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is that due to the default assignment, if the user does not configure any locale, it will still not be null nor be undefined. Therefore those two checks can be removed from the if-statement.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. I missed how exactly the !== (and ===) operator works in Typescript. I will fix and commit the changes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah TypeScript/Javascript has a lot of weird quirks. These are mostly due to historical reasons and the aim for nearly boundless backwards-compatibility due to being a web-focused language.

For the most extreme of this quirks, see this website: https://jsisweird.com/

@derfalx
Copy link
Author

derfalx commented Oct 2, 2025

Heyho, since I got no further response / hint regarding required fixes / improvments: Is anything still required, before the PR can be merged?

@saberzero1
Copy link
Collaborator

Heyho, since I got no further response / hint regarding required fixes / improvments: Is anything still required, before the PR can be merged?

Apologies for the delayed response.

Thanks for addressing the requested changes. I'll pass this to the other maintainers to do a final check before merging.

@saberzero1
Copy link
Collaborator

@aarnphm do we need to make additional changes to comply with this? https://github.com/citation-style-language/locales?tab=readme-ov-file#licensing

@derfalx
Copy link
Author

derfalx commented Oct 3, 2025

No problem, and thanks for your quick reply! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants