Skip to content
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

Not yet translated files in duplicated navigation entry #300

Open
WizzardMaker opened this issue Apr 15, 2024 · 2 comments
Open

Not yet translated files in duplicated navigation entry #300

WizzardMaker opened this issue Apr 15, 2024 · 2 comments

Comments

@WizzardMaker
Copy link

I'm currently building a documentation site and stumbled across this bug while migrating my translations.
The used docs_structure is folder and I'm using mkdocs-material.

Translation fallback files get sorted in a separate navigation entry with the same name:
image

Here, S3/Mana and magic/Test is supposed to be filed with all other entries in S3/Mana and magic/ above.

This is my mkdocs.yml:

site_name: Settlers United Documentation

docs_dir: '../docs/'
extra_css:
  - stylesheets/extra.css


theme:
  favicon: assets/favicon.webp
  logo: assets/favicon.webp
  features:
    - content.tooltips
    - announce.dismiss
    - search.suggest
    - search.highlight
  name: material
  palette:
    scheme: slate
    primary: black
    accent: deep orange

markdown_extensions:
  - attr_list
  - abbr
  - md_in_html
  - tables
  - admonition
  - pymdownx.details
  - pymdownx.highlight:
      anchor_linenums: true
      line_spans: __span
      pygments_lang_class: true
  - pymdownx.inlinehilite
  - pymdownx.snippets
  - pymdownx.superfences
  - pymdownx.tabbed:
      alternate_style: true


plugins:
  - search
  - i18n:
      fallback_to_default: true
      reconfigure_material: true
      reconfigure_search: true
      docs_structure: folder
      languages:
        - locale: en
          default: true
          name: English
          build: true
        - locale: de
          name: Deutsch
          site_name: Settlers United Dokumentation
          build: true

The folder structure is as follows (truncated for only necessary parts)

config/
  mkdocs.yml
docs/
  assets/
  de/
    S3/
      mana-and-magic/
        area-of-effect.md
        basics.md
        cost-progression.md
        table-of-knowledge.md
  en/
    S3/
      mana-and-magic/
        area-of-effect.md
        basics.md
        cost-progression.md
        table-of-knowledge.md
        test.md
        

I don't know if I configured something wrong with this plugin or if mkdocs-material is breaking something

@AngryMane
Copy link
Contributor

@WizzardMaker (CC: @ultrabug )
This issue was quite easy to reproduce using the provided mkdocs.yaml.

Conclusion

mkdocs-static-i18n needs to modify reconfigure_navigation in folder.py.

Detail

For example, consider the following directory structure:

  • docs
    • en
      • S3
        • test1.md
        • test2.md
    • den
      • S3
        • test2.md
        • test3.md

reconfigure_navigation removes the language info from the path, so the nav is modified as follows:

  • docs
    • S3
      • test1.md
      • test2.md
    • S3
      • test2.md
      • test3.md

After this, there is no process to merge the same S3 directories, so nav_item.html in mkdocs-material renders each as a separate item, resulting in the problem you pointed out.

@AngryMane
Copy link
Contributor

@WizzardMaker @ultrabug
I think the problem pointed out in this issue will be resolved by the following modifications.
main...AngryMane:mkdocs-static-i18n:issue_300

However, I'm aware of another issue where the sidebar display state is reset when transitioning from a page in a non-default language to a page that only exists in the default language(=fallback page).

I don't think this is related to my PR because I can reproduce this problem without my PR, but I think it needs to be fixed.
I'll do a little investigation but if I can't find the cause, I will issue a PR for the current fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants