Allow configuration of default post language

This commit is contained in:
itepechi 2023-08-08 05:39:34 +09:00
parent eef9314bcf
commit 571df1fb1f
6 changed files with 36 additions and 7 deletions

View File

@ -138,7 +138,12 @@ const PostStatusForm = {
statusText = buildMentionsString({ user: this.repliedUser, attentions: this.attentions }, currentUser) statusText = buildMentionsString({ user: this.repliedUser, attentions: this.attentions }, currentUser)
} }
const { postContentType: contentType, sensitiveByDefault, sensitiveIfSubject, interfaceLanguage } = this.$store.getters.mergedConfig const {
postContentType: contentType,
postLanguage: language,
sensitiveByDefault,
sensitiveIfSubject,
} = this.$store.getters.mergedConfig
let statusParams = { let statusParams = {
spoilerText: this.subject || '', spoilerText: this.subject || '',
@ -149,12 +154,13 @@ const PostStatusForm = {
poll: {}, poll: {},
mediaDescriptions: {}, mediaDescriptions: {},
visibility: this.suggestedVisibility(), visibility: this.suggestedVisibility(),
language: interfaceLanguage, contentType,
contentType language
} }
if (this.statusId || this.isRedraft) { if (this.statusId || this.isRedraft) {
const statusContentType = this.statusContentType || contentType const statusContentType = this.statusContentType || contentType
const statusLanguage = this.statusLanguage || language
statusParams = { statusParams = {
spoilerText: this.subject || '', spoilerText: this.subject || '',
status: this.statusText || '', status: this.statusText || '',
@ -164,8 +170,8 @@ const PostStatusForm = {
poll: this.statusPoll || {}, poll: this.statusPoll || {},
mediaDescriptions: this.statusMediaDescriptions || {}, mediaDescriptions: this.statusMediaDescriptions || {},
visibility: this.statusScope || this.suggestedVisibility(), visibility: this.statusScope || this.suggestedVisibility(),
language: this.statusLanguage || interfaceLanguage, contentType: statusContentType,
contentType: statusContentType language: statusLanguage
} }
} }
@ -189,8 +195,8 @@ const PostStatusForm = {
poll: draft.data.poll, poll: draft.data.poll,
mediaDescriptions: draft.data.mediaDescriptions, mediaDescriptions: draft.data.mediaDescriptions,
visibility: draft.data.visibility, visibility: draft.data.visibility,
language: draft.data.language, contentType: draft.data.contentType,
contentType: draft.data.contentType language: draft.data.language
} }
if (draft.data.poll) { if (draft.data.poll) {

View File

@ -10,6 +10,7 @@ import { library } from '@fortawesome/fontawesome-svg-core'
import { import {
faGlobe, faSync faGlobe, faSync
} from '@fortawesome/free-solid-svg-icons' } from '@fortawesome/free-solid-svg-icons'
import iso6391 from 'iso-639-1'
library.add( library.add(
faGlobe, faGlobe,
@ -80,6 +81,15 @@ const GeneralTab = {
label: this.$t(`post_status.content_type["${format}"]`) label: this.$t(`post_status.content_type["${format}"]`)
})) }))
}, },
postLanguages () {
return iso6391.getLanguages(iso6391.getAllCodes())
.map(lang => ({
key: lang.code,
value: lang.code,
label: lang.nativeName,
}))
.sort((a, b) => a.label.localeCompare(b.label));
},
instanceSpecificPanelPresent () { return this.$store.state.instance.showInstanceSpecificPanel }, instanceSpecificPanelPresent () { return this.$store.state.instance.showInstanceSpecificPanel },
instanceWallpaperUsed () { instanceWallpaperUsed () {
return this.$store.state.instance.background && return this.$store.state.instance.background &&

View File

@ -587,6 +587,15 @@
{{ $t('settings.subject_line_behavior') }} {{ $t('settings.subject_line_behavior') }}
</ChoiceSetting> </ChoiceSetting>
</li> </li>
<li>
<ChoiceSetting
id="postLanguage"
path="postLanguage"
:options="postLanguages"
>
{{ $t('settings.post_status_language') }}
</ChoiceSetting>
</li>
<li v-if="postFormats.length > 0"> <li v-if="postFormats.length > 0">
<ChoiceSetting <ChoiceSetting
id="postContentType" id="postContentType"

View File

@ -682,6 +682,7 @@
"play_videos_in_modal": "Play videos in a popup frame", "play_videos_in_modal": "Play videos in a popup frame",
"post_look_feel": "Posts Look & Feel", "post_look_feel": "Posts Look & Feel",
"post_status_content_type": "Default post content type", "post_status_content_type": "Default post content type",
"post_status_language": "Default post language",
"posts": "Posts", "posts": "Posts",
"preload_images": "Preload images", "preload_images": "Preload images",
"presets": "Presets", "presets": "Presets",

View File

@ -681,6 +681,7 @@
"play_videos_in_modal": "ビデオをメディアビューアーで見る", "play_videos_in_modal": "ビデオをメディアビューアーで見る",
"post_look_feel": "投稿の見た目", "post_look_feel": "投稿の見た目",
"post_status_content_type": "投稿のコンテントタイプ", "post_status_content_type": "投稿のコンテントタイプ",
"post_status_language": "投稿の言語",
"posts": "投稿", "posts": "投稿",
"preload_images": "画像を先読みする", "preload_images": "画像を先読みする",
"presets": "プリセット", "presets": "プリセット",

View File

@ -14,6 +14,7 @@ const browserLocale = (window.navigator.language || 'en').split('-')[0]
*/ */
export const multiChoiceProperties = [ export const multiChoiceProperties = [
'postContentType', 'postContentType',
'postLanguage',
'subjectLineBehavior', 'subjectLineBehavior',
'conversationDisplay', // tree | linear 'conversationDisplay', // tree | linear
'conversationOtherRepliesButton', // below | inside 'conversationOtherRepliesButton', // below | inside
@ -79,6 +80,7 @@ export const defaultState = {
subjectLineBehavior: undefined, // instance default subjectLineBehavior: undefined, // instance default
alwaysShowSubjectInput: undefined, // instance default alwaysShowSubjectInput: undefined, // instance default
postContentType: undefined, // instance default postContentType: undefined, // instance default
postLanguage: browserLocale,
// This hides statuses filtered via a word filter // This hides statuses filtered via a word filter
hideFilteredStatuses: undefined, // instance default hideFilteredStatuses: undefined, // instance default
modalOnRepeat: undefined, // instance default modalOnRepeat: undefined, // instance default