From 21ae0f8272c87139db9f41ccb7d1ed71a055719c Mon Sep 17 00:00:00 2001 From: Xylight Date: Sun, 8 Sep 2024 16:40:02 -0700 Subject: [PATCH] fix: allow unsetting language --- src/lib/components/lemmy/post/form/PostForm.svelte | 14 +++++++++++--- src/lib/i18n/en.json | 6 ++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/lib/components/lemmy/post/form/PostForm.svelte b/src/lib/components/lemmy/post/form/PostForm.svelte index 2aca87ca..2f3ba3a3 100644 --- a/src/lib/components/lemmy/post/form/PostForm.svelte +++ b/src/lib/components/lemmy/post/form/PostForm.svelte @@ -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} > + {#each $site?.all_languages as language} {/each} diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index e94224a5..65f9ad40 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -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": {