ultrabug / mkdocs-static-i18n

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

Adding hooks to mkdocs.yml causes the build to fail. #160

Closed try0 closed 1 year ago

try0 commented 1 year ago

https://www.mkdocs.org/user-guide/configuration/#hooks

mkdocs.yml

plugins:
  - i18n:
      default_language: ja
      languages:
        en: 
          name: English
          site_name: Site Name
        ja:
          name: 日本語
      nav_translations:
        en:
          よくある質問(FAQ): FAQ

hooks:
  - hooks.py

version: 0.50

https://github.com/ultrabug/mkdocs-static-i18n/blob/main/mkdocs_static_i18n/plugin.py#L226

Traceback (most recent call last):
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs\commands\build.py", line 270, in build
    config = config.plugins.run_event('config', config)
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs\plugins.py", line 520, in run_event
    result = method(item, **kwargs)
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs_static_i18n\plugin.py", line 226, in on_config
    self.i18n_configs[language] = deepcopy(config)
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\copy.py", line 270, in _reconstruct
    state = deepcopy(state, memo)
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "C:\Users\user-name\AppData\Local\Programs\Python\Python39\lib\copy.py", line 161, in deepcopy
    rv = reductor(4)
TypeError: cannot pickle 'module' object
ultrabug commented 1 year ago

Thanks for reporting this @try0 ; it's true that I have not tested this plugin with the latest mkdocs features so there might be quirks :(

ultrabug commented 1 year ago

The fix is on its way and will be available in version 0.51 @try0

try0 commented 1 year ago

@ultrabug

Thanks for supporting the hooks. I will try to update and build our documents.

ありがとうございました!

ultrabug commented 1 year ago

どういたしまして!