ultrabug / mkdocs-static-i18n

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

Build fails: “TypeError: 'NoneType' object is not iterable” #152

Closed xplosionmind closed 1 year ago

xplosionmind commented 1 year ago

I am getting the following log when building https://github.com/scambifestival/manuale (i18n branch)

INFO     -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
              - associazione/README.md
              - burocrazia/README.md
              - comunicazione/README.md
              - eventi-minori/README.md
              - format/README.md
              - merchandising/README.md
              - palanche/README.md
              - relazioni/README.md
              - staff/README.md
              - tools/README.md
              - workflow/README.md
INFO     -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
              - associazione/README.md
              - burocrazia/README.md
              - comunicazione/README.md
              - eventi-minori/README.md
              - merchandising/README.md
              - relazioni/README.md
              - workflow/README.md
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/mkdocs/__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 82, in serve
    builder(config)
  File "/usr/local/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 75, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/usr/local/lib/python3.10/site-packages/mkdocs/commands/build.py", line 302, in build
    nav = config.plugins.run_event('nav', nav, config=config, files=files)
  File "/usr/local/lib/python3.10/site-packages/mkdocs/plugins.py", line 517, in run_event
    result = method(item, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/mkdocs_static_i18n/plugin.py", line 397, in on_nav
    nav = folder_structure.on_nav(self, nav, config, files)
  File "/usr/local/lib/python3.10/site-packages/mkdocs_static_i18n/folder_structure.py", line 348, in on_nav
    for item in self.i18n_navs[language]:
  File "/usr/local/lib/python3.10/site-packages/mkdocs/structure/nav.py", line 39, in __iter__
    return iter(self.items)
TypeError: 'NoneType' object is not iterable
ultrabug commented 1 year ago

@xplosionmind Hi,

There is no it folder in your folder structure and it should since it's your configured default language.

The folder structure is meant to have a convergent tree of files per folder.

xplosionmind commented 1 year ago

Thanks a lot for your reply, @ultrabug!

Can’t I have a folder just for the English content and everything else is in Italian?

ultrabug commented 1 year ago

This is not how it's supposed to work, no @xplosionmind

The "everything else" is meant for stuff that is not "translated/translatable".

xplosionmind commented 1 year ago

Thank you for clarifying that, @ultrabug.

One last question: is it possible to remove the /lang/ slug in URLs for the default language?

ultrabug commented 1 year ago

Yes, just don't list it in the languages config list, just as default_language

xplosionmind commented 1 year ago

Yes, just don't list it in the languages config list, just as default_language

I fear this works only with the suffix mode… The it folder is parsed as a subject if I do not list it in mkdocs.yml

ultrabug commented 1 year ago

Thanks for pointing this out @xplosionmind ; I will look into this as soon as I can.

ultrabug commented 1 year ago

Ok @xplosionmind so you could have this done by setting build: false to it and after #156 is merged and released.

I'd like to still remind you that the folder structure is supposed to be strict in how you structure your folders layout and you should do your best to stick with it. This plugin can't adapt to every layout users may think of I'm sure you understand that.

Once tests pass, I'll merge the #156 PR so that at least the build process do not crash hard on users but report a warning that unpredictable site will be generated.