ru + en lang
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
export interface Locale {
|
||||
settings: {
|
||||
title: string;
|
||||
description: string;
|
||||
};
|
||||
modules: {
|
||||
'attachment-clean-paste': {
|
||||
name: string;
|
||||
description: string;
|
||||
descriptionShort: string;
|
||||
extensionsLabel: string;
|
||||
extensionsDesc: string;
|
||||
extensionsPlaceholder: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export const en: Locale = {
|
||||
settings: {
|
||||
title: 'ZeroQ QoL Modules',
|
||||
description: 'Enable or disable modules as you wish.',
|
||||
},
|
||||
modules: {
|
||||
'attachment-clean-paste': {
|
||||
name: 'Attachment Clean Paste',
|
||||
description:
|
||||
'Replaces ![[embed]] with [[path/file|name]] for configured file extensions on paste/drop',
|
||||
descriptionShort:
|
||||
'Replaces ![[embed]] with [[path/file|name]] for specified file extensions.',
|
||||
extensionsLabel: 'File extensions',
|
||||
extensionsDesc:
|
||||
'Comma-separated extensions (e.g.: png, jpg, pdf, mp3). Files with these extensions will be inserted as [[path/file|name]] instead of ![[path/file]].',
|
||||
extensionsPlaceholder: 'png, jpg, jpeg, gif, svg, webp, pdf',
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { en, Locale } from './en';
|
||||
import { ru } from './ru';
|
||||
|
||||
const locales: Record<string, Locale> = { en, ru };
|
||||
|
||||
function detectLocale(): Locale {
|
||||
const lang = (navigator.language || 'en').slice(0, 2);
|
||||
return locales[lang] || en;
|
||||
}
|
||||
|
||||
export const locale = detectLocale();
|
||||
export type { Locale };
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Locale } from './en';
|
||||
|
||||
export const ru: Locale = {
|
||||
settings: {
|
||||
title: 'ZeroQ QoL Modules',
|
||||
description: 'Включайте и отключайте модули по своему усмотрению.',
|
||||
},
|
||||
modules: {
|
||||
'attachment-clean-paste': {
|
||||
name: 'Attachment Clean Paste',
|
||||
description:
|
||||
'Заменяет ![[вложение]] на [[вложение|имя]] для указанных расширений при вставке/перетаскивании',
|
||||
descriptionShort:
|
||||
'Заменяет ![[вложение]] на [[вложение|имя]] для указанных расширений.',
|
||||
extensionsLabel: 'Расширения файлов',
|
||||
extensionsDesc:
|
||||
'Расширения через запятую (например: png, jpg, pdf, mp3). Файлы с этими расширениями будут вставляться как [[path/file|name]] вместо ![[path/file]].',
|
||||
extensionsPlaceholder: 'png, jpg, jpeg, gif, svg, webp, pdf',
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from 'obsidian';
|
||||
import type ZeroQoLModulesPlugin from '../../main';
|
||||
import { BaseModule } from '../base-module';
|
||||
import { locale } from '../../locales';
|
||||
|
||||
const MODULE_ID = 'attachment-clean-paste';
|
||||
|
||||
@@ -19,9 +20,8 @@ interface AttachmentCleanPasteSettings {
|
||||
|
||||
export class AttachmentCleanPasteModule extends BaseModule {
|
||||
id = MODULE_ID;
|
||||
name = 'Attachment Clean Paste';
|
||||
description =
|
||||
'Заменяет ![[вложение]] на [[вложение|имя]] для указанных расширений при вставке/перетаскивании';
|
||||
name = locale.modules['attachment-clean-paste'].name;
|
||||
description = locale.modules['attachment-clean-paste'].description;
|
||||
|
||||
private app: App;
|
||||
|
||||
@@ -170,9 +170,11 @@ class AttachmentCleanPasteSettingTab extends PluginSettingTab {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
|
||||
containerEl.createEl('h2', { text: 'Attachment Clean Paste' });
|
||||
const loc = locale.modules['attachment-clean-paste'];
|
||||
|
||||
containerEl.createEl('h2', { text: loc.name });
|
||||
containerEl.createEl('p', {
|
||||
text: 'Заменяет ![[вложение]] на [[вложение|имя]] для указанных расширений.',
|
||||
text: loc.descriptionShort,
|
||||
attr: { style: 'color: var(--text-muted); margin-bottom: 20px;' },
|
||||
});
|
||||
|
||||
@@ -181,13 +183,11 @@ class AttachmentCleanPasteSettingTab extends PluginSettingTab {
|
||||
| undefined;
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Расширения файлов')
|
||||
.setDesc(
|
||||
'Расширения через запятую (например: png, jpg, pdf, mp3). Файлы с этими расширениями будут вставляться как [[path/file|name]] вместо ![[path/file]].',
|
||||
)
|
||||
.setName(loc.extensionsLabel)
|
||||
.setDesc(loc.extensionsDesc)
|
||||
.addTextArea((textarea) => {
|
||||
textarea
|
||||
.setPlaceholder('png, jpg, jpeg, gif, svg, webp, pdf')
|
||||
.setPlaceholder(loc.extensionsPlaceholder)
|
||||
.setValue(rawSettings?.extensions ?? '')
|
||||
.onChange(async (value) => {
|
||||
if (this.plugin.settings.modules[this.moduleId]) {
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ import { App, PluginSettingTab, Setting } from 'obsidian';
|
||||
import type ZeroQoLModulesPlugin from './main';
|
||||
import { MODULES } from './modules';
|
||||
import { ZeroQSettings } from './types';
|
||||
import { locale } from './locales';
|
||||
|
||||
const MODULE_DEFAULTS = MODULES.reduce(
|
||||
(acc, mod) => {
|
||||
@@ -37,9 +38,9 @@ export class ZeroQSettingTab extends PluginSettingTab {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
|
||||
containerEl.createEl('h1', { text: 'ZeroQ QoL Modules' });
|
||||
containerEl.createEl('h1', { text: locale.settings.title });
|
||||
containerEl.createEl('p', {
|
||||
text: 'Включайте и отключайте модули по своему усмотрению.',
|
||||
text: locale.settings.description,
|
||||
attr: { style: 'color: var(--text-muted); margin-bottom: 20px;' },
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user