ultrabug / mkdocs-static-i18n

MkDocs i18n plugin using static translation markdown files
https://ultrabug.github.io/mkdocs-static-i18n/
MIT License
219 stars 37 forks source link

Having issues building my translations after updating it to 1.0.0 #285

Closed MetalKnight56 closed 6 months ago

MetalKnight56 commented 6 months ago

Ok so i'm using the mkdocs-static-i18n which allowed me to localize each page according to any language i want to add. Before updating my plugin version, it all worked fine, but now for some reason on my local enviroment, it all works fine, the url looks like this when in english https://epicfight-docs.readthedocs.io/en and this when in spanish https://epicfight-docs.readthedocs.io/es

! but when building my mkdocs documentation on my readthedocs account, intead of it working like it does locally, the url looks like this when in english !

https://epicfight-docs.readthedocs.io/en/latest/

and this when in spanish or any other language

https://epicfight-docs.readthedocs.io/en/latest/es/

PS - As you can see above, if you try to change the language when in the index/home lets say from "en -> es" it also breaks the page displaying some big icons and weird things - which you can see here - https://epicfight-docs.readthedocs.io/es/

Mind that the issue is after building the documentation, it all worked fine when i used to do "mkdocs serve" Here's my docs's mkdocs.yml file - https://github.com/MetalKnight56/EpicFight-Docs/blob/main/mkdocs.yml And here's my docs file structure (i use suffix) - https://github.com/MetalKnight56/EpicFight-Docs/tree/main/docs

kamilkrzyskow commented 6 months ago

Hello @MetalKnight56, looking at https://readthedocs.org/projects/epicfight-docs/ it seems that ReadTheDocs itself sets /en/latest/ as the root / page of the project. I don't understand why it adds /en/ before the /latest/.

The i18n 1.0 plugin creates the default language at the / root directory and then creates subsequent languages at /lang_code/. Before in 0.53 it would also duplicate the default language in it's own /lang_code/ path.

It's hard to tell what's the issue here as the behaviour didn't change so much. You could try setting the site_url in your mkdocs.yml https://www.mkdocs.org/user-guide/configuration/#site_url to https://epicfight-docs.readthedocs.io/ Other than that investigate ReadTheDocs to find how it sets the / directory.

MetalKnight56 commented 6 months ago

Hello @MetalKnight56, looking at readthedocs.org/projects/epicfight-docs it seems that ReadTheDocs itself sets /en/latest/ as the root / page of the project. I don't understand why it adds /en/ before the /latest/.

The i18n 1.0 plugin creates the default language at the / root directory and then creates subsequent languages at /lang_code/. Before in 0.53 it would also duplicate the default language in it's own /lang_code/ path.

It's hard to tell what's the issue here as the behaviour didn't change so much. You could try setting the site_url in your mkdocs.yml mkdocs.org/user-guide/configuration/#site_url to https://epicfight-docs.readthedocs.io/ Other than that investigate ReadTheDocs to find how it sets the / directory.

The thing that is weird is the fact that before when i used "0.56" version of i18n it all worked just fine, because it would add the lang code even after selecting any page including the index.en so for example when you click on a language when on index.en it would look something like this the url https://epicfight-docs.readthedocs.io/en/latest/pt/ but now it just does this - https://epicfight-docs.readthedocs.io/pt/

kamilkrzyskow commented 6 months ago

If you're saying that https://epicfight-docs.readthedocs.io/en/latest/pt/ is correct, then try setting the site_url to https://epicfight-docs.readthedocs.io/en/latest/, but to me it's weird that there is both en and pt.

MetalKnight56 commented 6 months ago

If you're saying that https://epicfight-docs.readthedocs.io/en/latest/pt/ is correct, then try setting the site_url to https://epicfight-docs.readthedocs.io/en/latest/, but to me it's weird that there is both en and pt.

Ok i found the solution to it, but it just gave me a huge headache. So ReadTheDocs allows me to change how they build the versioning scheme. If anyone ever has the same issue as me, here's the reference - https://docs.readthedocs.io/en/latest/versioning-schemes.html#

Just gotta change a setting on the admin panel>adavanced options and change the versioning scheme to Single version

(Mind that it took me like 10 minutes or so for the changes to apply + it broke all links i had on my other pages...)

Here's the new page - https://epicfight-docs.readthedocs.io/

kamilkrzyskow commented 6 months ago

Did you try using site_url or not? I believe it would allow you to keep the old links working.

MetalKnight56 commented 6 months ago

Did you try using site_url or not? I believe it would allow you to keep the old links working.

didn't actually try that, but i mean, just converted the links its fine, i agree with you that it did look weird so i kinda stopped stalling and got to fix that as well

kamilkrzyskow commented 6 months ago

You could override the 404.html template with a version that contains a JavaScript redirection script based on the URL for old links.

MetalKnight56 commented 6 months ago

You could override the 404.html template with a version that contains a JavaScript redirection script based on the URL for old links.

That's a good idea, I'll try it