From 18613da93eb0941a6a7a464f924101a994def23c Mon Sep 17 00:00:00 2001 From: AntoKeinanen Date: Thu, 27 Mar 2025 20:22:01 +0200 Subject: [PATCH] fix: correctly remove yaml and undo accidental class removal --- src/main.ts | 10 ++++++---- src/translation.ts | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 4f6412e..639bba6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -150,10 +150,12 @@ export default class AdvancedMerge extends Plugin { ); } - sectionContents = sectionContents.replace( - /^---\n(\w*:\s.*\n)*---/, - "", - ); + if (this.settings.removeYamlProperties) { + sectionContents = sectionContents.replace( + /---\n(\w*:\s.*\n)*---/, + "", + ); + } vault.append(outputFile, sectionContents); } diff --git a/src/translation.ts b/src/translation.ts index ed9b666..563d8e5 100644 --- a/src/translation.ts +++ b/src/translation.ts @@ -161,3 +161,25 @@ export const TRANSLATIONS: Record = { "Видаляє властивості YAML із верхньої частини файлу під час об'єднання. УВАГА: Це може випадково видалити не-YAML частини.", }, }; + +export class AdvancedMergeTranslation { + private language: string; + + /** + * Represents a plugin translation. + * @constructor + */ + constructor() { + this.language = !Object.keys(TRANSLATIONS).contains(navigator.language) + ? DEFAULT_LANGUAGE + : navigator.language; + } + + /** + * Gets translation object for current language. + * @returns {Translation} Current translation object. + */ + public get(): Translation { + return TRANSLATIONS[this.language]; + } +}