merge: Add LibreTranslate as an option to External Services (!935)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/935 Closes #807 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Hazelnoot <acomputerdog@gmail.com>
This commit is contained in:
commit
49597e7e08
8 changed files with 194 additions and 65 deletions
|
|
@ -8,30 +8,50 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<template #header><XHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
||||
<MkSpacer :contentMax="700" :marginMin="16" :marginMax="32">
|
||||
<FormSuspense :p="init">
|
||||
<MkFolder>
|
||||
<template #label>DeepL Translation</template>
|
||||
<div class="_gaps_m">
|
||||
<MkFolder>
|
||||
<template #label>DeepL Translation</template>
|
||||
|
||||
<div class="_gaps_m">
|
||||
<MkInput v-model="deeplAuthKey">
|
||||
<template #prefix><i class="ti ti-key"></i></template>
|
||||
<template #label>DeepL Auth Key</template>
|
||||
</MkInput>
|
||||
<MkSwitch v-model="deeplIsPro">
|
||||
<template #label>Pro account</template>
|
||||
</MkSwitch>
|
||||
<div class="_gaps_m">
|
||||
<MkInput v-model="deeplAuthKey">
|
||||
<template #prefix><i class="ti ti-key"></i></template>
|
||||
<template #label>DeepL Auth Key</template>
|
||||
</MkInput>
|
||||
<MkSwitch v-model="deeplIsPro">
|
||||
<template #label>Pro account</template>
|
||||
</MkSwitch>
|
||||
|
||||
<MkSwitch v-model="deeplFreeMode">
|
||||
<template #label>{{ i18n.ts.deeplFreeMode }}</template>
|
||||
</MkSwitch>
|
||||
<MkInput v-if="deeplFreeMode" v-model="deeplFreeInstance" :placeholder="'example.com/translate'">
|
||||
<template #prefix><i class="ph-globe-simple ph-bold ph-lg"></i></template>
|
||||
<template #label>DeepLX-JS URL</template>
|
||||
<template #caption>{{ i18n.ts.deeplFreeModeDescription }}</template>
|
||||
</MkInput>
|
||||
<MkSwitch v-model="deeplFreeMode">
|
||||
<template #label>{{ i18n.ts.deeplFreeMode }}</template>
|
||||
</MkSwitch>
|
||||
<MkInput v-if="deeplFreeMode" v-model="deeplFreeInstance" :placeholder="'example.com/translate'">
|
||||
<template #prefix><i class="ph-globe-simple ph-bold ph-lg"></i></template>
|
||||
<template #label>DeepLX-JS URL</template>
|
||||
<template #caption>{{ i18n.ts.deeplFreeModeDescription }}</template>
|
||||
</MkInput>
|
||||
|
||||
<MkButton primary @click="save_deepl">Save</MkButton>
|
||||
</div>
|
||||
</MkFolder>
|
||||
<MkButton primary @click="save_deepl">Save</MkButton>
|
||||
</div>
|
||||
</MkFolder>
|
||||
|
||||
<MkFolder>
|
||||
<template #label>LibreTranslate Translation</template>
|
||||
|
||||
<div class="_gaps_m">
|
||||
<MkInput v-model="libreTranslateURL" :placeholder="'example.com/translate'">
|
||||
<template #prefix><i class="ph-globe-simple ph-bold ph-lg"></i></template>
|
||||
<template #label>LibreTranslate URL</template>
|
||||
</MkInput>
|
||||
|
||||
<MkInput v-model="libreTranslateKey">
|
||||
<template #prefix><i class="ti ti-key"></i></template>
|
||||
<template #label>LibreTranslate Api Key</template>
|
||||
</MkInput>
|
||||
|
||||
<MkButton primary @click="save_libre">Save</MkButton>
|
||||
</div>
|
||||
</MkFolder>
|
||||
</div>
|
||||
</FormSuspense>
|
||||
</MkSpacer>
|
||||
</MkStickyContainer>
|
||||
|
|
@ -51,10 +71,12 @@ import { i18n } from '@/i18n.js';
|
|||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||
import MkFolder from '@/components/MkFolder.vue';
|
||||
|
||||
const deeplAuthKey = ref<string>('');
|
||||
const deeplAuthKey = ref<string | null>('');
|
||||
const deeplIsPro = ref<boolean>(false);
|
||||
const deeplFreeMode = ref<boolean>(false);
|
||||
const deeplFreeInstance = ref<string>('');
|
||||
const deeplFreeInstance = ref<string | null>('');
|
||||
const libreTranslateURL = ref<string | null>('');
|
||||
const libreTranslateKey = ref<string | null>('');
|
||||
|
||||
async function init() {
|
||||
const meta = await misskeyApi('admin/meta');
|
||||
|
|
@ -62,6 +84,8 @@ async function init() {
|
|||
deeplIsPro.value = meta.deeplIsPro;
|
||||
deeplFreeMode.value = meta.deeplFreeMode;
|
||||
deeplFreeInstance.value = meta.deeplFreeInstance;
|
||||
libreTranslateURL.value = meta.libreTranslateURL;
|
||||
libreTranslateKey.value = meta.libreTranslateKey;
|
||||
}
|
||||
|
||||
function save_deepl() {
|
||||
|
|
@ -75,6 +99,15 @@ function save_deepl() {
|
|||
});
|
||||
}
|
||||
|
||||
function save_libre() {
|
||||
os.apiWithDialog('admin/update-meta', {
|
||||
libreTranslateURL: libreTranslateURL.value,
|
||||
libreTranslateKey: libreTranslateKey.value,
|
||||
}).then(() => {
|
||||
fetchInstance(true);
|
||||
});
|
||||
}
|
||||
|
||||
const headerActions = computed(() => []);
|
||||
|
||||
const headerTabs = computed(() => []);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue