i18n_subsites failing with KeyError on _NATIVE_CONTENT_URL_DB[content.source_path]
I am getting following error when trying to use i18n_subsites plugin with default configuration:
DEBUG: Read file pages/en/about.rst -> Page
DEBUG: Signal page_generator_preread.send(PagesGenerator)
DEBUG: Signal page_generator_context.send(PagesGenerator, <metadata>)
DEBUG: Read file pages/en/contact.rst -> Page
DEBUG: Read file pages/cs/about.rst -> Page
DEBUG: Read file pages/cs/contact.rst -> Page
DEBUG: Generating i18n subsite for language 'cz' using class <class 'pelican.Pelican'>
DEBUG: Generating i18n subsite for language 'en' using class <class 'pelican.Pelican'>
DEBUG: i18n: Updating cross-site links and context of all generators.
ERROR: Cannot find translations for language 'en' in '/home/filip/src/domain.tld/theme/translations' with domain 'messages'. Installing NullTranslations.
CRITICAL: KeyError: u'/home/filip/src/domain.tld/content/pages/en/about.rst'
Traceback (most recent call last):
File "/home/filip/virtualenv/pelican27/bin/pelican", line 11, in <module>
sys.exit(main())
File "/home/filip/virtualenv/pelican27/local/lib/python2.7/site-packages/pelican/__init__.py", line 465, in main
pelican.run()
File "/home/filip/virtualenv/pelican27/local/lib/python2.7/site-packages/pelican/__init__.py", line 175, in run
writer = self.get_writer()
File "/home/filip/virtualenv/pelican27/local/lib/python2.7/site-packages/pelican/__init__.py", line 242, in get_writer
writers = [w for (_, w) in signals.get_writer.send(self)
File "/home/filip/virtualenv/pelican27/local/lib/python2.7/site-packages/blinker/base.py", line 267, in send
for receiver in self.receivers_for(sender)]
File "/home/filip/src/domain.tld/pelican-plugins/i18n_subsites/i18n_subsites.py", line 424, in create_next_subsite
new_pelican_obj.run()
File "/home/filip/virtualenv/pelican27/local/lib/python2.7/site-packages/pelican/__init__.py", line 175, in run
writer = self.get_writer()
File "/home/filip/virtualenv/pelican27/local/lib/python2.7/site-packages/pelican/__init__.py", line 242, in get_writer
writers = [w for (_, w) in signals.get_writer.send(self)
File "/home/filip/virtualenv/pelican27/local/lib/python2.7/site-packages/blinker/base.py", line 267, in send
for receiver in self.receivers_for(sender)]
File "/home/filip/src/domain.tld/pelican-plugins/i18n_subsites/i18n_subsites.py", line 424, in create_next_subsite
new_pelican_obj.run()
File "/home/filip/virtualenv/pelican27/local/lib/python2.7/site-packages/pelican/__init__.py", line 175, in run
writer = self.get_writer()
File "/home/filip/virtualenv/pelican27/local/lib/python2.7/site-packages/pelican/__init__.py", line 242, in get_writer
writers = [w for (_, w) in signals.get_writer.send(self)
File "/home/filip/virtualenv/pelican27/local/lib/python2.7/site-packages/blinker/base.py", line 267, in send
for receiver in self.receivers_for(sender)]
File "/home/filip/src/domain.tld/pelican-plugins/i18n_subsites/i18n_subsites.py", line 411, in create_next_subsite
update_generators()
File "/home/filip/src/domain.tld/pelican-plugins/i18n_subsites/i18n_subsites.py", line 383, in update_generators
interlink_removed_content(generator)
File "/home/filip/src/domain.tld/pelican-plugins/i18n_subsites/i18n_subsites.py", line 347, in interlink_removed_content
url = _NATIVE_CONTENT_URL_DB[content.source_path]
KeyError: u'/home/filip/src/domain.tld/content/pages/en/about.rst'
Content looks like this:
content
├── pages
│ ├── cs
│ │ ├── about.rst
│ │ └── contact.rst
│ └── en
│ ├── about.rst
│ └── contact.rst
O nás
#####
:slug: about
:status: published
:lang: cz
Snippet from config:
TIMEZONE = 'Europe/Prague'
DEFAULT_LANG = 'cz'
LOCALE = 'cs_CZ.UTF-8'
PLUGIN_PATHS = ['pelican-plugins']
PLUGINS = ['i18n_subsites']
JINJA_ENVIRONMENT = {
'extensions': ['jinja2.ext.i18n'],
}
Using latest pelican 3.7.1 and latest version of pelican-plugins.
Hi. I have the same kind of error running in a MS Windows 10 dev PC, python3.6.4, pelican 3.7.1:
DEBUG: Pelican version: 3.7.1
DEBUG: Python version: 3.6.4
DEBUG: Adding current directory to system path
DEBUG: Temporarily adding PLUGIN_PATHS to system path
DEBUG: Loading plugin `i18n_subsites`
DEBUG: Registering plugin `i18n_subsites`
DEBUG: Restoring system path
DEBUG: Template list: ['!simple/archives.html', '!simple/article.html', '!simple/author.html', '!simple/authors.html', '!simple/base.html', '!simple/categories.html', '!simple/category.html', '!simple/gosquared.html', '!simple/index.html', '!simple/page.html', '!simple/pagination.html', '!simple/period_archives.html', '!simple/tag.html', '!simple/tags.html', '!simple/translations.html', 'analytics.html', 'archives.html', 'article.html', 'article_infos.html', 'author.html', 'authors.html', 'base.html', 'categories.html', 'category.html', 'comments.html', 'disqus_script.html', 'github.html', 'gosquared.html', 'index.html', 'page.html', 'pagination.html', 'period_archives.html', 'tag.html', 'taglist.html', 'tags.html', 'translations.html', 'twitter.html']
DEBUG: Read file pages/about.en.rst -> Page
DEBUG: Signal page_generator_preread.send(PagesGenerator)
DEBUG: Signal page_generator_context.send(PagesGenerator, <metadata>)
DEBUG: Read file pages/about.rst -> Page
DEBUG: Generating i18n subsite for language 'en' using class <class 'pelican.Pelican'>
DEBUG: i18n: Updating cross-site links and context of all generators.
CRITICAL: KeyError: 'C:\\Dati\\Studio\\Sviluppi\\base_pelican\\ldfa\\content\\pages\\about.en.rst'
Traceback (most recent call last):
File "C:\Bin\Python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Bin\Python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Dati\Studio\Sviluppi\base_pelican\venv\Scripts\pelican.exe\__main__.py", line 9, in <module>
File "c:\dati\studio\sviluppi\base_pelican\venv\lib\site-packages\pelican\__init__.py", line 487, in main
pelican.run()
File "c:\dati\studio\sviluppi\base_pelican\venv\lib\site-packages\pelican\__init__.py", line 175, in run
writer = self.get_writer()
File "c:\dati\studio\sviluppi\base_pelican\venv\lib\site-packages\pelican\__init__.py", line 242, in get_writer
writers = [w for (_, w) in signals.get_writer.send(self)
File "c:\dati\studio\sviluppi\base_pelican\venv\lib\site-packages\blinker\base.py", line 267, in send
for receiver in self.receivers_for(sender)]
File "c:\dati\studio\sviluppi\base_pelican\venv\lib\site-packages\blinker\base.py", line 267, in <listcomp>
for receiver in self.receivers_for(sender)]
File "/Dati/Studio/Sviluppi/base_pelican/ldfa/aux_plugins\i18n_subsites\i18n_subsites.py", line 426, in create_next_subsite
new_pelican_obj.run()
File "c:\dati\studio\sviluppi\base_pelican\venv\lib\site-packages\pelican\__init__.py", line 175, in run
writer = self.get_writer()
File "c:\dati\studio\sviluppi\base_pelican\venv\lib\site-packages\pelican\__init__.py", line 242, in get_writer
writers = [w for (_, w) in signals.get_writer.send(self)
File "c:\dati\studio\sviluppi\base_pelican\venv\lib\site-packages\blinker\base.py", line 267, in send
for receiver in self.receivers_for(sender)]
File "c:\dati\studio\sviluppi\base_pelican\venv\lib\site-packages\blinker\base.py", line 267, in <listcomp>
for receiver in self.receivers_for(sender)]
File "/Dati/Studio/Sviluppi/base_pelican/ldfa/aux_plugins\i18n_subsites\i18n_subsites.py", line 413, in create_next_subsite
update_generators()
File "/Dati/Studio/Sviluppi/base_pelican/ldfa/aux_plugins\i18n_subsites\i18n_subsites.py", line 385, in update_generators
interlink_removed_content(generator)
File "/Dati/Studio/Sviluppi/base_pelican/ldfa/aux_plugins\i18n_subsites\i18n_subsites.py", line 349, in interlink_removed_content
url = _NATIVE_CONTENT_URL_DB[content.source_path]
KeyError: 'C:\\Dati\\Studio\\Sviluppi\\base_pelican\\ldfa\\content\\pages\\about.en.rst'
There is an offset of a couple of lines in line # because I set an import pdb, and a pdb.set_trace() in i18n_subsites.py.
Does anyone found the problem? Do you have any hint?
I have the same error while upgrading a old pelican website to latest versions. I'm trying to debug but this is still occuring.
Error went away when i removed all
Translation: True (or rst equivalent)
from content headers.
Running into the same problem. The issue goes away when I remove Translation: True from the headers, but in this case the plugin is unable to render the default lang page/article in a language subsite where no translation is available.
I'm also getting the error
ERROR: Cannot find translations for language 'en' in '/home/user/site/themes/pelican-blueidea/translations' with domain 'messages'. Installing NullTranslations.
I use pelican=3.7.1 and Python 3.8.12
Update to pelican=4.7.2 also returns the same error.
The error still persists on pelican 4.8.0 with up-to-date i18n-subsites.
It's strange. Yes, it works when you remove the translation metadata, but... how am I supposed to mark the page as a translation of another one if I don't use translation: true?