Skip to content

Commit 585a370

Browse files
committed
Use langcodes to generate html lang attribute, update changelog
1 parent b085a09 commit 585a370

7 files changed

Lines changed: 17 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and [Pydantic's HISTORY.md](https://github.com/pydantic/pydantic/blob/main/HISTORY.md), and this project *mostly* adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## `1!0.1.0a36`
8+
9+
### Changed
10+
11+
* The `lang` attribute in `index.html` is now generated using [langcodes](https://pypi.org/project/langcodes/) instead of always defaulting to `en`.
12+
13+
### Fixed
14+
15+
* Fixed the language selector defaulting to "English (United States)" if the translation is missing.
16+
717
## `1!0.1.0a35`
818

919
### Fixed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ dependencies = [
4343
"hatch~=1.9",
4444
"importlib_resources~=6.0",
4545
"Jinja2~=3.1",
46+
"langcodes~=3.5",
4647
"moderngl[headless]~=5.10",
4748
"moderngl-window~=2.4",
4849
"more_itertools~=10.1",

src/hexdoc/_templates/index.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% import "macros/formatting.html.jinja" as fmt with context %}
22

33
<!DOCTYPE html>
4-
<html lang="en">
4+
<html lang="{{ lang_html }}">
55
<head>
66
{% block head %}
77
<title>{{ _("hexdoc."~props.modid~".title") }}</title>

src/hexdoc/jinja/render.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from pathlib import Path
77
from typing import Any, Mapping, Sequence
88

9+
import langcodes
910
from _hexdoc_favicons import Favicons
1011
from jinja2 import (
1112
BaseLoader,
@@ -200,6 +201,7 @@ def render_book(
200201
"version": version,
201202
"lang": lang,
202203
"lang_name": lang_name,
204+
"lang_html": langcodes.standardize_tag(lang),
203205
"is_bleeding_edge": version.startswith("latest"),
204206
"favicons_html": favicons_html,
205207
"favicons_formats": favicons_formats,

test/integration/__snapshots__/test_copier/test_index[vlatestmainen_usindex.html].raw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html lang="en-US">
33
<head>
44
<title>Mod Book</title>
55
<meta charset="utf-8" />

test/integration/__snapshots__/test_main_1.19/test_files[vlatestmainen_usindex.html].raw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html lang="en-US">
33
<head>
44
<title>Hex Book</title>
55
<meta charset="utf-8" />

test/integration/__snapshots__/test_main_main/test_files[vlatestmainen_usindex.html].raw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html lang="en-US">
33
<head>
44
<title>Hex Book</title>
55
<meta charset="utf-8" />

0 commit comments

Comments
 (0)