feat(i18n): support parsing callouts (#834)
* feat(i18n): support parsing callouts Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com> * chore: move callout into components Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com> * chore: update arabic translation Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com> * fix: make sure to use correct items Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com> --------- Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
This commit is contained in:
parent
a0d6daa3b4
commit
db5e701810
@ -1,4 +1,4 @@
|
|||||||
import { Translation } from "./locales/definition"
|
import { Translation, CalloutTranslation } from "./locales/definition"
|
||||||
import en from "./locales/en-US"
|
import en from "./locales/en-US"
|
||||||
import fr from "./locales/fr-FR"
|
import fr from "./locales/fr-FR"
|
||||||
import ja from "./locales/ja-JP"
|
import ja from "./locales/ja-JP"
|
||||||
@ -44,3 +44,4 @@ export const TRANSLATIONS = {
|
|||||||
export const defaultTranslation = "en-US"
|
export const defaultTranslation = "en-US"
|
||||||
export const i18n = (locale: ValidLocale): Translation => TRANSLATIONS[locale ?? defaultTranslation]
|
export const i18n = (locale: ValidLocale): Translation => TRANSLATIONS[locale ?? defaultTranslation]
|
||||||
export type ValidLocale = keyof typeof TRANSLATIONS
|
export type ValidLocale = keyof typeof TRANSLATIONS
|
||||||
|
export type ValidCallout = keyof CalloutTranslation
|
||||||
|
@ -6,6 +6,21 @@ export default {
|
|||||||
description: "لم يتم تقديم أي وصف",
|
description: "لم يتم تقديم أي وصف",
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
callout: {
|
||||||
|
note: "ملاحظة",
|
||||||
|
abstract: "ملخص",
|
||||||
|
info: "معلومات",
|
||||||
|
todo: "للقيام",
|
||||||
|
tip: "نصيحة",
|
||||||
|
success: "نجاح",
|
||||||
|
question: "سؤال",
|
||||||
|
warning: "تحذير",
|
||||||
|
failure: "فشل",
|
||||||
|
danger: "خطر",
|
||||||
|
bug: "خلل",
|
||||||
|
example: "مثال",
|
||||||
|
quote: "اقتباس",
|
||||||
|
},
|
||||||
backlinks: {
|
backlinks: {
|
||||||
title: "وصلات العودة",
|
title: "وصلات العودة",
|
||||||
noBacklinksFound: "لا يوجد وصلات عودة",
|
noBacklinksFound: "لا يوجد وصلات عودة",
|
||||||
|
@ -6,6 +6,21 @@ export default {
|
|||||||
description: "Keine Beschreibung angegeben",
|
description: "Keine Beschreibung angegeben",
|
||||||
},
|
},
|
||||||
components: {
|
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: {
|
backlinks: {
|
||||||
title: "Backlinks",
|
title: "Backlinks",
|
||||||
noBacklinksFound: "Keine Backlinks gefunden",
|
noBacklinksFound: "Keine Backlinks gefunden",
|
||||||
|
@ -1,11 +1,28 @@
|
|||||||
import { FullSlug } from "../../util/path"
|
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 {
|
export interface Translation {
|
||||||
propertyDefaults: {
|
propertyDefaults: {
|
||||||
title: string
|
title: string
|
||||||
description: string
|
description: string
|
||||||
}
|
}
|
||||||
components: {
|
components: {
|
||||||
|
callout: CalloutTranslation
|
||||||
backlinks: {
|
backlinks: {
|
||||||
title: string
|
title: string
|
||||||
noBacklinksFound: string
|
noBacklinksFound: string
|
||||||
|
@ -6,6 +6,21 @@ export default {
|
|||||||
description: "No description provided",
|
description: "No description provided",
|
||||||
},
|
},
|
||||||
components: {
|
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: {
|
backlinks: {
|
||||||
title: "Backlinks",
|
title: "Backlinks",
|
||||||
noBacklinksFound: "No backlinks found",
|
noBacklinksFound: "No backlinks found",
|
||||||
|
@ -6,6 +6,21 @@ export default {
|
|||||||
description: "Sin descripción",
|
description: "Sin descripción",
|
||||||
},
|
},
|
||||||
components: {
|
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: {
|
backlinks: {
|
||||||
title: "Enlaces de Retroceso",
|
title: "Enlaces de Retroceso",
|
||||||
noBacklinksFound: "No se han encontrado enlaces traseros",
|
noBacklinksFound: "No se han encontrado enlaces traseros",
|
||||||
|
@ -6,6 +6,21 @@ export default {
|
|||||||
description: "Aucune description fournie",
|
description: "Aucune description fournie",
|
||||||
},
|
},
|
||||||
components: {
|
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: {
|
backlinks: {
|
||||||
title: "Liens retour",
|
title: "Liens retour",
|
||||||
noBacklinksFound: "Aucun lien retour trouvé",
|
noBacklinksFound: "Aucun lien retour trouvé",
|
||||||
|
@ -6,6 +6,21 @@ export default {
|
|||||||
description: "説明なし",
|
description: "説明なし",
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
callout: {
|
||||||
|
note: "ノート",
|
||||||
|
abstract: "抄録",
|
||||||
|
info: "情報",
|
||||||
|
todo: "やるべきこと",
|
||||||
|
tip: "ヒント",
|
||||||
|
success: "成功",
|
||||||
|
question: "質問",
|
||||||
|
warning: "警告",
|
||||||
|
failure: "失敗",
|
||||||
|
danger: "危険",
|
||||||
|
bug: "バグ",
|
||||||
|
example: "例",
|
||||||
|
quote: "引用",
|
||||||
|
},
|
||||||
backlinks: {
|
backlinks: {
|
||||||
title: "バックリンク",
|
title: "バックリンク",
|
||||||
noBacklinksFound: "バックリンクはありません",
|
noBacklinksFound: "バックリンクはありません",
|
||||||
|
@ -6,6 +6,21 @@ export default {
|
|||||||
description: "Geen beschrijving gegeven.",
|
description: "Geen beschrijving gegeven.",
|
||||||
},
|
},
|
||||||
components: {
|
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: {
|
backlinks: {
|
||||||
title: "Backlinks",
|
title: "Backlinks",
|
||||||
noBacklinksFound: "Geen backlinks gevonden",
|
noBacklinksFound: "Geen backlinks gevonden",
|
||||||
|
@ -6,6 +6,21 @@ export default {
|
|||||||
description: "Nici o descriere furnizată",
|
description: "Nici o descriere furnizată",
|
||||||
},
|
},
|
||||||
components: {
|
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: {
|
backlinks: {
|
||||||
title: "Legături înapoi",
|
title: "Legături înapoi",
|
||||||
noBacklinksFound: "Nu s-au găsit legături înapoi",
|
noBacklinksFound: "Nu s-au găsit legături înapoi",
|
||||||
|
@ -6,6 +6,21 @@ export default {
|
|||||||
description: "Опис не надано",
|
description: "Опис не надано",
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
callout: {
|
||||||
|
note: "Примітка",
|
||||||
|
abstract: "Абстракт",
|
||||||
|
info: "Інформація",
|
||||||
|
todo: "Завдання",
|
||||||
|
tip: "Порада",
|
||||||
|
success: "Успіх",
|
||||||
|
question: "Питання",
|
||||||
|
warning: "Попередження",
|
||||||
|
failure: "Невдача",
|
||||||
|
danger: "Небезпека",
|
||||||
|
bug: "Баг",
|
||||||
|
example: "Приклад",
|
||||||
|
quote: "Цитата",
|
||||||
|
},
|
||||||
backlinks: {
|
backlinks: {
|
||||||
title: "Зворотні посилання",
|
title: "Зворотні посилання",
|
||||||
noBacklinksFound: "Зворотних посилань не знайдено",
|
noBacklinksFound: "Зворотних посилань не знайдено",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { QuartzTransformerPlugin } from "../types"
|
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 { Element, Literal, Root as HtmlRoot } from "hast"
|
||||||
import { ReplaceFunction, findAndReplace as mdastFindReplace } from "mdast-util-find-and-replace"
|
import { ReplaceFunction, findAndReplace as mdastFindReplace } from "mdast-util-find-and-replace"
|
||||||
import { slug as slugAnchor } from "github-slugger"
|
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 { PhrasingContent } from "mdast-util-find-and-replace/lib"
|
||||||
import { capitalize } from "../../util/lang"
|
import { capitalize } from "../../util/lang"
|
||||||
import { PluggableList } from "unified"
|
import { PluggableList } from "unified"
|
||||||
|
import { ValidCallout, i18n } from "../../i18n"
|
||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
comments: boolean
|
comments: boolean
|
||||||
@ -185,8 +186,9 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
|
|||||||
|
|
||||||
return src
|
return src
|
||||||
},
|
},
|
||||||
markdownPlugins() {
|
markdownPlugins(ctx) {
|
||||||
const plugins: PluggableList = []
|
const plugins: PluggableList = []
|
||||||
|
const cfg = ctx.cfg.configuration
|
||||||
|
|
||||||
// regex replacements
|
// regex replacements
|
||||||
plugins.push(() => {
|
plugins.push(() => {
|
||||||
@ -407,7 +409,12 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>
|
|||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
type: "text",
|
type: "text",
|
||||||
value: useDefaultTitle ? capitalize(calloutType) : titleContent + " ",
|
value: useDefaultTitle
|
||||||
|
? capitalize(
|
||||||
|
i18n(cfg.locale).components.callout[calloutType as ValidCallout] ??
|
||||||
|
calloutType,
|
||||||
|
)
|
||||||
|
: titleContent + " ",
|
||||||
},
|
},
|
||||||
...restOfTitle,
|
...restOfTitle,
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user