diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-20 23:43:35 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-09-22 12:50:31 -0400 |
| commit | cd93d2d8b5062493650673ecdd13139d6f0e5171 (patch) | |
| tree | 23ab13665da3bc5aca4913ca8f8dc33eb5219bff | |
| parent | pod digests: multilingual document digests sorted (diff) | |
xml: markup language attributes take a bcp 47 tag
Spine names a language as the directory under media/text/ is
named, which for a region is the posix form with an underscore,
pt_BR. A lang, xml:lang or dc:language value is a BCP 47 (RFC
3066) tag and wants a hyphen, pt-BR. Spine put its own code
there unchanged, so a document in a region language produced an
invalid attribute in every one of its xhtml files: 138 epubcheck
errors for a document of ten segments and a navigation file.
src.language_tag is the same language as a tag. The attributes
and the dc metadata now read it. Output paths keep src.language,
since a path is named after the directory, not after the tag.
(assisted by Claude-Code)
| -rw-r--r-- | org/default_paths.org | 15 | ||||
| -rw-r--r-- | org/out_xmls.org | 20 | ||||
| -rw-r--r-- | src/sisudoc/ocda/io_in/paths_source.d | 15 | ||||
| -rw-r--r-- | src/sisudoc/outputs/io_out/epub3.d | 4 | ||||
| -rw-r--r-- | src/sisudoc/outputs/io_out/xmls.d | 16 |
5 files changed, 50 insertions, 20 deletions
diff --git a/org/default_paths.org b/org/default_paths.org index a6cf19a..15f196f 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -310,6 +310,21 @@ template PathMatters() { string language() { return lng(); } + /+ ↓ the same language, as a language tag rather than as spine's + own code. Spine names a language the way a directory under + media/text/ is named, which for a region is the posix form + with an underscore, pt_BR. A lang, xml:lang or dc:language + value is a BCP 47 (RFC 3066) tag and wants a hyphen, pt-BR; + an underscore there is invalid and every xhtml file in the + document carrying it is an epubcheck error. Every other code + spine knows (from the document sample set) is two letters, + where the two forms are equal, which is why only a region + code shows this up. + +/ + string language_tag() { + import std.array : replace; + return lng().replace("_", "-"); + } string file_with_absolute_path() { return _env["pwd"].chainPath(path_and_fn).array; } diff --git a/org/out_xmls.org b/org/out_xmls.org index 75d61a0..90218bd 100644 --- a/org/out_xmls.org +++ b/org/out_xmls.org @@ -427,7 +427,7 @@ string header_metadata(M)( special_characters_plain(doc_matters.conf_make_meta.meta.date_available), special_characters_plain(doc_matters.conf_make_meta.meta.date_valid), special_characters_plain(doc_matters.conf_make_meta.meta.date_modified), - doc_matters.src.language, + doc_matters.src.language_tag, special_characters_plain(doc_matters.conf_make_meta.meta.rights_copyright), doc_matters.opt.action.generated_by ? special_characters_plain(doc_matters.generator_program.name_and_version) : "", special_characters_plain(doc_matters.generator_program.url_home), @@ -612,7 +612,7 @@ string html_head(M)( ((type == "seg") ? "../../../css/html_seg.css" : "../../css/html_scroll.css"), - doc_matters.src.language, + doc_matters.src.language_tag, site_info_button(doc_matters), metadata_links, inline_search_form(doc_matters), @@ -636,16 +636,16 @@ string epub3_seg_head(M)( xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="%s" xml:lang="%s">┃", - doc_matters.src.language, - doc_matters.src.language, + doc_matters.src.language_tag, + doc_matters.src.language_tag, ); string html_strict = format(q"┃<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="%s" xml:lang="%s">┃", - doc_matters.src.language, - doc_matters.src.language, + doc_matters.src.language_tag, + doc_matters.src.language_tag, ); string o; o = format(q"┃%s @@ -685,11 +685,11 @@ string epub3_seg_head(M)( special_characters_plain(doc_matters.conf_make_meta.meta.date_available), special_characters_plain(doc_matters.conf_make_meta.meta.date_valid), special_characters_plain(doc_matters.conf_make_meta.meta.date_modified), - doc_matters.src.language, + doc_matters.src.language_tag, special_characters_plain(doc_matters.conf_make_meta.meta.rights_copyright), special_characters_plain(doc_matters.generator_program.name_and_version), special_characters_plain(doc_matters.generator_program.url_home), - doc_matters.src.language, + doc_matters.src.language_tag, ); return o; } @@ -2938,7 +2938,7 @@ string epub3_oebps_content(D,P)(D doc, P parts) { <item id="css" href="%s" media-type="text/css"/> <item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" /> ┃", - doc.matters.src.language, + doc.matters.src.language_tag, _uuid, xhtml_format.special_characters_plain(doc.matters.conf_make_meta.meta.title_main), (doc.matters.conf_make_meta.meta.title_sub.empty) ? "" : format( @@ -2949,7 +2949,7 @@ string epub3_oebps_content(D,P)(D doc, P parts) { ? "" : xhtml_format.special_characters_plain(doc.matters.conf_make_meta.meta.creator_author), (doc.matters.conf_make_meta.meta.creator_author_surname_fn.empty) ? "" : xhtml_format.special_characters_plain(doc.matters.conf_make_meta.meta.creator_author_surname_fn), - doc.matters.src.language, // language, fix (needed in dochead metadata) + doc.matters.src.language_tag, // language, fix (needed in dochead metadata) (doc.matters.conf_make_meta.meta.date_published.empty) ? "" : xhtml_format.special_characters_plain_date(doc.matters.conf_make_meta.meta.date_published), (doc.matters.conf_make_meta.meta.rights_copyright.empty) diff --git a/src/sisudoc/ocda/io_in/paths_source.d b/src/sisudoc/ocda/io_in/paths_source.d index 9cacdf0..f32b89e 100644 --- a/src/sisudoc/ocda/io_in/paths_source.d +++ b/src/sisudoc/ocda/io_in/paths_source.d @@ -298,6 +298,21 @@ template PathMatters() { string language() { return lng(); } + /+ ↓ the same language, as a language tag rather than as spine's + own code. Spine names a language the way a directory under + media/text/ is named, which for a region is the posix form + with an underscore, pt_BR. A lang, xml:lang or dc:language + value is a BCP 47 (RFC 3066) tag and wants a hyphen, pt-BR; + an underscore there is invalid and every xhtml file in the + document carrying it is an epubcheck error. Every other code + spine knows (from the document sample set) is two letters, + where the two forms are equal, which is why only a region + code shows this up. + +/ + string language_tag() { + import std.array : replace; + return lng().replace("_", "-"); + } string file_with_absolute_path() { return _env["pwd"].chainPath(path_and_fn).array; } diff --git a/src/sisudoc/outputs/io_out/epub3.d b/src/sisudoc/outputs/io_out/epub3.d index 8a3baaf..c785895 100644 --- a/src/sisudoc/outputs/io_out/epub3.d +++ b/src/sisudoc/outputs/io_out/epub3.d @@ -298,7 +298,7 @@ template outputEPub3() { <item id="css" href="%s" media-type="text/css"/> <item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" /> ┃", - doc.matters.src.language, + doc.matters.src.language_tag, _uuid, xhtml_format.special_characters_plain(doc.matters.conf_make_meta.meta.title_main), (doc.matters.conf_make_meta.meta.title_sub.empty) ? "" : format( @@ -309,7 +309,7 @@ template outputEPub3() { ? "" : xhtml_format.special_characters_plain(doc.matters.conf_make_meta.meta.creator_author), (doc.matters.conf_make_meta.meta.creator_author_surname_fn.empty) ? "" : xhtml_format.special_characters_plain(doc.matters.conf_make_meta.meta.creator_author_surname_fn), - doc.matters.src.language, // language, fix (needed in dochead metadata) + doc.matters.src.language_tag, // language, fix (needed in dochead metadata) (doc.matters.conf_make_meta.meta.date_published.empty) ? "" : xhtml_format.special_characters_plain_date(doc.matters.conf_make_meta.meta.date_published), (doc.matters.conf_make_meta.meta.rights_copyright.empty) diff --git a/src/sisudoc/outputs/io_out/xmls.d b/src/sisudoc/outputs/io_out/xmls.d index 4ce5434..c97a7e3 100644 --- a/src/sisudoc/outputs/io_out/xmls.d +++ b/src/sisudoc/outputs/io_out/xmls.d @@ -308,7 +308,7 @@ template outputXHTMLs() { special_characters_plain(doc_matters.conf_make_meta.meta.date_available), special_characters_plain(doc_matters.conf_make_meta.meta.date_valid), special_characters_plain(doc_matters.conf_make_meta.meta.date_modified), - doc_matters.src.language, + doc_matters.src.language_tag, special_characters_plain(doc_matters.conf_make_meta.meta.rights_copyright), doc_matters.opt.action.generated_by ? special_characters_plain(doc_matters.generator_program.name_and_version) : "", special_characters_plain(doc_matters.generator_program.url_home), @@ -473,7 +473,7 @@ template outputXHTMLs() { ((type == "seg") ? "../../../css/html_seg.css" : "../../css/html_scroll.css"), - doc_matters.src.language, + doc_matters.src.language_tag, site_info_button(doc_matters), metadata_links, inline_search_form(doc_matters), @@ -491,16 +491,16 @@ template outputXHTMLs() { xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="%s" xml:lang="%s">┃", - doc_matters.src.language, - doc_matters.src.language, + doc_matters.src.language_tag, + doc_matters.src.language_tag, ); string html_strict = format(q"┃<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="%s" xml:lang="%s">┃", - doc_matters.src.language, - doc_matters.src.language, + doc_matters.src.language_tag, + doc_matters.src.language_tag, ); string o; o = format(q"┃%s @@ -540,11 +540,11 @@ template outputXHTMLs() { special_characters_plain(doc_matters.conf_make_meta.meta.date_available), special_characters_plain(doc_matters.conf_make_meta.meta.date_valid), special_characters_plain(doc_matters.conf_make_meta.meta.date_modified), - doc_matters.src.language, + doc_matters.src.language_tag, special_characters_plain(doc_matters.conf_make_meta.meta.rights_copyright), special_characters_plain(doc_matters.generator_program.name_and_version), special_characters_plain(doc_matters.generator_program.url_home), - doc_matters.src.language, + doc_matters.src.language_tag, ); return o; } |
