Add config opts for email language

This commit is contained in:
Tusooa Zhu 2022-03-26 12:39:26 -04:00
parent a5e861cd01
commit d39de30221
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
5 changed files with 46 additions and 17 deletions

View file

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<label for="interface-language-switcher"> <label for="interface-language-switcher">
{{ $t('settings.interfaceLanguage') }} {{ promptText }}
</label> </label>
{{ ' ' }} {{ ' ' }}
<Select <Select
@ -28,8 +28,18 @@ export default {
Select Select
}, },
props: { props: {
language: String, promptText: {
setLanguage: Function type: String,
required: true
},
language: {
type: String,
required: true
},
setLanguage: {
type: String,
required: true
}
}, },
computed: { computed: {
languages () { languages () {

View file

@ -5,6 +5,7 @@
<ul class="setting-list"> <ul class="setting-list">
<li> <li>
<interface-language-switcher <interface-language-switcher
:prompt-text="$t('settings.interfaceLanguage')"
:language="language" :language="language"
:set-language="val => language = val" :set-language="val => language = val"
/> />

View file

@ -8,8 +8,10 @@ import EmojiInput from 'src/components/emoji_input/emoji_input.vue'
import suggestor from 'src/components/emoji_input/suggestor.js' import suggestor from 'src/components/emoji_input/suggestor.js'
import Autosuggest from 'src/components/autosuggest/autosuggest.vue' import Autosuggest from 'src/components/autosuggest/autosuggest.vue'
import Checkbox from 'src/components/checkbox/checkbox.vue' import Checkbox from 'src/components/checkbox/checkbox.vue'
import InterfaceLanguageSwitcher from 'src/components/interface_language_switcher/interface_language_switcher.vue'
import BooleanSetting from '../helpers/boolean_setting.vue' import BooleanSetting from '../helpers/boolean_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js' import SharedComputedObject from '../helpers/shared_computed_object.js'
import localeService from 'src/services/locale/locale.service.js'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { import {
@ -40,7 +42,8 @@ const ProfileTab = {
banner: null, banner: null,
bannerPreview: null, bannerPreview: null,
background: null, background: null,
backgroundPreview: null backgroundPreview: null,
emailLanguage: this.$store.state.users.currentUser.language
} }
}, },
components: { components: {
@ -50,7 +53,8 @@ const ProfileTab = {
Autosuggest, Autosuggest,
ProgressButton, ProgressButton,
Checkbox, Checkbox,
BooleanSetting BooleanSetting,
InterfaceLanguageSwitcher
}, },
computed: { computed: {
user () { user () {
@ -111,9 +115,7 @@ const ProfileTab = {
}, },
methods: { methods: {
updateProfile () { updateProfile () {
this.$store.state.api.backendInteractor const params = {
.updateProfile({
params: {
note: this.newBio, note: this.newBio,
locked: this.newLocked, locked: this.newLocked,
// Backend notation. // Backend notation.
@ -121,9 +123,17 @@ const ProfileTab = {
display_name: this.newName, display_name: this.newName,
fields_attributes: this.newFields.filter(el => el != null), fields_attributes: this.newFields.filter(el => el != null),
bot: this.bot, bot: this.bot,
show_role: this.showRole show_role: this.showRole,
/* eslint-enable camelcase */ /* eslint-enable camelcase */
} }).then((user) => { }
if (this.emailLanguage) {
params.language = localeService.internalToBackendLocale(this.emailLanguage)
}
this.$store.state.api.backendInteractor
.updateProfile({ params })
.then((user) => {
this.newFields.splice(user.fields.length) this.newFields.splice(user.fields.length)
merge(this.newFields, user.fields) merge(this.newFields, user.fields)
this.$store.commit('addNewUsers', [user]) this.$store.commit('addNewUsers', [user])

View file

@ -89,6 +89,13 @@
{{ $t('settings.bot') }} {{ $t('settings.bot') }}
</Checkbox> </Checkbox>
</p> </p>
<p>
<interface-language-switcher
:prompt-text="$t('settings.email_language')"
:language="emailLanguage"
:set-language="val => emailLanguage = val"
/>
</p>
<button <button
:disabled="newName && newName.length === 0" :disabled="newName && newName.length === 0"
class="btn button-default" class="btn button-default"

View file

@ -191,6 +191,7 @@ const updateProfile = ({ credentials, params }) => {
// homepage // homepage
// location // location
// token // token
// language
const register = ({ params, credentials }) => { const register = ({ params, credentials }) => {
const { nickname, ...rest } = params const { nickname, ...rest } = params
return fetch(MASTODON_REGISTRATION_URL, { return fetch(MASTODON_REGISTRATION_URL, {