feat(i18n): localize the min read string (#838)
* feat(i18n): localize the min read string fixes #825 * chore: format
This commit is contained in:
		@@ -2,6 +2,7 @@ import { formatDate, getDate } from "./Date"
 | 
			
		||||
import { QuartzComponentConstructor, QuartzComponentProps } from "./types"
 | 
			
		||||
import readingTime from "reading-time"
 | 
			
		||||
import { classNames } from "../util/lang"
 | 
			
		||||
import { i18n } from "../i18n"
 | 
			
		||||
 | 
			
		||||
interface ContentMetaOptions {
 | 
			
		||||
  /**
 | 
			
		||||
@@ -30,8 +31,11 @@ export default ((opts?: Partial<ContentMetaOptions>) => {
 | 
			
		||||
 | 
			
		||||
      // Display reading time if enabled
 | 
			
		||||
      if (options.showReadingTime) {
 | 
			
		||||
        const { text: timeTaken, words: _words } = readingTime(text)
 | 
			
		||||
        segments.push(timeTaken)
 | 
			
		||||
        const { minutes, words: _words } = readingTime(text)
 | 
			
		||||
        const displayedTime = i18n(cfg.locale).components.contentMeta.readingTime({
 | 
			
		||||
          minutes: Math.ceil(minutes),
 | 
			
		||||
        })
 | 
			
		||||
        segments.push(displayedTime)
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return <p class={classNames(displayClass, "content-meta")}>{segments.join(", ")}</p>
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,14 @@ export default {
 | 
			
		||||
    tableOfContents: {
 | 
			
		||||
      title: "فهرس المحتويات",
 | 
			
		||||
    },
 | 
			
		||||
    contentMeta: {
 | 
			
		||||
      readingTime: ({ minutes }) =>
 | 
			
		||||
        minutes == 1
 | 
			
		||||
          ? `دقيقة أو أقل للقراءة`
 | 
			
		||||
          : minutes == 2
 | 
			
		||||
            ? `دقيقتان للقراءة`
 | 
			
		||||
            : `${minutes} دقائق للقراءة`,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  pages: {
 | 
			
		||||
    rss: {
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,9 @@ export default {
 | 
			
		||||
    tableOfContents: {
 | 
			
		||||
      title: "Inhaltsverzeichnis",
 | 
			
		||||
    },
 | 
			
		||||
    contentMeta: {
 | 
			
		||||
      readingTime: ({ minutes }) => `${minutes} min read`,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  pages: {
 | 
			
		||||
    rss: {
 | 
			
		||||
 
 | 
			
		||||
@@ -55,6 +55,9 @@ export interface Translation {
 | 
			
		||||
    tableOfContents: {
 | 
			
		||||
      title: string
 | 
			
		||||
    }
 | 
			
		||||
    contentMeta: {
 | 
			
		||||
      readingTime: (variables: { minutes: number }) => string
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  pages: {
 | 
			
		||||
    rss: {
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,9 @@ export default {
 | 
			
		||||
    tableOfContents: {
 | 
			
		||||
      title: "Table of Contents",
 | 
			
		||||
    },
 | 
			
		||||
    contentMeta: {
 | 
			
		||||
      readingTime: ({ minutes }) => `${minutes} min read`,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  pages: {
 | 
			
		||||
    rss: {
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,9 @@ export default {
 | 
			
		||||
    tableOfContents: {
 | 
			
		||||
      title: "Tabla de Contenidos",
 | 
			
		||||
    },
 | 
			
		||||
    contentMeta: {
 | 
			
		||||
      readingTime: ({ minutes }) => `${minutes} min read`,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  pages: {
 | 
			
		||||
    rss: {
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,9 @@ export default {
 | 
			
		||||
    tableOfContents: {
 | 
			
		||||
      title: "Table des Matières",
 | 
			
		||||
    },
 | 
			
		||||
    contentMeta: {
 | 
			
		||||
      readingTime: ({ minutes }) => `${minutes} min read`,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  pages: {
 | 
			
		||||
    rss: {
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,9 @@ export default {
 | 
			
		||||
    tableOfContents: {
 | 
			
		||||
      title: "目次",
 | 
			
		||||
    },
 | 
			
		||||
    contentMeta: {
 | 
			
		||||
      readingTime: ({ minutes }) => `${minutes} min read`,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  pages: {
 | 
			
		||||
    rss: {
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,9 @@ export default {
 | 
			
		||||
    tableOfContents: {
 | 
			
		||||
      title: "Inhoudsopgave",
 | 
			
		||||
    },
 | 
			
		||||
    contentMeta: {
 | 
			
		||||
      readingTime: ({ minutes }) => `${minutes} min read`,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  pages: {
 | 
			
		||||
    rss: {
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,9 @@ export default {
 | 
			
		||||
    tableOfContents: {
 | 
			
		||||
      title: "Cuprins",
 | 
			
		||||
    },
 | 
			
		||||
    contentMeta: {
 | 
			
		||||
      readingTime: ({ minutes }) => `${minutes} min read`,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  pages: {
 | 
			
		||||
    rss: {
 | 
			
		||||
 
 | 
			
		||||
@@ -53,6 +53,9 @@ export default {
 | 
			
		||||
    tableOfContents: {
 | 
			
		||||
      title: "Зміст",
 | 
			
		||||
    },
 | 
			
		||||
    contentMeta: {
 | 
			
		||||
      readingTime: ({ minutes }) => `${minutes} min read`,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  pages: {
 | 
			
		||||
    rss: {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user