Skip to content

find_language_in misses a content-language meta that is not the first meta #356

Closed

Description

@Sarthak-Shreshtha01

find_language_in looks for the language in <html lang>, <body lang> and then a <meta http-equiv="content-language">. For each of these it only checks the first matching tag (soup.find), so a content-language <meta> is found only when it is the first <meta> of the page. Most pages start with <meta charset="utf-8">, so the language is not found there.

from zimscraperlib.html import find_language_in

find_language_in(
    "<html><head><meta charset='utf-8'>"
    "<meta http-equiv='content-language' content='fr'></head><body></body></html>",
    "text/html",
)
# returns "" instead of "fr"

Without the <meta charset> it returns "fr". find_language_in_file has the same problem.

Activity

  1. added theissue type on Oct 19, 2026
  2. added this to the 5.5.0 milestone on Oct 19, 2026
  3. added a commit that references this issue on Oct 19, 2026
    d7b7c14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions