diff --git a/quartz/i18n/index.ts b/quartz/i18n/index.ts index f9758d36b..a422acb79 100644 --- a/quartz/i18n/index.ts +++ b/quartz/i18n/index.ts @@ -1,4 +1,4 @@ -import { Translation } from "./locales/definition" +import { Translation, CalloutTranslation } from "./locales/definition" import en from "./locales/en-US" import fr from "./locales/fr-FR" import ja from "./locales/ja-JP" @@ -44,3 +44,4 @@ export const TRANSLATIONS = { export const defaultTranslation = "en-US" export const i18n = (locale: ValidLocale): Translation => TRANSLATIONS[locale ?? defaultTranslation] export type ValidLocale = keyof typeof TRANSLATIONS +export type ValidCallout = keyof CalloutTranslation diff --git a/quartz/i18n/locales/ar-SA.ts b/quartz/i18n/locales/ar-SA.ts index 9c29b4d5e..d8efeffef 100644 --- a/quartz/i18n/locales/ar-SA.ts +++ b/quartz/i18n/locales/ar-SA.ts @@ -6,6 +6,21 @@ export default { description: "لم يتم تقديم أي وصف", }, components: { + callout: { + note: "ملاحظة", + abstract: "ملخص", + info: "معلومات", + todo: "للقيام", + tip: "نصيحة", + success: "نجاح", + question: "سؤال", + warning: "تحذير", + failure: "فشل", + danger: "خطر", + bug: "خلل", + example: "مثال", + quote: "اقتباس", + }, backlinks: { title: "وصلات العودة", noBacklinksFound: "لا يوجد وصلات عودة", diff --git a/quartz/i18n/locales/de-DE.ts b/quartz/i18n/locales/de-DE.ts index c6531bef4..f2125bf60 100644 --- a/quartz/i18n/locales/de-DE.ts +++ b/quartz/i18n/locales/de-DE.ts @@ -6,6 +6,21 @@ export default { description: "Keine Beschreibung angegeben", }, components: { + callout: { + note: "Hinweis", + abstract: "Zusammenfassung", + info: "Info", + todo: "Zu erledigen", + tip: "Tipp", + success: "Erfolg", + question: "Frage", + warning: "Warnung", + failure: "Misserfolg", + danger: "Gefahr", + bug: "Fehler", + example: "Beispiel", + quote: "Zitat", + }, backlinks: { title: "Backlinks", noBacklinksFound: "Keine Backlinks gefunden", diff --git a/quartz/i18n/locales/definition.ts b/quartz/i18n/locales/definition.ts index de607eb56..baf2a5875 100644 --- a/quartz/i18n/locales/definition.ts +++ b/quartz/i18n/locales/definition.ts @@ -1,11 +1,28 @@ import { FullSlug } from "../../util/path" +export interface CalloutTranslation { + note: string + abstract: string + info: string + todo: string + tip: string + success: string + question: string + warning: string + failure: string + danger: string + bug: string + example: string + quote: string +} + export interface Translation { propertyDefaults: { title: string description: string } components: { + callout: CalloutTranslation backlinks: { title: string noBacklinksFound: string diff --git a/quartz/i18n/locales/en-US.ts b/quartz/i18n/locales/en-US.ts index 6ba6d0e5d..3ba28a0d5 100644 --- a/quartz/i18n/locales/en-US.ts +++ b/quartz/i18n/locales/en-US.ts @@ -6,6 +6,21 @@ export default { description: "No description provided", }, components: { + callout: { + note: "Note", + abstract: "Abstract", + info: "Info", + todo: "Todo", + tip: "Tip", + success: "Success", + question: "Question", + warning: "Warning", + failure: "Failure", + danger: "Danger", + bug: "Bug", + example: "Example", + quote: "Quote", + }, backlinks: { title: "Backlinks", noBacklinksFound: "No backlinks found", diff --git a/quartz/i18n/locales/es-ES.ts b/quartz/i18n/locales/es-ES.ts index 4d395429d..92a74a03c 100644 --- a/quartz/i18n/locales/es-ES.ts +++ b/quartz/i18n/locales/es-ES.ts @@ -6,6 +6,21 @@ export default { description: "Sin descripción", }, components: { + callout: { + note: "Nota", + abstract: "Resumen", + info: "Información", + todo: "Por hacer", + tip: "Consejo", + success: "Éxito", + question: "Pregunta", + warning: "Advertencia", + failure: "Fallo", + danger: "Peligro", + bug: "Error", + example: "Ejemplo", + quote: "Cita", + }, backlinks: { title: "Enlaces de Retroceso", noBacklinksFound: "No se han encontrado enlaces traseros", diff --git a/quartz/i18n/locales/fr-FR.ts b/quartz/i18n/locales/fr-FR.ts index b30ff049f..fee1ad921 100644 --- a/quartz/i18n/locales/fr-FR.ts +++ b/quartz/i18n/locales/fr-FR.ts @@ -6,6 +6,21 @@ export default { description: "Aucune description fournie", }, components: { + callout: { + note: "Note", + abstract: "Résumé", + info: "Info", + todo: "À faire", + tip: "Conseil", + success: "Succès", + question: "Question", + warning: "Avertissement", + failure: "Échec", + danger: "Danger", + bug: "Bogue", + example: "Exemple", + quote: "Citation", + }, backlinks: { title: "Liens retour", noBacklinksFound: "Aucun lien retour trouvé", diff --git a/quartz/i18n/locales/ja-JP.ts b/quartz/i18n/locales/ja-JP.ts index a886d84f8..f684c36b3 100644 --- a/quartz/i18n/locales/ja-JP.ts +++ b/quartz/i18n/locales/ja-JP.ts @@ -6,6 +6,21 @@ export default { description: "説明なし", }, components: { + callout: { + note: "ノート", + abstract: "抄録", + info: "情報", + todo: "やるべきこと", + tip: "ヒント", + success: "成功", + question: "質問", + warning: "警告", + failure: "失敗", + danger: "危険", + bug: "バグ", + example: "例", + quote: "引用", + }, backlinks: { title: "バックリンク", noBacklinksFound: "バックリンクはありません", diff --git a/quartz/i18n/locales/nl-NL.ts b/quartz/i18n/locales/nl-NL.ts index 5426a1e1f..b40362355 100644 --- a/quartz/i18n/locales/nl-NL.ts +++ b/quartz/i18n/locales/nl-NL.ts @@ -6,6 +6,21 @@ export default { description: "Geen beschrijving gegeven.", }, components: { + callout: { + note: "Notitie", + abstract: "Samenvatting", + info: "Info", + todo: "Te doen", + tip: "Tip", + success: "Succes", + question: "Vraag", + warning: "Waarschuwing", + failure: "Mislukking", + danger: "Gevaar", + bug: "Bug", + example: "Voorbeeld", + quote: "Citaat", + }, backlinks: { title: "Backlinks", noBacklinksFound: "Geen backlinks gevonden", diff --git a/quartz/i18n/locales/ro-RO.ts b/quartz/i18n/locales/ro-RO.ts index 8fce4a90d..39f1344be 100644 --- a/quartz/i18n/locales/ro-RO.ts +++ b/quartz/i18n/locales/ro-RO.ts @@ -6,6 +6,21 @@ export default { description: "Nici o descriere furnizată", }, components: { + callout: { + note: "Notă", + abstract: "Rezumat", + info: "Informație", + todo: "De făcut", + tip: "Sfat", + success: "Succes", + question: "Întrebare", + warning: "Avertisment", + failure: "Eșec", + danger: "Pericol", + bug: "Bug", + example: "Exemplu", + quote: "Citat", + }, backlinks: { title: "Legături înapoi", noBacklinksFound: "Nu s-au găsit legături înapoi", diff --git a/quartz/i18n/locales/uk-UA.ts b/quartz/i18n/locales/uk-UA.ts index bf664b6f8..d60b1f8cf 100644 --- a/quartz/i18n/locales/uk-UA.ts +++ b/quartz/i18n/locales/uk-UA.ts @@ -6,6 +6,21 @@ export default { description: "Опис не надано", }, components: { + callout: { + note: "Примітка", + abstract: "Абстракт", + info: "Інформація", + todo: "Завдання", + tip: "Порада", + success: "Успіх", + question: "Питання", + warning: "Попередження", + failure: "Невдача", + danger: "Небезпека", + bug: "Баг", + example: "Приклад", + quote: "Цитата", + }, backlinks: { title: "Зворотні посилання", noBacklinksFound: "Зворотних посилань не знайдено", diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index f8a28c486..a9d39458d 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -1,5 +1,5 @@ import { QuartzTransformerPlugin } from "../types" -import { Root, Html, BlockContent, DefinitionContent, Paragraph, Code } from "mdast" +import { Blockquote, Root, Html, BlockContent, DefinitionContent, Paragraph, Code } from "mdast" import { Element, Literal, Root as HtmlRoot } from "hast" import { ReplaceFunction, findAndReplace as mdastFindReplace } from "mdast-util-find-and-replace" import { slug as slugAnchor } from "github-slugger" @@ -17,6 +17,7 @@ import { toHtml } from "hast-util-to-html" import { PhrasingContent } from "mdast-util-find-and-replace/lib" import { capitalize } from "../../util/lang" import { PluggableList } from "unified" +import { ValidCallout, i18n } from "../../i18n" export interface Options { comments: boolean @@ -185,8 +186,9 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin return src }, - markdownPlugins() { + markdownPlugins(ctx) { const plugins: PluggableList = [] + const cfg = ctx.cfg.configuration // regex replacements plugins.push(() => { @@ -407,7 +409,12 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin children: [ { type: "text", - value: useDefaultTitle ? capitalize(calloutType) : titleContent + " ", + value: useDefaultTitle + ? capitalize( + i18n(cfg.locale).components.callout[calloutType as ValidCallout] ?? + calloutType, + ) + : titleContent + " ", }, ...restOfTitle, ],