From b7e93739656d225ed0a8854f357746b5291b6857 Mon Sep 17 00:00:00 2001
From: Tusooa Zhu <tusooa@kazv.moe>
Date: Mon, 25 Jul 2022 15:38:05 -0400
Subject: Add support for multiple interface languages

---
 .../interface_language_switcher.vue                | 75 +++++++++++++++++-----
 1 file changed, 59 insertions(+), 16 deletions(-)

(limited to 'src/components/interface_language_switcher/interface_language_switcher.vue')

diff --git a/src/components/interface_language_switcher/interface_language_switcher.vue b/src/components/interface_language_switcher/interface_language_switcher.vue
index 6997f149..e18a2a12 100644
--- a/src/components/interface_language_switcher/interface_language_switcher.vue
+++ b/src/components/interface_language_switcher/interface_language_switcher.vue
@@ -1,21 +1,39 @@
 <template>
-  <div>
-    <label for="interface-language-switcher">
+  <div class="interface-language-switcher">
+    <label>
       {{ promptText }}
     </label>
-    {{ ' ' }}
-    <Select
-      id="interface-language-switcher"
-      v-model="controlledLanguage"
-    >
-      <option
-        v-for="lang in languages"
-        :key="lang.code"
-        :value="lang.code"
+    <ol>
+      <li
+        v-for="index of controlledLanguage.keys()"
+        :key="index"
       >
-        {{ lang.name }}
-      </option>
-    </Select>
+        <Select
+          class="language-select"
+          :model-value="controlledLanguage[index]"
+          @update:modelValue="val => setLanguageAt(index, val)"
+        >
+          <option
+            v-for="lang in languages"
+            :key="lang.code"
+            :value="lang.code"
+          >
+            {{ lang.name }}
+          </option>
+        </Select>
+        <button
+          v-if="controlledLanguage.length > 1"
+          class="button-default btn"
+          @click="() => removeLanguageAt(index)"
+        >{{ $t('settings.remove_language') }}</button>
+      </li>
+      <li>
+        <button
+          class="button-default btn"
+          @click="addLanguage"
+        >{{ $t('settings.add_language') }}</button>
+      </li>
+    </ol>
   </div>
 </template>
 
