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

i18n_subsites failing with KeyError on _NATIVE_CONTENT_URL_DB[content.source_path] #1032

Open
fpytloun opened this issue Jun 7, 2018 · 7 comments

Comments

@fpytloun
Copy link

fpytloun commented Jun 7, 2018

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.

@l-dfa
Copy link

l-dfa commented Jun 24, 2018

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.

@Gustry
Copy link

Gustry commented Sep 30, 2020

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.

@tohammer
Copy link

Error went away when i removed all
Translation: True (or rst equivalent)
from content headers.

@georgkrause
Copy link

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.

@kokkytos
Copy link

kokkytos commented Mar 11, 2022

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.

@vlajna95
Copy link

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?

@danmcb
Copy link

danmcb commented Nov 4, 2024

from the docs:
``
Setting it up

For each extra used language code, a language-specific settings overrides dictionary must be given (but can be empty) in the I18N_SUBSITES dictionary

PLUGINS = ['i18n_subsites', ...]

mapping: language_code -> settings_overrides_dict

I18N_SUBSITES = {
'cz': {
'SITENAME': 'Hezkej blog',
}
}
``
I fixed the issue by adding this config hash (leaving the contents empty).

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

8 participants