summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-12-03 20:08:18 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-12-03 20:08:18 +0900
commit45bee7cc2f39aa6a3f7371ae02d2d0271d3291af (patch)
tree74a4e02813750d2fc9e1d81025742e2a76d0122a /src
parentRefactor (diff)
downloadsharkey-45bee7cc2f39aa6a3f7371ae02d2d0271d3291af.tar.gz
sharkey-45bee7cc2f39aa6a3f7371ae02d2d0271d3291af.tar.bz2
sharkey-45bee7cc2f39aa6a3f7371ae02d2d0271d3291af.zip
Resolve #327
Diffstat (limited to 'src')
-rw-r--r--src/client/app/common/views/components/profile-editor.vue13
-rw-r--r--src/models/user.ts1
-rw-r--r--src/server/api/endpoints/i/update.ts9
3 files changed, 23 insertions, 0 deletions
diff --git a/src/client/app/common/views/components/profile-editor.vue b/src/client/app/common/views/components/profile-editor.vue
index b402f046b1..33c53c7dc8 100644
--- a/src/client/app/common/views/components/profile-editor.vue
+++ b/src/client/app/common/views/components/profile-editor.vue
@@ -32,6 +32,12 @@
<span>{{ $t('description') }}</span>
</ui-textarea>
+ <ui-select v-model="lang">
+ <span slot="label">{{ $t('language') }}</span>
+ <span slot="icon"><fa icon="language"/></span>
+ <option v-for="lang in unique(Object.values(langmap).map(x => x.nativeName)).map(name => Object.keys(langmap).find(k => langmap[k].nativeName == name))" :value="lang" :key="lang">{{ langmap[lang].nativeName }}</option>
+ </ui-select>
+
<ui-input type="file" @change="onAvatarChange">
<span>{{ $t('avatar') }}</span>
<span slot="icon"><fa icon="image"/></span>
@@ -87,12 +93,16 @@ import Vue from 'vue';
import i18n from '../../../i18n';
import { apiUrl, host } from '../../../config';
import { toUnicode } from 'punycode';
+import langmap from 'langmap';
+import { unique } from '../../../../../prelude/array';
export default Vue.extend({
i18n: i18n('common/views/components/profile-editor.vue'),
data() {
return {
+ unique,
+ langmap,
host: toUnicode(host),
enableEmail: false,
email: null,
@@ -100,6 +110,7 @@ export default Vue.extend({
username: null,
location: null,
description: null,
+ lang: null,
birthday: null,
avatarId: null,
bannerId: null,
@@ -137,6 +148,7 @@ export default Vue.extend({
this.username = this.$store.state.i.username;
this.location = this.$store.state.i.profile.location;
this.description = this.$store.state.i.description;
+ this.lang = this.$store.state.i.lang;
this.birthday = this.$store.state.i.profile.birthday;
this.avatarId = this.$store.state.i.avatarId;
this.bannerId = this.$store.state.i.bannerId;
@@ -198,6 +210,7 @@ export default Vue.extend({
name: this.name || null,
location: this.location || null,
description: this.description || null,
+ lang: this.lang,
birthday: this.birthday || null,
avatarId: this.avatarId || undefined,
bannerId: this.bannerId || undefined,
diff --git a/src/models/user.ts b/src/models/user.ts
index 0e9875504b..18e45dbae9 100644
--- a/src/models/user.ts
+++ b/src/models/user.ts
@@ -44,6 +44,7 @@ type IUserBase = {
wallpaperUrl?: string;
data: any;
description: string;
+ lang?: string;
pinnedNoteIds: mongo.ObjectID[];
/**
diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts
index 4952b2f010..b87c3c47e7 100644
--- a/src/server/api/endpoints/i/update.ts
+++ b/src/server/api/endpoints/i/update.ts
@@ -6,6 +6,7 @@ import acceptAllFollowRequests from '../../../../services/following/requests/acc
import { publishToFollowers } from '../../../../services/i/update';
import define from '../../define';
import getDriveFileUrl from '../../../../misc/get-drive-file-url';
+const langmap = require('langmap');
export const meta = {
desc: {
@@ -32,6 +33,13 @@ export const meta = {
}
},
+ lang: {
+ validator: $.str.optional.nullable.or(Object.keys(langmap)),
+ desc: {
+ 'ja-JP': '言語'
+ }
+ },
+
location: {
validator: $.str.optional.nullable.pipe(isValidLocation),
desc: {
@@ -121,6 +129,7 @@ export default define(meta, (ps, user, app) => new Promise(async (res, rej) => {
if (ps.name !== undefined) updates.name = ps.name;
if (ps.description !== undefined) updates.description = ps.description;
+ if (ps.lang !== undefined) updates.lang = ps.lang;
if (ps.location !== undefined) updates['profile.location'] = ps.location;
if (ps.birthday !== undefined) updates['profile.birthday'] = ps.birthday;
if (ps.avatarId !== undefined) updates.avatarId = ps.avatarId;