question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError: 'LANGUAGE_CODE'

See original GitHub issue

While debugging a template that derives from bootstrap4.html, I noticed that the html lang attribute is not set even if I set it in my settings.py.

I’m not really sure, where this LANGUAGE_CODE should come from without loading i18n before, so I changed the bootstrap4.html like this:

<!DOCTYPE html>
{% load bootstrap4 %}
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
<html{% if LANGUAGE_CODE %} lang="{{ LANGUAGE_CODE }}"{% endif %}>

which works for me. Perhaps this could be further optimized to check if i18n is enabled but I’m not sure how to do this at the moment.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dyvecommented, Nov 25, 2017

Sure, or leave it out if LANGUAGE_CODEI actually like @sachalalala’s solution, but it might require django.i18n in settings.

Op 24 nov. 2017, om 23:46 heeft Timothy Allen notifications@github.com het volgende geschreven:

Could we do this instead, to set en_us as a default?

<html lang="{{ LANGUAGE_CODE|default:'en_us' }}"> — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/zostera/django-bootstrap4/issues/52#issuecomment-346903624>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAFBi3yJ4AMLZ_pLuOX-rWvlfLXGvmKnks5s50dJgaJpZM4QptGa>.
0reactions
jietercommented, Jan 3, 2018

Fixed by #53

Read more comments on GitHub >

github_iconTop Results From Across the Web

New language adding error('Unknown language code si.')
Request URL: http://localhost.test:8000/accounts/login/. Django Version: 2.0.4. Exception Type: KeyError. Exception Value: 'Unknown language code si.'.
Read more >
19811 (KeyError: u"Unknown language code 'en-us'.")
Default LANGUAGE_CODE='en-us' is not present in django.conf.locale.LANG_INFO and can trigger KeyError exception. It can be easily reproduced by using ...
Read more >
KeyError when key exists in dictionary - python - Stack Overflow
I'm working on a code that detects the langue of a tweet and applies the lexical matching that language. The code USED to...
Read more >
u'Unknown language code tl.' · Issue #364 - GitHub
I am getting: KeyError at /de/admin/blog/blogarticle/13/ u'Unknown language code tl.' my django version is 1.8 and python 2.7.10. and ...
Read more >
Source code for pytube.captions
for backwards compatibility, e.g.: # English -> vssId: .en, languageCode: en ... try: duration = float(child.attrib["dur"]) except KeyError: duration = 0.0 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found