From 01b07f01e9340935faf51e5a3c8034cc90423989 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Sat, 25 Apr 2020 07:04:39 +0300 Subject: Add support for follow request notifications --- src/modules/config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/modules/config.js') diff --git a/src/modules/config.js b/src/modules/config.js index 7997521d..8f4638f5 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -34,7 +34,8 @@ export const defaultState = { likes: true, repeats: true, moves: true, - emojiReactions: false + emojiReactions: false, + followRequest: true }, webPushNotifications: false, muteWords: [], -- cgit v1.2.3-70-g09d2 From 5187b37aca4d6ca177c254f999e6acb637db5532 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 26 May 2020 22:50:37 +0300 Subject: moved multiChoiceProperties where it fits better --- .../settings_modal/tabs/helpers/shared_computed_object.js | 11 +++++------ src/modules/config.js | 10 ++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src/modules/config.js') diff --git a/src/components/settings_modal/tabs/helpers/shared_computed_object.js b/src/components/settings_modal/tabs/helpers/shared_computed_object.js index 61643e3b..b6a18e9c 100644 --- a/src/components/settings_modal/tabs/helpers/shared_computed_object.js +++ b/src/components/settings_modal/tabs/helpers/shared_computed_object.js @@ -1,10 +1,9 @@ import { filter, trim } from 'lodash' -import { instanceDefaultProperties, defaultState as configDefaultState } from 'src/modules/config.js' - -const multiChoiceProperties = [ - 'postContentType', - 'subjectLineBehavior' -] +import { + instanceDefaultProperties, + multiChoiceProperties, + defaultState as configDefaultState +} from 'src/modules/config.js' const SharedComputedObject = () => ({ user () { diff --git a/src/modules/config.js b/src/modules/config.js index 8f4638f5..b6b1b241 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -3,6 +3,16 @@ import { setPreset, applyTheme } from '../services/style_setter/style_setter.js' const browserLocale = (window.navigator.language || 'en').split('-')[0] +/* TODO this is a bit messy. + * We need to declare settings with their types and also deal with + * instance-default settings in some way, hopefully try to avoid copy-pasta + * in general. + */ +export const multiChoiceProperties = [ + 'postContentType', + 'subjectLineBehavior' +] + export const defaultState = { colors: {}, theme: undefined, -- cgit v1.2.3-70-g09d2 From 99eaec85478f384ddb0ea45a9d9c95c4dce646f5 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 8 Jun 2020 17:22:07 +0200 Subject: Messages: Load languages asynchronously. Reduces the size of the initial app bundle by about half. --- src/App.js | 3 +- .../interface_language_switcher.vue | 3 +- src/i18n/messages.js | 95 ++++++++++++++++------ src/main.js | 6 +- src/modules/config.js | 5 ++ 5 files changed, 80 insertions(+), 32 deletions(-) (limited to 'src/modules/config.js') diff --git a/src/App.js b/src/App.js index 6445335a..040138c9 100644 --- a/src/App.js +++ b/src/App.js @@ -47,7 +47,8 @@ export default { }), created () { // Load the locale from the storage - this.$i18n.locale = this.$store.getters.mergedConfig.interfaceLanguage + const val = this.$store.getters.mergedConfig.interfaceLanguage + this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val }) window.addEventListener('resize', this.updateMobileState) }, destroyed () { diff --git a/src/components/interface_language_switcher/interface_language_switcher.vue b/src/components/interface_language_switcher/interface_language_switcher.vue index f5ace0cc..dd6800a3 100644 --- a/src/components/interface_language_switcher/interface_language_switcher.vue +++ b/src/components/interface_language_switcher/interface_language_switcher.vue @@ -32,7 +32,7 @@ import _ from 'lodash' export default { computed: { languageCodes () { - return Object.keys(languagesObject) + return languagesObject.languages }, languageNames () { @@ -43,7 +43,6 @@ export default { get: function () { return this.$store.getters.mergedConfig.interfaceLanguage }, set: function (val) { this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val }) - this.$i18n.locale = val } } }, diff --git a/src/i18n/messages.js b/src/i18n/messages.js index c56ae205..a257486f 100644 --- a/src/i18n/messages.js +++ b/src/i18n/messages.js @@ -7,34 +7,75 @@ // sed -i -e "s/'//gm" -e 's/"/\\"/gm' -re 's/^( +)(.+?): ((.+?))?(,?)(\{?)$/\1"\2": "\4"/gm' -e 's/\"\{\"/{/g' -e 's/,"$/",/g' file.json // There's only problem that apostrophe character ' gets replaced by \\ so you have to fix it manually, sorry. +const loaders = { + ar: () => import('./ar.json'), + ca: () => import('./ca.json'), + cs: () => import('./cs.json'), + de: () => import('./de.json'), + eo: () => import('./eo.json'), + es: () => import('./es.json'), + et: () => import('./et.json'), + eu: () => import('./eu.json'), + fi: () => import('./fi.json'), + fr: () => import('./fr.json'), + ga: () => import('./ga.json'), + he: () => import('./he.json'), + hu: () => import('./hu.json'), + it: () => import('./it.json'), + ja: () => import('./ja_pedantic.json'), + ja_easy: () => import('./ja_easy.json'), + ko: () => import('./ko.json'), + nb: () => import('./nb.json'), + nl: () => import('./nl.json'), + oc: () => import('./oc.json'), + pl: () => import('./pl.json'), + pt: () => import('./pt.json'), + ro: () => import('./ro.json'), + ru: () => import('./ru.json'), + te: () => import('./te.json'), + zh: () => import('./zh.json') +} + const messages = { - ar: require('./ar.json'), - ca: require('./ca.json'), - cs: require('./cs.json'), - de: require('./de.json'), - en: require('./en.json'), - eo: require('./eo.json'), - es: require('./es.json'), - et: require('./et.json'), - eu: require('./eu.json'), - fi: require('./fi.json'), - fr: require('./fr.json'), - ga: require('./ga.json'), - he: require('./he.json'), - hu: require('./hu.json'), - it: require('./it.json'), - ja: require('./ja_pedantic.json'), - ja_easy: require('./ja_easy.json'), - ko: require('./ko.json'), - nb: require('./nb.json'), - nl: require('./nl.json'), - oc: require('./oc.json'), - pl: require('./pl.json'), - pt: require('./pt.json'), - ro: require('./ro.json'), - ru: require('./ru.json'), - te: require('./te.json'), - zh: require('./zh.json') + languages: [ + 'ar', + 'ca', + 'cs', + 'de', + 'en', + 'eo', + 'es', + 'et', + 'eu', + 'fi', + 'fr', + 'ga', + 'he', + 'hu', + 'it', + 'ja', + 'ja_easy', + 'ko', + 'nb', + 'nl', + 'oc', + 'pl', + 'pt', + 'ro', + 'ru', + 'te', + 'zh' + ], + default: { + en: require('./en.json') + }, + setLanguage: async (i18n, language) => { + if (loaders[language]) { + let messages = await loaders[language]() + i18n.setLocaleMessage(language, messages) + } + i18n.locale = language + } } export default messages diff --git a/src/main.js b/src/main.js index be4213fa..9a201e4f 100644 --- a/src/main.js +++ b/src/main.js @@ -46,11 +46,13 @@ Vue.use(VBodyScrollLock) const i18n = new VueI18n({ // By default, use the browser locale, we will update it if neccessary - locale: currentLocale, + locale: 'en', fallbackLocale: 'en', - messages + messages: messages.default }) +messages.setLanguage(i18n, currentLocale) + const persistedStateOptions = { paths: [ 'config', diff --git a/src/modules/config.js b/src/modules/config.js index b6b1b241..47b24d77 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -1,5 +1,6 @@ import { set, delete as del } from 'vue' import { setPreset, applyTheme } from '../services/style_setter/style_setter.js' +import messages from '../i18n/messages' const browserLocale = (window.navigator.language || 'en').split('-')[0] @@ -115,6 +116,10 @@ const config = { case 'customTheme': case 'customThemeSource': applyTheme(value) + break + case 'interfaceLanguage': + messages.setLanguage(this.getters.i18n, value) + break } } } -- cgit v1.2.3-70-g09d2