feat(publish): support status language

relate issue #332
zio/stable
三咲智子 2023-01-02 05:52:00 +08:00
parent b8c7ed8157
commit aca6f16245
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
7 changed files with 55 additions and 2 deletions

View File

@ -3,6 +3,7 @@ import type { Attachment, CreateStatusParams, Status, StatusVisibility } from 'm
import { fileOpen } from 'browser-fs-access'
import { useDropZone } from '@vueuse/core'
import { EditorContent } from '@tiptap/vue-3'
import ISO6391 from 'iso-639-1'
import type { Draft } from '~/types'
type FileUploadError = [filename: string, message: string]
@ -135,6 +136,10 @@ function chooseVisibility(visibility: StatusVisibility) {
draft.params.visibility = visibility
}
function chooseLanguage(language: string | null) {
draft.params.language = language
}
async function publish() {
const payload = {
...draft.params,
@ -323,6 +328,41 @@ defineExpose({
</button>
</CommonTooltip>
<CommonTooltip placement="top" :content="$t('tooltip.change_language')">
<CommonDropdown placement="bottom">
<button btn-action-icon :aria-label="$t('tooltip.change_language')">
<div i-ri:translate-2 />
<div i-ri:arrow-down-s-line text-sm text-secondary me--1 />
</button>
<template #popper>
<div min-w-80 p3>
<!-- TODO search lang -->
<!-- <input
placeholder="Search"
p2 mb2 border-rounded w-full bg-transparent
outline-none border="~ base"
> -->
<div max-h-40vh overflow-auto>
<CommonDropdownItem
v-for="code in [null, ...ISO6391.getAllCodes()]"
:key="code"
:checked="code === (draft.params.language || null)"
@click="chooseLanguage(code)"
>
{{ code ? ISO6391.getNativeName(code) : 'None' }}
<template #description>
<template v-if="code">
{{ ISO6391.getName(code) }}
</template>
</template>
</CommonDropdownItem>
</div>
</div>
</template>
</CommonDropdown>
</CommonTooltip>
<CommonTooltip placement="bottom" :content="$t('tooltip.change_content_visibility')">
<CommonDropdown>
<button :aria-label="$t('tooltip.change_content_visibility')" btn-action-icon w-12>

View File

@ -347,6 +347,7 @@
"add_content_warning": "Add content warning",
"add_media": "Add images, a video or an audio file",
"change_content_visibility": "Change content visibility",
"change_language": "Change language",
"emoji": "Emoji",
"explore_links_intro": "These news stories are being talked about by people on this and other servers of the decentralized network right now.",
"explore_posts_intro": "These posts from this and other servers in the decentralized network are gaining traction on this server right now.",

View File

@ -350,6 +350,7 @@
"add_content_warning": "Add content warning",
"add_media": "Add images, a video or an audio file",
"change_content_visibility": "Change content visibility",
"change_language": "Change language",
"emoji": "Emoji",
"explore_links_intro": "These news stories are being talked about by people on this and other servers of the decentralized network right now.",
"explore_posts_intro": "These posts from this and other servers in the decentralized network are gaining traction on this server right now.",

View File

@ -340,6 +340,7 @@
"add_content_warning": "添加内容警告标识",
"add_media": "添加图片、视频或者音频文件",
"change_content_visibility": "修改内容是否可见",
"change_language": "更改语言",
"emoji": "表情符号",
"explore_links_intro": "这些新闻故事正被本站和分布式网络上其他站点的用户谈论。",
"explore_posts_intro": "来自本站和分布式网络上其他站点的这些嘟文正在本站引起关注。",

View File

@ -340,6 +340,7 @@
"add_content_warning": "添加內容警告標識",
"add_media": "添加圖片、視頻或者音頻文件",
"change_content_visibility": "修改內容是否可見",
"change_language": "改變語言",
"emoji": "表情符號",
"explore_links_intro": "這些新聞故事正被本站和分佈式網絡上其他站點的用戶談論。",
"explore_posts_intro": "來自本站和分佈式網絡上其他站點的這些嘟文正在本站引起關注。",

View File

@ -47,6 +47,7 @@
"form-data": "^4.0.0",
"fuse.js": "^6.6.2",
"idb-keyval": "^6.2.0",
"iso-639-1": "^2.1.15",
"js-yaml": "^4.1.0",
"lru-cache": "^7.14.1",
"masto": "^4.11.1",

View File

@ -51,6 +51,7 @@ specifiers:
fs-extra: ^11.1.0
fuse.js: ^6.6.2
idb-keyval: ^6.2.0
iso-639-1: ^2.1.15
js-yaml: ^4.1.0
jsdom: ^20.0.3
lint-staged: ^13.1.0
@ -106,6 +107,7 @@ dependencies:
form-data: 4.0.0
fuse.js: 6.6.2
idb-keyval: 6.2.0
iso-639-1: 2.1.15
js-yaml: 4.1.0
lru-cache: 7.14.1
masto: 4.11.1
@ -163,7 +165,7 @@ devDependencies:
typescript: 4.9.4
unplugin-auto-import: 0.12.1_@vueuse+core@9.9.0
vite-plugin-inspect: 0.7.11
vite-plugin-pwa: 0.13.3
vite-plugin-pwa: 0.13.3_workbox-window@6.5.4
vitest: 0.26.2_jsdom@20.0.3
vue-tsc: 1.0.16_typescript@4.9.4
workbox-window: 6.5.4
@ -6613,6 +6615,11 @@ packages:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
dev: true
/iso-639-1/2.1.15:
resolution: {integrity: sha512-7c7mBznZu2ktfvyT582E2msM+Udc1EjOyhVRE/0ZsjD9LBtWSm23h3PtiRh2a35XoUsTQQjJXaJzuLjXsOdFDg==}
engines: {node: '>=6.0'}
dev: false
/isomorphic-form-data/2.0.0:
resolution: {integrity: sha512-TYgVnXWeESVmQSg4GLVbalmQ+B4NPi/H4eWxqALKj63KsUrcu301YDjBqaOw3h+cbak7Na4Xyps3BiptHtxTfg==}
dependencies:
@ -9941,10 +9948,11 @@ packages:
- supports-color
dev: true
/vite-plugin-pwa/0.13.3:
/vite-plugin-pwa/0.13.3_workbox-window@6.5.4:
resolution: {integrity: sha512-cjWXpZ7slAY14OKz7M8XdgTIi9wjf6OD6NkhiMAc+ogxnbUrecUwLdRtfGPCPsN2ftut5gaN1jTghb11p6IQAA==}
peerDependencies:
vite: ^3.1.0
workbox-window: ^6.5.4
dependencies:
'@rollup/plugin-replace': 4.0.0_rollup@2.79.1
debug: 4.3.4