diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml deleted file mode 100644 index 4374c00..0000000 --- a/.gitea/workflows/release.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Draft Release -on: - push: - branches: [master] -jobs: - draft: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - - run: npm ci - - run: npm run build - - run: zip -j zeroq-qol-modules.zip main.js manifest.json styles.css - - name: Create or update draft release - env: - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - run: | - set -e - API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" - TAG="latest-build" - SHA="${GITHUB_SHA}" - - EXISTING=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \ - "${API}/releases" \ - | jq '.[] | select(.tag_name == "'"${TAG}"'" and .draft == true) | .id') - - if [ -z "$EXISTING" ]; then - echo "Creating new draft release..." - RESP=$(curl -s -X POST -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: application/json" \ - -d '{ - "tag_name": "'"${TAG}"'", - "name": "Latest Build from master", - "body": "Автоматическая сборка из ветки `master`.\n\nКоммит: '"${SHA}"'", - "draft": true, - "prerelease": true - }' "${API}/releases") - RELEASE_ID=$(echo "$RESP" | jq -r '.id') - else - echo "Updating existing draft release (id: ${EXISTING})..." - RELEASE_ID=$EXISTING - - curl -s -X PATCH -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: application/json" \ - -d '{ - "body": "Автоматическая сборка из ветки `master`.\n\nКоммит: '"${SHA}"'" - }' "${API}/releases/${RELEASE_ID}" - - ASSETS=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \ - "${API}/releases/${RELEASE_ID}/assets" | jq -r '.[].id') - for AID in $ASSETS; do - curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \ - "${API}/releases/${RELEASE_ID}/assets/${AID}" - done - fi - - echo "Uploading artifact..." - curl -s -X POST -H "Authorization: token ${GITEA_TOKEN}" \ - -F "attachment=@zeroq-qol-modules.zip" \ - "${API}/releases/${RELEASE_ID}/assets" - echo "Done." diff --git a/src/locales/en.ts b/src/locales/en.ts new file mode 100644 index 0000000..1ba6c38 --- /dev/null +++ b/src/locales/en.ts @@ -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', + }, + }, +}; diff --git a/src/locales/index.ts b/src/locales/index.ts new file mode 100644 index 0000000..809159a --- /dev/null +++ b/src/locales/index.ts @@ -0,0 +1,12 @@ +import { en, Locale } from './en'; +import { ru } from './ru'; + +const locales: Record = { en, ru }; + +function detectLocale(): Locale { + const lang = (navigator.language || 'en').slice(0, 2); + return locales[lang] || en; +} + +export const locale = detectLocale(); +export type { Locale }; diff --git a/src/locales/ru.ts b/src/locales/ru.ts new file mode 100644 index 0000000..eb04df3 --- /dev/null +++ b/src/locales/ru.ts @@ -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', + }, + }, +}; diff --git a/src/modules/attachment-clean-paste/index.ts b/src/modules/attachment-clean-paste/index.ts index dc0ce0e..7dc8c73 100644 --- a/src/modules/attachment-clean-paste/index.ts +++ b/src/modules/attachment-clean-paste/index.ts @@ -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]) { diff --git a/src/settings.ts b/src/settings.ts index db7092d..e316fab 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -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;' }, });