-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
the footnote label "Footnotes" should be able to be translated #9502
Comments
We have to read |
remark-rehype has the options. Should be in both projects' docs! |
Thanks! Ref: https://github.com/remarkjs/remark-rehype#example-footnotes-in-languages-other-than-english So it looks like a possible solution: compile(
{value: '…'},
{remarkRehypeOptions: {footnoteLabel: 'Fußnoten'}}
) I guess we could expose the whole MDX option object and deep merge it for maximum flexibility (although it expose the ability to break things? 🤔 ), or eventually just the |
This is it. I have noticed it too several days ago but forgotten to tell it to correct my misuses guess. I am sorry for that. I wonder if we should generate processor instances (the return value of docusaurus/packages/docusaurus-mdx-loader/src/processor.ts Lines 159 to 169 in 17c93e4
Shall we add an additional argument const processorOptions: ProcessorOptions & Options = {
...options,
remarkPlugins,
rehypePlugins,
remarkRehypeOptions: {
// this function translaveFootnoteLabel must be defined at another place by ourselves
footnoteLabel: translateFootnoteLabel(language),
},
providerImportSource: '@mdx-js/react',
}; |
PR to track: #9674 |
It would be the best if the translated footnote label strings were out of the box. |
Can we use |
Agree, not sure where to store those translations though, maybe we could rename the Our problem is that we probably want external contributors to find and translate those strings, and introducing another folder to translate is not going to help.
I'd prefer to pass the locale as mdx loader parameter instead of relying on this env variable for now. It's more explicit and testable. But if we store translations there, who will be responsible to translate those strings? cc @wooorm, any interest to maintain an official repo with footnote label translations? 🤪 I guess other MDX-based projects could benefit from this. |
It’s not specific to MDX, it’s more a GFM markdown thing. I can also see other websites wanting different labels. This value is what GH uses but on your own blog something else might be better. Now, docusaurus probably already has certain other values that it translates, to me this is a better place to maintain and configure this? |
@wooorm yes we have other values that we translate, and it makes sense to let site owners decide on the final label they want for their site. However providing localized labels out of the box as a fallback would be convenient for the whole community. But it would remain the responsibility of individual projects and users to override those fallback labels if they are not good enough. |
Just feels weird setting up an i18n system in micromark-extension-gfm-footnote or mdast-util-to-hast where folks can PR different files, say i18n/pt.js and such, and other folks use one key "label" from there. Perhaps also needs a template language and to deal with plurals for backlinks? That doesn't feel very "out of the box" for me. |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
By the upgrade of the MDX plugin, the border of the document body and the footnotees has been changed from
<hr>
to the English-fixed heading. I couldn't find a way to change the language of the heading.Some remark and related plugins can customize the "Footnotes" label by the option passed to
mdast-util-to-hast.toHast
.https://github.com/remarkjs/remark-rehype#fields
https://github.com/remarkjs/remark-rehype#example-footnotes-in-languages-other-than-english
https://github.com/remarkjs/remark-html#options
https://github.com/syntax-tree/mdast-util-to-hast#footnotes
https://github.com/micromark/micromark-extension-gfm-footnote#label
Reproducible demo
WIP
Steps to reproduce
docs
docusaurus start
Expected behavior
The footnote label is that in the language of your language (e.g. "脚注" in Japanese)
Actual behavior
Always "Footnotes" regardless of your language
Your environment
Self-service
↑ If easy to fix, but doesn't seem
The text was updated successfully, but these errors were encountered: