From 9656c9b96919f17647adda80ba187a4f5b2299e1 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 18 Jan 2021 15:54:12 -0600 Subject: [PATCH 1/5] Support old user.deactivated and new user.is_active fields --- src/services/entity_normalizer/entity_normalizer.service.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 625f593e..a199ebd0 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -188,7 +188,9 @@ export const parseUser = (data) => { output.follow_request_count = data.pleroma.follow_request_count output.tags = data.pleroma.tags - output.deactivated = data.pleroma.deactivated + // deactivated was changed to is_active in Pleroma 2.3.0 + // backwards compatability kept for now + output.deactivated = data.pleroma.deactivated ? !data.pleroma.is_active : data.pleroma.deactivated output.notification_settings = data.pleroma.notification_settings output.unread_chat_count = data.pleroma.unread_chat_count From 36e56354e448b3c2106668f353dedcab5fde794d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 19 Jan 2021 10:01:55 -0600 Subject: [PATCH 2/5] More robust backwards compatibility --- .../entity_normalizer/entity_normalizer.service.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index a199ebd0..d6d84d9a 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -188,9 +188,12 @@ export const parseUser = (data) => { output.follow_request_count = data.pleroma.follow_request_count output.tags = data.pleroma.tags + // deactivated was changed to is_active in Pleroma 2.3.0 - // backwards compatability kept for now - output.deactivated = data.pleroma.deactivated ? !data.pleroma.is_active : data.pleroma.deactivated + // so check if is_active is present + output.deactivated = typeof data.pleroma.is_active !== undefined + ? !data.pleroma.is_active // new backend + : data.pleroma.deactivated // old backend output.notification_settings = data.pleroma.notification_settings output.unread_chat_count = data.pleroma.unread_chat_count From b76a68e622b2db6474acdd206bbdfb2e66fefd8f Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 20 Jan 2021 14:03:26 +0300 Subject: [PATCH 3/5] UserCard: Make user roles translateable I did not add a translation for my native language in this patch because I am not sure how weblate would react, but I did add it locally and it seems to work. --- src/components/user_card/user_card.vue | 3 +-- src/i18n/en.json | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index 16dd5249..773f764a 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -83,7 +83,7 @@ v-if="!!visibleRole" class="alert user-role" > - {{ visibleRole }} + {{ $t(`user_card.roles.${visibleRole}`) }} Date: Wed, 20 Jan 2021 16:04:49 +0000 Subject: [PATCH 4/5] Apply 1 suggestion(s) to 1 file(s) --- src/services/entity_normalizer/entity_normalizer.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index d6d84d9a..6ed663e1 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -191,7 +191,7 @@ export const parseUser = (data) => { // deactivated was changed to is_active in Pleroma 2.3.0 // so check if is_active is present - output.deactivated = typeof data.pleroma.is_active !== undefined + output.deactivated = typeof data.pleroma.is_active !== 'undefined' ? !data.pleroma.is_active // new backend : data.pleroma.deactivated // old backend From 11c7355749b6e0180841dd02604a06dd924dd217 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 20 Jan 2021 23:49:34 +0300 Subject: [PATCH 5/5] Use native language names in the language picker This seems more intuitive to me and is what I've seen in most other language pickers. --- CHANGELOG.md | 1 + .../interface_language_switcher.vue | 28 +++++++++---------- src/services/locale/locale.service.js | 12 ++++++++ 3 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 src/services/locale/locale.service.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 40c1d982..2d751bf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Don't filter own posts when they hit your wordfilter +- Language picker now uses native language names ## [2.2.2] - 2020-12-22 ### Added diff --git a/src/components/interface_language_switcher/interface_language_switcher.vue b/src/components/interface_language_switcher/interface_language_switcher.vue index 524ec5e9..dc3bd408 100644 --- a/src/components/interface_language_switcher/interface_language_switcher.vue +++ b/src/components/interface_language_switcher/interface_language_switcher.vue @@ -12,11 +12,11 @@ v-model="language" > import languagesObject from '../../i18n/messages' +import localeService from '../../services/locale/locale.service.js' import ISO6391 from 'iso-639-1' import _ from 'lodash' import { library } from '@fortawesome/fontawesome-svg-core' @@ -42,12 +43,8 @@ library.add( export default { computed: { - languageCodes () { - return languagesObject.languages - }, - - languageNames () { - return _.map(this.languageCodes, this.getLanguageName) + languages () { + return _.map(languagesObject.languages, (code) => ({ code: code, name: this.getLanguageName(code) })).sort((a, b) => a.name.localeCompare(b.name)) }, language: { @@ -61,12 +58,13 @@ export default { methods: { getLanguageName (code) { const specialLanguageNames = { - 'ja': 'Japanese (日本語)', - 'ja_easy': 'Japanese (やさしいにほんご)', - 'zh': 'Simplified Chinese (简体中文)', - 'zh_Hant': 'Traditional Chinese (繁體中文)' + 'ja_easy': 'やさしいにほんご', + 'zh': '简体中文', + 'zh_Hant': '繁體中文' } - return specialLanguageNames[code] || ISO6391.getName(code) + const languageName = specialLanguageNames[code] || ISO6391.getNativeName(code) + const browserLocale = localeService.internalToBrowserLocale(code) + return languageName.charAt(0).toLocaleUpperCase(browserLocale) + languageName.slice(1) } } } diff --git a/src/services/locale/locale.service.js b/src/services/locale/locale.service.js new file mode 100644 index 00000000..5be99d81 --- /dev/null +++ b/src/services/locale/locale.service.js @@ -0,0 +1,12 @@ +const specialLanguageCodes = { + 'ja_easy': 'ja', + 'zh_Hant': 'zh-HANT' +} + +const internalToBrowserLocale = code => specialLanguageCodes[code] || code + +const localeService = { + internalToBrowserLocale +} + +export default localeService