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

awesome-pages and i18n compatibility using .pages #58

Open
Argald0 opened this issue Jan 15, 2022 · 4 comments
Open

awesome-pages and i18n compatibility using .pages #58

Argald0 opened this issue Jan 15, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@Argald0
Copy link

Argald0 commented Jan 15, 2022

Hi there !

I have just read the issues on @ultrabug's i18n compatibility with awesome-pages from the end of 2021, and from what I read I understood that everything works fine unless there is something unexpected in the mkdocs.yml such as .... Knowing this issue, I decided to go for a .pages file, but I do get 404 errors.

I wasn't sure whether I should put it here or as ultrabug's plugin issue, but I believe I'm doing something wrong with the .pages file, that's why I'm posting here. Would you mind giving it a look plz ?

First of all, I have this project :
image

mkdocs.yml
docs/
├─ .pages 
├─ index.md
├─ index.fr.md
├─ file2.md
└─ file2.fr.md

With this mkdocs.yml :

site_name: My Docs
theme:
  name: material
  font:
    text: Ubuntu
    code: Ubuntu Mono
  palette:
    scheme: slate
    primary: blue grey
    accent: amber
extra:
  alternate:
    - name: English
      link: ./
      lang: en
    - name: Français
      link: ./fr/
      lang: fr
plugins:
    - search
    - awesome-pages
    - i18n:
        default_language: en
        languages:
          en: english
          fr: français
        nav_translations:
          fr:
            'Welcome': 'Bienvenue'
            'File 2 awesome pages': 'Fichier 2 awesome pages'

This is what my .pages file looks like :

nav:
    - Welcome: index.md
    - File 2 awesome pages: file2.md

While browsing the mkdocs serve, if I change the language from default (english) to french, and try to access one of the pages it outputs a 404 error :
image

Whereas if I stay in the default language it doesn't :
image

I also notice that when clicking on a page, the url is /file2.md whereas it should be /fr/file2 : back in the default language instead of staying in the fr part.

Thank you in advance ! 😄

@lukasgeiter
Copy link
Owner

Yeah I can absolutely reproduce this problem and I also understand what's happening.

When configuring the navigation in mkdocs.yml, the i18n plugin patches the entries to reflect the language it's currently processing. For example when building the French version, it will turn index.md into index.fr.md.

.pages files are not patched this way, so it's trying to find index.md which doesn't exist in the French version. As a fallback, awesome-pages treats Welcome: index.md as a relative link to index.md, resulting in the behavior you're seeing.

Unfortunately, I'm not sure how a good solution would look like. Maybe @ultrabug has an idea?

@lukasgeiter lukasgeiter added the bug Something isn't working label Jan 25, 2022
@Dryamov
Copy link

Dryamov commented Feb 10, 2022

Any ideas?

@ultrabug
Copy link

ultrabug commented Feb 22, 2022

Well @lukasgeiter is not wrong I guess tho i18n does not "turn" index.md to index.fr.md, it just uses as the source of the index file because that's how mkdocs build process works.

@Argald0 you should go fully with the .pages approach and use strict: false option of awesome-pages.

That's how I do it on my own website so you have a working example there.

Which means in your case that you should not use titles in your .pages nav, just use:

nav:
    - index.md
    - index.fr.md
    - file2.md
    - file2.fr.md

and

plugins:
    - search
    - awesome-pages:
        strict: false

EDIT: yes, the build process will complain for missing pages depending on the locale being built, but that's fine.

hayato-m126 added a commit to tier4/driving_log_replayer that referenced this issue Oct 17, 2022
hayato-m126 added a commit to tier4/driving_log_replayer that referenced this issue Oct 20, 2022
hayato-m126 added a commit to tier4/driving_log_replayer that referenced this issue Nov 4, 2022
closes: #1 

* docs: add mkdocs i18n

* docs: page in i18n

lukasgeiter/mkdocs-awesome-pages-plugin#58

* docs: add files

* docs: introduction

* docs: introduction preparation

* docs: introduction

* docs: update

* docs: update scenario format

* docs: update scenario format

* docs: result format

* docs: result format

* chore: git mv

* docs: add use_case english

* docs: update localization

* docs: update localization

* docs: update obstacle_segmentation

* docs: update obstacle_segmentation

* docs: update perception

* docs: update perception.en.md

* docs: update performance_diag

* docs: update performance_diag.en.md

* chore: update index.en.md

* fix: pre-commit

* Apply suggestions from code review

markdown style: "code", "emphasis"
correct grammar errors

Co-authored-by: Michał Kiełczykowski <88498438+kielczykowski-rai@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Michał Kiełczykowski <88498438+kielczykowski-rai@users.noreply.github.com>

* docs: fix typo

* docs: update i18n information

* Update docs/result_format/index.en.md

jsonl fomat

Co-authored-by: Michał Kiełczykowski <88498438+kielczykowski-rai@users.noreply.github.com>

* docs: update why JSONL format

* Update docs/scenario_format/index.en.md

scenario description

Co-authored-by: Michał Kiełczykowski <88498438+kielczykowski-rai@users.noreply.github.com>

* docs: update description of vehicle_id

* chore: move sample folder

* docs: update converge evaluation start condition

* docs: update perception onnx conversion

* docs: delete scenario time unit

* Update docs/use_case/localization.en.md

localization input bag topic list

Co-authored-by: Michał Kiełczykowski <88498438+kielczykowski-rai@users.noreply.github.com>

* Update docs/use_case/perception.en.md

Co-authored-by: Michał Kiełczykowski <88498438+kielczykowski-rai@users.noreply.github.com>

* Update docs/use_case/perception.en.md

Co-authored-by: Michał Kiełczykowski <88498438+kielczykowski-rai@users.noreply.github.com>

* docs: update perception launch sensing module

* docs: add hyperlink

* Update docs/use_case/performance_diag.en.md

Co-authored-by: Michał Kiełczykowski <88498438+kielczykowski-rai@users.noreply.github.com>

* docs: setting file creation

* docs: obstacle segmentation point cloud error hz

* docs: Example usage flow

* fix: lint, format

* fix: spell check

* docs: mkdocs setting

* docs: quick start

* fix: markdown lint

* chore: git mv

* docs: update overview

* docs: update run.md

* chore: git mv

* chore: git mv

* docs: update setup

* fix: yaml lint

* fix: sample directory path

* docs: update

* docs: add make map directory

* docs: make dataset directory

* Update docs/quick_start/setup.en.md

Co-authored-by: Michał Kiełczykowski <88498438+kielczykowski-rai@users.noreply.github.com>

* Update docs/quick_start/installation.en.md

Co-authored-by: Michał Kiełczykowski <88498438+kielczykowski-rai@users.noreply.github.com>

* docs: delete unnecessary sentence

Co-authored-by: Michał Kiełczykowski <88498438+kielczykowski-rai@users.noreply.github.com>
@kamilkrzyskow
Copy link
Contributor

Using a more dynamic nav like this allows to prevent warnings:

nav:
    - ... | index*.md
    - section_dir
    - ...

I didn't run across any issues with this approach yet 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants