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>
| | |
| | | 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" |
| | |
| | | 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 |
| | |
| | | description: "لم يتم تقديم أي وصف", |
| | | }, |
| | | components: { |
| | | callout: { |
| | | note: "ملاحظة", |
| | | abstract: "ملخص", |
| | | info: "معلومات", |
| | | todo: "للقيام", |
| | | tip: "نصيحة", |
| | | success: "نجاح", |
| | | question: "سؤال", |
| | | warning: "تحذير", |
| | | failure: "فشل", |
| | | danger: "خطر", |
| | | bug: "خلل", |
| | | example: "مثال", |
| | | quote: "اقتباس", |
| | | }, |
| | | backlinks: { |
| | | title: "وصلات العودة", |
| | | noBacklinksFound: "لا يوجد وصلات عودة", |
| | |
| | | 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", |
| | |
| | | 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 |
| | |
| | | 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", |
| | |
| | | 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", |
| | |
| | | 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é", |
| | |
| | | description: "説明なし", |
| | | }, |
| | | components: { |
| | | callout: { |
| | | note: "ノート", |
| | | abstract: "抄録", |
| | | info: "情報", |
| | | todo: "やるべきこと", |
| | | tip: "ヒント", |
| | | success: "成功", |
| | | question: "質問", |
| | | warning: "警告", |
| | | failure: "失敗", |
| | | danger: "危険", |
| | | bug: "バグ", |
| | | example: "例", |
| | | quote: "引用", |
| | | }, |
| | | backlinks: { |
| | | title: "バックリンク", |
| | | noBacklinksFound: "バックリンクはありません", |
| | |
| | | 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", |
| | |
| | | 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", |
| | |
| | | description: "Опис не надано", |
| | | }, |
| | | components: { |
| | | callout: { |
| | | note: "Примітка", |
| | | abstract: "Абстракт", |
| | | info: "Інформація", |
| | | todo: "Завдання", |
| | | tip: "Порада", |
| | | success: "Успіх", |
| | | question: "Питання", |
| | | warning: "Попередження", |
| | | failure: "Невдача", |
| | | danger: "Небезпека", |
| | | bug: "Баг", |
| | | example: "Приклад", |
| | | quote: "Цитата", |
| | | }, |
| | | backlinks: { |
| | | title: "Зворотні посилання", |
| | | noBacklinksFound: "Зворотних посилань не знайдено", |
| | |
| | | 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" |
| | |
| | | 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 |
| | |
| | | |
| | | return src |
| | | }, |
| | | markdownPlugins() { |
| | | markdownPlugins(ctx) { |
| | | const plugins: PluggableList = [] |
| | | const cfg = ctx.cfg.configuration |
| | | |
| | | // regex replacements |
| | | plugins.push(() => { |
| | |
| | | children: [ |
| | | { |
| | | type: "text", |
| | | value: useDefaultTitle ? capitalize(calloutType) : titleContent + " ", |
| | | value: useDefaultTitle |
| | | ? capitalize( |
| | | i18n(cfg.locale).components.callout[calloutType as ValidCallout] ?? |
| | | calloutType, |
| | | ) |
| | | : titleContent + " ", |
| | | }, |
| | | ...restOfTitle, |
| | | ], |