ru + en lang

This commit is contained in:
2026-07-11 02:54:10 +03:00
parent 106b884c03
commit 2dec5660f6
6 changed files with 82 additions and 75 deletions
-63
View File
@@ -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."
+36
View File
@@ -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',
},
},
};
+12
View File
@@ -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 };
+21
View File
@@ -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 -10
View File
@@ -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
View File
@@ -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;' },
});