ultrabug / mkdocs-static-i18n

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

Non localized files missing in not default language #292

Open brospars opened 9 months ago

brospars commented 9 months ago

I recently upgraded to the latest version of this plugin and some of my links are broken because non localized files are not copied in other languages :

docs_dir
├── index.fr.md
├── index.en.md
├── topic1
│   ├── custom_data_file.csv
│   ├── index.en.md
│   └── index.fr.md

Will do :

site
├── fr
│   ├── index.html
│   ├── topic1
│   │   ├── custom_data_file.csv
│   │   └── index.html
├── index.html
├── topic1
│   └── index.html

Where previsously it was :

site
├── fr
│   ├── index.html
│   ├── topic1
│   │   ├── custom_data_file.csv
│   │   └── index.html
├── index.html
├── topic1
│   ├── custom_data_file.csv
│   └── index.html

My custom_data_file.csv file was copied on both languages and I can link to it in my .pages but now it's not working anymore... I understand it's more efficient this way but is there a way to achieve that anyway ?

ultrabug commented 9 months ago

Bonjour Benoit,

I'm surprised by what you're experiencing since you say your tree structure would build as

site
├── fr
│   ├── index.html
│   ├── topic1
│   │   ├── custom_data_file.csv
│   │   └── index.html
├── index.html
├── topic1
│   └── index.html

but in my understanding it should build as

site
├── fr
│   ├── index.html
│   └── topic1
│       └── index.html
├── index.html
└── topic1
    ├── custom_data_file.csv
    └── index.html

Unless your mkdocs.yml says differently? Could you share it?

brospars commented 8 months ago

Hello, Yes my bad I modified it to simplify and made a mistake.

But another related problem is that sometimes images are inserted using html like so :

<figure>
  <img src="Images/TitreActivite.png" alt="Image alt" />
  <figcaption>Image caption</figcaption>
</figure>

with the following structure :

docs_dir
├── index.fr.md
├── index.en.md
├── Images
│   └── TitreActivite.png
site
├── fr
│   ├── index.html
├── index.html
└── Images
    └── TitreActivite.png

So images will work in the default language but not in the others...

kamilkrzyskow commented 8 months ago

Try using the markdown in html extension and use it like the example here: https://squidfunk.github.io/mkdocs-material/reference/images/#image-captions

If you have to use HTML tags then use absolute paths starting with a / or /prefix from your site_url if you're hosting the page on GitHub Pages.