-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
[i18n] Making everything translatable (website title, description...) #4542
Comments
Thanks for the feedback :) This has been reported here too: #4480 I was thinking of adding I think it's a better place to translate content, particularly when you have a long list of locales: not sure we want to maintain a lot of translations in the config. But at the same time, I'd also like a locale to be able to "override" config setting somehow, just not sure what this API should look like and need to think more about this. |
@slorber Agree with you, and yes it is not evident how to design this API... To sum up, here is a small list of untranslatable things I noticed:
Making the above things translatable can avoid unreadable texts for visitors and provide better SEO (better html document title) Other untranslatable things:
|
Thanks @MisterFISHUP for the exhaustive reporting.
Does it make sense? |
@slorber That sounds great! Moreover, the two solutions A few comments:
By the way I noticed the copyright in the footer is often of form |
Another case is the admonitions when they don't have a title: :::caution
We only copy `.md` and `.mdx` files, as pages React components are translated through JSON translation files already.
::: It requires to use We should find a way to provide automatic default admonition titles in the selected language Reported here: #3526 (comment) Remark-admonition issue: elviswolcott/remark-admonitions#35 |
The blog sidebar title is not translatable (reported in #3643 (comment)) See: https://docusaurus.io/fr/blog This label is provided by config for now: |
The DocSearch modal is also not translated currently. We'll have to wait for Algolia to provide APIs to translate it. |
The blog |
Didn't experiment, but could it be translatable by wrapping it with
The translations will still be written in |
The For all other use-cases (including Examples:
|
I'll look into some of them, and it would be great if we can make a task list for this issue |
For the theme config, I think there're a lot that can be translated besides the announcement bar: metadata, light/dark icons, etc. Maybe put them in a |
Yes something like ATM blog tag labels are not translatable, and docs tag labels (#3646) won't either. I don't think it's a very high priority for now (nobody noticed) so we'll figure this one last. |
Not sure what you mean, since at least tags in Markdown front matter are translated once you provide different front matter in the translated MD file? |
Oh you are right didn't think about that 😅 |
It's not possible to customize sidebar items' labels of type doc/ref (only labels provided in the sidebars.json, as the frontmatter such as See comment here: #5593 (comment) |
Has that issue been closed? So it is not going to be implemented? |
Dear developers of Docusaurus: The i18n for the index pages automatically generated by
By the way, I suggest your teams to check your own website. Take a look at this example 🔗, please. I am not sure whether you have written the translation. But the page description is definitely not translated yet. So I suspect that there should be a bug currently. I hope your team can fix this issue soon. Thank you! |
@Josh-Cena Thank you! I will wait for the next release. |
Admonition default titles are now translatable (#7556) (canary or next release) Please help us and provide the missing admonition translations for your language: https://github.com/facebook/docusaurus/tree/main/packages/docusaurus-theme-translations/locales (tip: also provide all the other missing translations at the same time) |
Note for myself: Autogenerated category labels ( |
We don't have a good API design to translate many things of the site config at the moment. However I'd like to present you a temporary workaround introduced in #8677. Your site config will receive a IMPORTANT: the If you decide to use this variable, you'd rather program defensively and assume the locale value might be absent, and fallback yourself to your defaultLocale. 2 possible defensive examples, assuming "en" is your default locale:
function getSiteTagline() {
switch(process.env.DOCUSAURUS_CURRENT_LOCALE) {
case "fr": return "Mon site en Français";
default: return "My English website";
}
} Some cases where
The
Note: I hope this makes sense and is not too confusing. Hopefully, we will provide a better way to translate the config later, but this should be good enough to unlock many use cases. |
Really need it. we sent our docs to a translate platform and push back to i18n dir. now we had to manually update the the image link to another image path and save new img files to a different dir. |
Just for tracking purposes: |
"Recent Post" yazısı niye çevrilmiyor? |
@volkantash you can translate this label thanks to the It's not super convenient, I agree, and we'll try to improve, but at least it is possible. |
I think that @slorber had a point. We have a English site with Japanese and Chinese translation. So in the English version of a blog article we might set a tag like "Product" in the front matter, which would then be "商品" in the Japanese .mdx file. On first view everything looks fine, as we get both a page for the "product" tag as well as for the "商品" tag.
However, we also get two 404 errors, as apparently no direct connection is formed between the English tag and the Japanese tag: Maybe we made a mistake during our setup, but we think that the handling of tags and their translatability should be looked at one more time. |
@kkhr1341 the translation of urls/slugs is not a goal of Docusaurus currently (see https://docusaurus.io/docs/i18n/introduction#i18n-non-goals). It would be quite complicated for us to support it properly, not just for tags but for all other urls as well. However, the problem here is that your tag label is tightly coupled to the tag url segment. This is already possible, with an historical API that is lightly documented but I don't like it much because it's awkward and you'll have to add the permalink to all your docs using this tag, ensuring they remain in sync: tags:
- label: "商品"
permalink: "product" In the future, we'll likely have a |
@alienzhangyw you can use If you prefer to translate things thanks to env vars, you can also delete the generated files here: i18n/en/docusaurus-theme-classic/navbar.json
i18n/en/docusaurus-theme-classic/footer.json You can also remove individual keys from this file, if you only want your config to take over for certain keys. Docusaurus will use this file's labels in priority if it exists, but it can also be "partially complete" and we'll merge labels from your config/env with what's in those files. |
🚀 Feature
First of all, the i18n feature of Docusaurus is terrific, thanks a lot!
It seems that the website's title can't be translated. It's not a big problem if the website title is just a simple name or doesn't have much meaning. However, It's really not ideal especially when the website uses languages that use different alphabet: imagine the main language of the website is Chinese (or Hebrew, Thai, Russian, etc) and the website title is also written in this language, then all final html pages' title will contain this website title, even for pages written in secondary/other languages (English for example), which is a bit bad for viewers and SEO since the website title in the html title is almost unreadable.
Thus, I think it's a good idea to include the possibility to translate the website title in the i18n feature, to improve readability and SEO in the cases illustrated above.
Have you read the Contributing Guidelines on issues?
Yes.
Motivation
See above.
Pitch
It would be great if the website title can be translated just like how the navbar/footer/react code is translated: add translations in some json file in
i18n
directory. Or even better: provide the website title translation ini18n
indocusaurus.config.js
directly (maybe inlocalConfigs
for example, with a optional field for website title translation).PS. Still need to mention this again: thanks for the awesome i18n feature!
TODOs
The text was updated successfully, but these errors were encountered: