mirror of https://github.com/theNewDynamic/gohugo-theme-ananke.git

Patrick Kollitsch
13 hours ago 0df36e86dab038569301fe01326901ce856bf3fb
fix(i18n): use the singular unit in the English reading time

"3 minute read" is a compound adjective, so the unit stays singular.
Add a fixture test for the singular and plural forms.

Closes #870

Signed-off-by: Patrick Kollitsch <davidsneighbourdev+gh@gmail.com>
1 files modified
4 files added
41 ■■■■■ changed files
i18n/en.toml 2 ●●●●● patch | view | raw | blame | history
tests/fixtures/reading-time/content/posts/long.md 5 ●●●●● patch | view | raw | blame | history
tests/fixtures/reading-time/content/posts/short.md 5 ●●●●● patch | view | raw | blame | history
tests/fixtures/reading-time/hugo.toml 6 ●●●●● patch | view | raw | blame | history
tests/fixtures/reading-time/reading-time.test.mjs 23 ●●●●● patch | view | raw | blame | history
i18n/en.toml
@@ -45,7 +45,7 @@
[readingTime]
one = "One minute read"
other = "{{ .Count }} minutes read"
other = "{{ .Count }} minute read"
[wordCount]
one = "One word"
tests/fixtures/reading-time/content/posts/long.md
New file
@@ -0,0 +1,5 @@
---
title: Long post
---
word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word
tests/fixtures/reading-time/content/posts/short.md
New file
@@ -0,0 +1,5 @@
---
title: Short post
---
Word.
tests/fixtures/reading-time/hugo.toml
New file
@@ -0,0 +1,6 @@
title = "Reading time fixture"
theme = "ananke"
[params]
show_reading_time = true
reading_speed = 100 # words per minute, so the fixture word counts give exact minutes
tests/fixtures/reading-time/reading-time.test.mjs
New file
@@ -0,0 +1,23 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { test } from "node:test";
import { fileURLToPath } from "node:url";
import { load } from "cheerio";
import { buildFixtureSite } from "../../support/prepare-site.mjs";
const source = dirname(fileURLToPath(import.meta.url));
function readingTime(output, path) {
  const $ = load(readFileSync(join(output, path), "utf8"));
  return $("article header span.f6.tracked").first().text().trim();
}
test("reading time uses the singular unit as a compound adjective (#870)", () => {
  const output = buildFixtureSite({ source });
  assert.equal(
    readingTime(output, "posts/short/index.html"),
    "- One minute read",
  );
  assert.equal(readingTime(output, "posts/long/index.html"), "- 3 minute read");
});