mkdocs-static-i18n: Issue with incorrect language folder being copied

The contents of the mkdocs.yml file are as follows:

‘’’ site_name: ‘Guide’ site_description: Documentation docs_dir: docs/IDE/

extra_css:

  • stylesheets/extra.css

theme: name: material features: - content.tooltips - navigation.tracking - navigation.expand - content.code.copy - content.code.select - content.code.annotate - content.footnote.tooltips

palette:
  # Palette toggle for automatic mode
  - media: "(prefers-color-scheme)"
    toggle:
      icon: material/brightness-auto
      name: Switch to light mode

  # Palette toggle for light mode
  - media: "(prefers-color-scheme: light)"
    scheme: default 
    toggle:
      icon: material/brightness-7
      name: Switch to dark mode

  # Palette toggle for dark mode
  - media: "(prefers-color-scheme: dark)"
    scheme: slate
    toggle:
      icon: material/brightness-4
      name: Switch to system preference

extra: social: - icon: fontawesome/brands/github link: site - icon: fontawesome/brands/slack link: site tags: <tag>: <identifier> generator: true

markdown_extensions:

  • meta
  • footnotes
  • attr_list
  • abbr
  • pymdownx.tasklist: custom_checkbox: true
  • md_in_html
  • tables
  • admonition
  • def_list
  • pymdownx.superfences
  • pymdownx.highlight: anchor_linenums: true line_spans: __span pygments_lang_class: true
  • pymdownx.inlinehilite
  • pymdownx.snippets
  • pymdownx.tabbed: alternate_style: true

plugins:

  • search
  • tags
  • i18n: docs_structure: folder languages: - locale: en name: English build: true - locale: ko name: Korean build: true default: true - locale: ja name: Japan build: true`

The folder structure is as follows:

docs / ko / index.md ko_folder / ko_index.md en / index.md en_folder / en_index.md ja / index.md ja_folder / ja_index.md ‘’’

When you do mkdocs build, the ko folder is copied to each of the en and ja folders in the site folder. ex) site / ko_index.md a folder / ko_index.md en / en_index.md en_folder / en_index.md ko_folder / ko_index.md ja / index.md ja_folder / ja_index.md ko_folder / ko_index.md

What’s the problem?

  • mkdocs version : 1.5.3
  • python version : 3.7.4
  • mkdocs-static-i18n version : 1.2.1

About this issue

  • Original URL
  • State: open
  • Created 5 months ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

I forgot to mention that the PR got a little fix, after I asked you for the logs 😓, but it doesn’t matter in this scenario. Comparing your prints_i18n.log with the one from my debug-files.zip I get an almost perfect match, minus my Windows paths and 2 more links I had in a file, however this in-part proves the behaviour is the same on my PC and yours. I didn’t yet check the goorm.log too deeply yet, but at a first glance it does seem fine. I don’t see a bug, but see room for improvement for the URL creation.

I think there is in-fact a misunderstanding here. I worked with the assumption that the wrong directory is being copied over into the site after build, but now I’m connecting the dots, and I understand your issue is with the Korean files being inside the en/ directory beside the English ones.

In your mkdocs.yml file you have fallback_to_default: true, here is the documentation: https://ultrabug.github.io/mkdocs-static-i18n/setup/controlling-your-builds/#fallbacking-to-default If there is no file under the same path in the en/ docs directory it will copy it from ko/, as you’re using the Korean letters for Korean version and English letters for English version, then the path is not found and it’s detected as a lacking file in the en/ version compared to the Korean one and then it copies the files over.

So try setting fallback_to_default: false @snowCho and it should help.

I’m sorry. I’m not a developer.

No worries, @snowCho you’re doing great. I saw that after installing the PR version you don’t have the log messages, this showed me an error on my part as I limited the print output to only 2 specific paths 😓 if path in ("de_CH/legal/website.md", "bot/selfhosting.md"):, so of course you don’t have any additional debug information, as you don’t have those paths. Sorry for the confusion. It would make it easier to read if you just attached the mkdocs.yml file directly instead of copying the text as the formatting breaks, or perhaps you’re not using 3 ticks ``` to create code blocks, a single tick ` isn’t enough for multiline code. Or zip the directory if possible and attach it here for investigation, but first with the new information provided I have a few comments:

  • In this message on the most bottom screenshot I see that you’re accessing the fr/ page, and the page’s content is in French as intended, the navigation on the left is of mixed language as the folder names aren’t translated in the mkdocs.yml and some files also have English titles.
Video of the built site

https://github.com/ultrabug/mkdocs-static-i18n/assets/34622465/a646ec3f-e56d-49d5-a095-b2b0abbd41cf

At the end I switched from French to English and the path used was en/, because you configured it like that with the link /en/, but the plugin doesn’t use the link to change the path of the files it uses it only for the alternate language switcher creation. Perhaps this could be seen as a bug, but I’m not so sure.


Please provide more information as after you accessed fr/ wanting it to be English I feel like there might be some misunderstanding 🤔 I’ve updated the PR branch, so you can reinstall it

pip uninstall mkdocs-static-i18n
pip install git+https://github.com/kamilkrzyskow/i18n.git@fix/folder-with-tests

Then with the docs_folder_structure_two_languages please run:

mkdocs build > prints_i18n.log
mkdocs build > full_i18n.log 2>&1

Then with your own Korean Guide of goormIDE documentation please run:

mkdocs build > prints_goorm.log
mkdocs build > full_goorm.log 2>&1

Those last commands should create log files you can attach to the message / drag & drop will work as well. debug-files.zip

@snowCho Oh, I’m surprised that the issue is in 1.2.0 this could mean that the issue was there from 1.0.0 🤔 Please check it with PR with pip install git+https://github.com/kamilkrzyskow/i18n.git@fix/folder-with-tests Also it would be great if you could show the debug information for a path that was incorrectly copied for the different languages:

path='de_CH/legal/website.md'
current de_CH
is_relative_to(de_CH\legal\website.md, de_CH) -> True
default en
is_relative_to(de_CH\legal\website.md, en) -> False
expected_src_uris:
0 de_CH\legal\website.md
1 en\legal\website.md
2 legal\website.md

this could perhaps explain some more about the issue 🤔

I dropped the 1.2.1 from PyPI, seemed the fastest.

We’ll have to get correct tests up for the fix.

Hello @snowCho, could you please check with plugin version 1.2.0? Perhaps my file lookup fix in 1.2.1 broke this. 🤔 Also as a side note Python 3.7 is quite old, consider updating to 3.12 this won’t help with the bug, but should improve performance etc.