@@ -34,7 +52,7 @@ export default {
       required: true
     },
     language: {
-      type: String,
+      type: [Array, String],
       required: true
     },
     setLanguage: {
@@ -48,7 +66,9 @@ export default {
     },
 
     controlledLanguage: {
-      get: function () { return this.language },
+      get: function () {
+        return Array.isArray(this.language) ? this.language : [this.language]
+      },
       set: function (val) {
         this.setLanguage(val)
       }
@@ -58,7 +78,30 @@ export default {
   methods: {
     getLanguageName (code) {
       return localeService.getLanguageName(code)
+    },
+    addLanguage () {
+      this.controlledLanguage = [...this.controlledLanguage, '']
+    },
+    setLanguageAt (index, val) {
+      const lang = [...this.controlledLanguage]
+      lang[index] = val
+      this.controlledLanguage = lang
+    },
+    removeLanguageAt (index) {
+      const lang = [...this.controlledLanguage]
+      lang.splice(index, 1)
+      this.controlledLanguage = lang
     }
   }
 }
 </script>
+
+<style lang="scss">
+@import '../../_variables.scss';
+
+.interface-language-switcher {
+  .language-select {
+    margin-right: 1em;
+  }
+}
+</style>
-- 
cgit v1.2.3-70-g09d2


From 7e2ae2ba9565a58944fe8915f054f8eef812ee54 Mon Sep 17 00:00:00 2001
From: tusooa <tusooa@kazv.moe>
Date: Fri, 23 Dec 2022 23:02:21 -0500
Subject: Optimize UI

---
 .../interface_language_switcher.vue                | 37 ++++++++++++----------
 src/i18n/en.json                                   |  4 ++-
 src/modules/instance.js                            |  9 ++++--
 3 files changed, 31 insertions(+), 19 deletions(-)

(limited to 'src/components/interface_language_switcher/interface_language_switcher.vue')

diff --git a/src/components/interface_language_switcher/interface_language_switcher.vue b/src/components/interface_language_switcher/interface_language_switcher.vue
index e18a2a12..c9e7506b 100644
--- a/src/components/interface_language_switcher/interface_language_switcher.vue
+++ b/src/components/interface_language_switcher/interface_language_switcher.vue
@@ -3,29 +3,34 @@
     <label>
       {{ promptText }}
     </label>
-    <ol>
+    <ul class="setting-list">
       <li
         v-for="index of controlledLanguage.keys()"
         :key="index"
       >
-        <Select
-          class="language-select"
-          :model-value="controlledLanguage[index]"
-          @update:modelValue="val => setLanguageAt(index, val)"
-        >
-          <option
-            v-for="lang in languages"
-            :key="lang.code"
-            :value="lang.code"
+        <label>
+          {{ index === 0 ? $t('settings.primary_language') : $tc('settings.fallback_language', index, { index }) }}
+          <Select
+            class="language-select"
+            :model-value="controlledLanguage[index]"
+            @update:modelValue="val => setLanguageAt(index, val)"
           >
-            {{ lang.name }}
-          </option>
-        </Select>
+            <option
+              v-for="lang in languages"
+              :key="lang.code"
+              :value="lang.code"
+            >
+              {{ lang.name }}
+            </option>
+          </Select>
+        </label>
         <button
-          v-if="controlledLanguage.length > 1"
+          v-if="controlledLanguage.length > 1 && index !== 0"
           class="button-default btn"
           @click="() => removeLanguageAt(index)"
-        >{{ $t('settings.remove_language') }}</button>
+        >
+          {{ $t('settings.remove_language') }}
+        </button>
       </li>
       <li>
         <button
@@ -33,7 +38,7 @@
           @click="addLanguage"
         >{{ $t('settings.add_language') }}</button>
       </li>
-    </ol>
+    </ul>
   </div>
 </template>
 
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 9abfae67..7df42d92 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -334,8 +334,10 @@
     "select_all": "Select all"
   },
   "settings": {
-    "add_language": "Add another language",
+    "add_language": "Add fallback language",
     "remove_language": "Remove",
+    "primary_language": "Primary language:",
+    "fallback_language": "Fallback language {index}:",
     "app_name": "App name",
     "expert_mode": "Show advanced",
     "save": "Save changes",
diff --git a/src/modules/instance.js b/src/modules/instance.js
index 3b15e62e..bff26151 100644
--- a/src/modules/instance.js
+++ b/src/modules/instance.js
@@ -273,8 +273,13 @@ const instance = {
         langList
           .map(async lang => {
             if (!state.unicodeEmojiAnnotations[lang]) {
-              const annotations = await loadAnnotations(lang)
-              commit('setUnicodeEmojiAnnotations', { lang, annotations })
+              try {
+                const annotations = await loadAnnotations(lang)
+                commit('setUnicodeEmojiAnnotations', { lang, annotations })
+              } catch (e) {
+                console.warn(`Error loading unicode emoji annotations for ${lang}: `, e)
+                // ignore
+              }
             }
           }))
     },
-- 
cgit v1.2.3-70-g09d2


From 817432bd62c781d25ad407eeec89909e5a9b4d61 Mon Sep 17 00:00:00 2001
From: tusooa <tusooa@kazv.moe>
Date: Wed, 25 Jan 2023 19:01:29 -0500
Subject: Fix stylelint

---
 .../interface_language_switcher/interface_language_switcher.vue         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/components/interface_language_switcher/interface_language_switcher.vue')

diff --git a/src/components/interface_language_switcher/interface_language_switcher.vue b/src/components/interface_language_switcher/interface_language_switcher.vue
index c9e7506b..a57e8761 100644
--- a/src/components/interface_language_switcher/interface_language_switcher.vue
+++ b/src/components/interface_language_switcher/interface_language_switcher.vue
@@ -102,7 +102,7 @@ export default {
 </script>
 
 <style lang="scss">
-@import '../../_variables.scss';
+@import "../../variables";
 
 .interface-language-switcher {
   .language-select {
-- 
cgit v1.2.3-70-g09d2


From 55ea6df40b7e2cfe2b1b5bde33204d4c03e54a12 Mon Sep 17 00:00:00 2001
From: Henry Jameson <me@hjkos.com>
Date: Sun, 12 Mar 2023 17:28:14 +0200
Subject: lint

---
 .../interface_language_switcher.vue                |  4 ++-
 .../settings_modal/tabs/filtering_tab.vue          | 12 ++++----
 src/components/settings_modal/tabs/general_tab.vue | 11 +++----
 .../settings_modal/tabs/notifications_tab.vue      |  8 +++--
 src/components/settings_modal/tabs/profile_tab.vue | 34 +++++++++++++++++-----
 5 files changed, 47 insertions(+), 22 deletions(-)

(limited to 'src/components/interface_language_switcher/interface_language_switcher.vue')

diff --git a/src/components/interface_language_switcher/interface_language_switcher.vue b/src/components/interface_language_switcher/interface_language_switcher.vue
index a57e8761..364791a1 100644
--- a/src/components/interface_language_switcher/interface_language_switcher.vue
+++ b/src/components/interface_language_switcher/interface_language_switcher.vue
@@ -36,7 +36,9 @@
         <button
           class="button-default btn"
           @click="addLanguage"
-        >{{ $t('settings.add_language') }}</button>
+        >
+          {{ $t('settings.add_language') }}
+        </button>
       </li>
     </ul>
   </div>
diff --git a/src/components/settings_modal/tabs/filtering_tab.vue b/src/components/settings_modal/tabs/filtering_tab.vue
index 46c6bc5c..41d1b54f 100644
--- a/src/components/settings_modal/tabs/filtering_tab.vue
+++ b/src/components/settings_modal/tabs/filtering_tab.vue
@@ -10,8 +10,8 @@
           <ul class="setting-list suboptions">
             <li>
               <BooleanSetting
-                parentPath="hideFilteredStatuses"
-                :parentInvert="true"
+                parent-path="hideFilteredStatuses"
+                :parent-invert="true"
                 path="hideWordFilteredPosts"
               >
                 {{ $t('settings.hide_wordfiltered_statuses') }}
@@ -20,8 +20,8 @@
             <li>
               <BooleanSetting
                 v-if="user"
-                parentPath="hideFilteredStatuses"
-                :parentInvert="true"
+                parent-path="hideFilteredStatuses"
+                :parent-invert="true"
                 path="hideMutedThreads"
               >
                 {{ $t('settings.hide_muted_threads') }}
@@ -30,8 +30,8 @@
             <li>
               <BooleanSetting
                 v-if="user"
-                parentPath="hideFilteredStatuses"
-                :parentInvert="true"
+                parent-path="hideFilteredStatuses"
+                :parent-invert="true"
                 path="hideMutedPosts"
               >
                 {{ $t('settings.hide_muted_posts') }}
diff --git a/src/components/settings_modal/tabs/general_tab.vue b/src/components/settings_modal/tabs/general_tab.vue
index eb2cef9b..641d850a 100644
--- a/src/components/settings_modal/tabs/general_tab.vue
+++ b/src/components/settings_modal/tabs/general_tab.vue
@@ -33,7 +33,7 @@
             <li>
               <BooleanSetting
                 path="pauseOnUnfocused"
-                parentPath="streaming"
+                parent-path="streaming"
               >
                 {{ $t('settings.pause_on_unfocused') }}
               </BooleanSetting>
@@ -262,7 +262,8 @@
         <li>
           <BooleanSetting
             v-if="user"
-            source="profile" path="stripRichContent"
+            source="profile"
+            path="stripRichContent"
             expert="1"
           >
             {{ $t('settings.no_rich_text_description') }}
@@ -287,7 +288,7 @@
             <BooleanSetting
               path="preloadImage"
               expert="1"
-              parentPath="hideNsfw"
+              parent-path="hideNsfw"
             >
               {{ $t('settings.preload_images') }}
             </BooleanSetting>
@@ -296,7 +297,7 @@
             <BooleanSetting
               path="useOneClickNsfw"
               expert="1"
-              parentPath="hideNsfw"
+              parent-path="hideNsfw"
             >
               {{ $t('settings.use_one_click_nsfw') }}
             </BooleanSetting>
@@ -314,7 +315,7 @@
               <BooleanSetting
                 path="loopVideoSilentOnly"
                 expert="1"
-                parentPath="loopVideo"
+                parent-path="loopVideo"
                 :disabled="!loopSilentAvailable"
               >
                 {{ $t('settings.loop_video_silent_only') }}
diff --git a/src/components/settings_modal/tabs/notifications_tab.vue b/src/components/settings_modal/tabs/notifications_tab.vue
index ea095372..fcb92135 100644
--- a/src/components/settings_modal/tabs/notifications_tab.vue
+++ b/src/components/settings_modal/tabs/notifications_tab.vue
@@ -4,7 +4,10 @@
       <h2>{{ $t('settings.notification_setting_filters') }}</h2>
       <ul class="setting-list">
         <li>
-          <BooleanSetting source="profile" path="blockNotificationsFromStrangers">
+          <BooleanSetting
+            source="profile"
+            path="blockNotificationsFromStrangers"
+          >
             {{ $t('settings.notification_setting_block_from_strangers') }}
           </BooleanSetting>
         </li>
@@ -67,7 +70,8 @@
         </li>
         <li>
           <BooleanSetting
-            source="profile" path="webPushHideContents"
+            source="profile"
+            path="webPushHideContents"
             expert="1"
           >
             {{ $t('settings.notification_setting_hide_notification_contents') }}
diff --git a/src/components/settings_modal/tabs/profile_tab.vue b/src/components/settings_modal/tabs/profile_tab.vue
index 74652990..1cc850cb 100644
--- a/src/components/settings_modal/tabs/profile_tab.vue
+++ b/src/components/settings_modal/tabs/profile_tab.vue
@@ -254,27 +254,42 @@
       <h2>{{ $t('settings.account_privacy') }}</h2>
       <ul class="setting-list">
         <li>
-          <BooleanSetting source="profile" path="locked">
+          <BooleanSetting
+            source="profile"
+            path="locked"
+          >
             {{ $t('settings.lock_account_description') }}
           </BooleanSetting>
         </li>
         <li>
-          <BooleanSetting source="profile" path="discoverable">
+          <BooleanSetting
+            source="profile"
+            path="discoverable"
+          >
             {{ $t('settings.discoverable') }}
           </BooleanSetting>
         </li>
         <li>
-          <BooleanSetting source="profile" path="allowFollowingMove">
+          <BooleanSetting
+            source="profile"
+            path="allowFollowingMove"
+          >
             {{ $t('settings.allow_following_move') }}
           </BooleanSetting>
         </li>
         <li>
-          <BooleanSetting source="profile" path="hideFavorites">
+          <BooleanSetting
+            source="profile"
+            path="hideFavorites"
+          >
             {{ $t('settings.hide_favorites_description') }}
           </BooleanSetting>
         </li>
         <li>
-          <BooleanSetting source="profile" path="hideFollowers">
+          <BooleanSetting
+            source="profile"
+            path="hideFollowers"
+          >
             {{ $t('settings.hide_followers_description') }}
           </BooleanSetting>
           <ul class="setting-list suboptions">
@@ -282,7 +297,7 @@
               <BooleanSetting
                 source="profile"
                 path="hideFollowersCount"
-                parentPath="hideFollowers"
+                parent-path="hideFollowers"
               >
                 {{ $t('settings.hide_followers_count_description') }}
               </BooleanSetting>
@@ -290,7 +305,10 @@
           </ul>
         </li>
         <li>
-          <BooleanSetting source="profile" path="hideFollows">
+          <BooleanSetting
+            source="profile"
+            path="hideFollows"
+          >
             {{ $t('settings.hide_follows_description') }}
           </BooleanSetting>
           <ul class="setting-list suboptions">
@@ -298,7 +316,7 @@
               <BooleanSetting
                 source="profile"
                 path="hideFollowsCount"
-                parentPath="hideFollows"
+                parent-path="hideFollows"
               >
                 {{ $t('settings.hide_follows_count_description') }}
               </BooleanSetting>
-- 
cgit v1.2.3-70-g09d2

