diff --git a/quartz/i18n/index.ts b/quartz/i18n/index.ts index ec2a757dab176..98d330b954fe9 100644 --- a/quartz/i18n/index.ts +++ b/quartz/i18n/index.ts @@ -1,54 +1,56 @@ -import ar from "./locales/ar-SA"; -import de from "./locales/de-DE"; -import { CalloutTranslation,Translation } from "./locales/definition"; -import en from "./locales/en-US"; -import es from "./locales/es-ES"; -import fr from "./locales/fr-FR"; -import it from "./locales/it-IT"; -import ja from "./locales/ja-JP"; -import ko from "./locales/ko-KR"; -import nl from "./locales/nl-NL"; -import ro from "./locales/ro-RO"; -import ru from "./locales/ru-RU"; -import uk from "./locales/uk-UA"; -import zh from "./locales/zh-CN"; +import { Translation, CalloutTranslation } from "./locales/definition" +import en from "./locales/en-US" +import fr from "./locales/fr-FR" +import it from "./locales/it-IT" +import ja from "./locales/ja-JP" +import de from "./locales/de-DE" +import nl from "./locales/nl-NL" +import ro from "./locales/ro-RO" +import es from "./locales/es-ES" +import ar from "./locales/ar-SA" +import uk from "./locales/uk-UA" +import ru from "./locales/ru-RU" +import ko from "./locales/ko-KR" +import zh from "./locales/zh-CN" +import vi from "./locales/vi-VN" export const TRANSLATIONS = { - "en-US": en, - "fr-FR": fr, - "it-IT": it, - "ja-JP": ja, - "de-DE": de, - "nl-NL": nl, - "nl-BE": nl, - "ro-RO": ro, - "ro-MD": ro, - "es-ES": es, - "ar-SA": ar, - "ar-AE": ar, - "ar-QA": ar, - "ar-BH": ar, - "ar-KW": ar, - "ar-OM": ar, - "ar-YE": ar, - "ar-IR": ar, - "ar-SY": ar, - "ar-IQ": ar, - "ar-JO": ar, - "ar-PL": ar, - "ar-LB": ar, - "ar-EG": ar, - "ar-SD": ar, - "ar-LY": ar, - "ar-MA": ar, - "ar-TN": ar, - "ar-DZ": ar, - "ar-MR": ar, - "uk-UA": uk, - "ru-RU": ru, - "ko-KR": ko, - "zh-CN": zh, -} as const; + "en-US": en, + "fr-FR": fr, + "it-IT": it, + "ja-JP": ja, + "de-DE": de, + "nl-NL": nl, + "nl-BE": nl, + "ro-RO": ro, + "ro-MD": ro, + "es-ES": es, + "ar-SA": ar, + "ar-AE": ar, + "ar-QA": ar, + "ar-BH": ar, + "ar-KW": ar, + "ar-OM": ar, + "ar-YE": ar, + "ar-IR": ar, + "ar-SY": ar, + "ar-IQ": ar, + "ar-JO": ar, + "ar-PL": ar, + "ar-LB": ar, + "ar-EG": ar, + "ar-SD": ar, + "ar-LY": ar, + "ar-MA": ar, + "ar-TN": ar, + "ar-DZ": ar, + "ar-MR": ar, + "uk-UA": uk, + "ru-RU": ru, + "ko-KR": ko, + "zh-CN": zh, + "vi-VN": vi, +} as const export const defaultTranslation = "en-US"; export const i18n = (locale: ValidLocale): Translation => TRANSLATIONS[locale ?? defaultTranslation]; diff --git a/quartz/i18n/locales/vi-VN.ts b/quartz/i18n/locales/vi-VN.ts new file mode 100644 index 0000000000000..b72ced4ac55df --- /dev/null +++ b/quartz/i18n/locales/vi-VN.ts @@ -0,0 +1,83 @@ +import { Translation } from "./definition" + +export default { + propertyDefaults: { + title: "Không có tiêu đề", + description: "Không có mô tả được cung cấp", + }, + components: { + callout: { + note: "Ghi Chú", + abstract: "Tóm Tắt", + info: "Thông tin", + todo: "Cần Làm", + tip: "Gợi Ý", + success: "Thành Công", + question: "Nghi Vấn", + warning: "Cảnh Báo", + failure: "Thất Bại", + danger: "Nguy Hiểm", + bug: "Lỗi", + example: "Ví Dụ", + quote: "Trích Dẫn", + }, + backlinks: { + title: "Liên Kết Ngược", + noBacklinksFound: "Không có liên kết ngược được tìm thấy", + }, + themeToggle: { + lightMode: "Sáng", + darkMode: "Tối", + }, + explorer: { + title: "Trong bài này", + }, + footer: { + createdWith: "Được tạo bởi", + }, + graph: { + title: "Biểu Đồ", + }, + recentNotes: { + title: "Bài viết gần đây", + seeRemainingMore: ({ remaining }) => `Xem ${remaining} thêm →`, + }, + transcludes: { + transcludeOf: ({ targetSlug }) => `Bao gồm ${targetSlug}`, + linkToOriginal: "Liên Kết Gốc", + }, + search: { + title: "Tìm Kiếm", + searchBarPlaceholder: "Tìm kiếm thông tin", + }, + tableOfContents: { + title: "Bảng Nội Dung", + }, + contentMeta: { + readingTime: ({ minutes }) => `đọc ${minutes} phút`, + }, + }, + pages: { + rss: { + recentNotes: "Những bài gần đây", + lastFewNotes: ({ count }) => `${count} Bài gần đây`, + }, + error: { + title: "Không Tìm Thấy", + notFound: "Trang này được bảo mật hoặc không tồn tại.", + }, + folderContent: { + folder: "Thư Mục", + itemsUnderFolder: ({ count }) => + count === 1 ? "1 mục trong thư mục này." : `${count} mục trong thư mục này.`, + }, + tagContent: { + tag: "Thẻ", + tagIndex: "Thẻ Mục Lục", + itemsUnderTag: ({ count }) => + count === 1 ? "1 mục gắn thẻ này." : `${count} mục gắn thẻ này.`, + showingFirst: ({ count }) => `Hiển thị trước ${count} thẻ.`, + totalTags: ({ count }) => `Tìm thấy ${count} thẻ tổng cộng.`, + }, + }, +} as const satisfies Translation diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts index 8689865924c9e..58367bb11c14e 100644 --- a/quartz/plugins/transformers/ofm.ts +++ b/quartz/plugins/transformers/ofm.ts @@ -1,23 +1,22 @@ -import { slug as slugAnchor } from "github-slugger"; -import { Element, Literal, Root as HtmlRoot } from "hast"; -import { toHtml } from "hast-util-to-html"; -import { BlockContent, Code,DefinitionContent, Html, Paragraph, Root } from "mdast"; -import { findAndReplace as mdastFindReplace,ReplaceFunction } from "mdast-util-find-and-replace"; -import { PhrasingContent } from "mdast-util-find-and-replace/lib"; -import { toHast } from "mdast-util-to-hast"; -import path from "path"; -import rehypeRaw from "rehype-raw"; -import { PluggableList } from "unified"; -import { SKIP, visit } from "unist-util-visit"; - +import { QuartzTransformerPlugin } from "../types" +import { 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 rehypeRaw from "rehype-raw" +import { SKIP, visit } from "unist-util-visit" +import path from "path" +import { JSResource } from "../../util/resources" // @ts-ignore import calloutScript from "../../components/scripts/callout.inline.ts"; // @ts-ignore -import checkboxScript from "../../components/scripts/checkbox.inline.ts"; -import { capitalize } from "../../util/lang"; -import { FilePath, pathToRoot, slugifyFilePath,slugTag } from "../../util/path"; -import { JSResource } from "../../util/resources"; -import { QuartzTransformerPlugin } from "../types"; +import checkboxScript from "../../components/scripts/checkbox.inline.ts" +import { FilePath, pathToRoot, slugTag, slugifyFilePath } from "../../util/path" +import { toHast } from "mdast-util-to-hast" +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" export interface Options { comments: boolean @@ -528,22 +527,45 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin last.value = last.value.slice(0, -matches[0].length); const block = matches[0].slice(1); - if (!Object.keys(file.data.blocks!).includes(block)) { - node.properties = { - ...node.properties, - id: block, - }; - file.data.blocks![block] = node; - } - } - } - } - }); - - file.data.htmlAst = tree; - }; - }); - } + if (last.value === "") { + // this is an inline block ref but the actual block + // is the previous element above it + let idx = (index ?? 1) - 1 + while (idx >= 0) { + const element = parent?.children.at(idx) + if (!element) break + if (element.type !== "element") { + idx -= 1 + } else { + if (!Object.keys(file.data.blocks!).includes(block)) { + element.properties = { + ...element.properties, + id: block, + } + file.data.blocks![block] = element + } + return + } + } + } else { + // normal paragraph transclude + if (!Object.keys(file.data.blocks!).includes(block)) { + node.properties = { + ...node.properties, + id: block, + } + file.data.blocks![block] = node + } + } + } + } + } + }) + + file.data.htmlAst = tree + } + }) + } if (opts.enableYouTubeEmbed) { plugins.push(() => {