fix: allow unsetting language

This commit is contained in:
Xylight committed 2024-09-08 16:40:02 -07:00
1 parent f2b16d5669
commit 21ae0f8272
2 files changed
+15 -5

No files matched your search

@@ -4,17 +4,15 @@
import type { Community, Post, PostView } from 'lemmy-js-client'
import { Select, Spinner, Switch, toast } from 'mono-svelte'
import {
Check,
Icon,
Photo,
BookOpen,
ArrowPath,
Sparkles,
ChatBubbleBottomCenterText,
EllipsisHorizontal,
Plus,
Language,
Link,
XMark,
} from 'svelte-hero-icons'
import { profile } from '$lib/auth.js'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
@@ -29,6 +27,7 @@
import { feature } from '$lib/version'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import ErrorContainer, {
clearErrorScope,
pushError,
} from '$lib/components/error/ErrorContainer.svelte'
import { errorMessage } from '$lib/lemmy/error'
@@ -66,6 +65,9 @@
alt_text: undefined,
language_id: undefined,
}
// weird select menu language handling
// @ts-ignore
$: if (data.language_id === '') data.language_id = undefined
let saveDraft = edit ? false : true
let communitySearch = passedCommunity?.name ?? ''
@@ -82,6 +84,7 @@
data.nsfw = editingPost.nsfw
data.alt_text = editingPost.alt_text
data.thumbnail = editingPost.thumbnail_url
// @ts-ignore
data.language_id = editingPost.language_id.toString()
}
@@ -106,6 +109,7 @@
})
async function submit() {
clearErrorScope('post-form')
if (!data.community && !edit) {
pushError({
message: $t('toast.needCommunity'),
@@ -413,6 +417,10 @@
label={$t('settings.app.lang.title')}
bind:value={data.language_id}
>
<option value={undefined}>
<Icon src={XMark} size="16" micro />
{$t('form.post.unset')}
</option>
{#each $site?.all_languages as language}
<option value={language.id.toString()}>{language.name}</option>
{/each}
+4 -2
View File
@@ -138,7 +138,8 @@
"selectFile": "Select a file",
"altText": "Alt Text",
"addUrl": "Add URL",
"setLanguage": "Set language"
"setLanguage": "Set language",
"unset": "Unset"
},
"profile": {
"displayName": "Display name",
@@ -847,7 +848,8 @@
"slurs": "Your submission contains a term banned in this instance.",
"captcha_failed": "Incorrect CAPTCHA answer.",
"cant_block_local_instance": "You can't block the instance you are actively using.",
"invalid_vote_value": "You can't commit voter fraud on Lemmy posts, sorry."
"invalid_vote_value": "You can't commit voter fraud on Lemmy posts, sorry.",
"language_not_allowed": "That language isn't allowed in this community. Unset it to use the community's default."
},
"aria": {
"pagination": {