From b76a68e622b2db6474acdd206bbdfb2e66fefd8f Mon Sep 17 00:00:00 2001
From: rinpatch <rinpatch@sdf.org>
Date: Wed, 20 Jan 2021 14:03:26 +0300
Subject: 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 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

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

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}`) }}
                 </span>
                 <span
                   v-if="user.bot"
@@ -507,7 +507,6 @@
 
     .user-role {
       flex: none;
-      text-transform: capitalize;
       color: $fallback--text;
       color: var(--alertNeutralText, $fallback--text);
       background-color: $fallback--fg;
-- 
cgit v1.2.3-70-g09d2


From da807a12fb2b1862205b2c1163326806cca6bd26 Mon Sep 17 00:00:00 2001
From: rinpatch <rin@patch.cx>
Date: Fri, 12 Feb 2021 12:01:16 +0300
Subject: Make bot label localizable

---
 src/components/user_card/user_card.vue | 2 +-
 src/i18n/en.json                       | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

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

diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue
index 773f764a..c6c4dfee 100644
--- a/src/components/user_card/user_card.vue
+++ b/src/components/user_card/user_card.vue
@@ -89,7 +89,7 @@
                   v-if="user.bot"
                   class="alert user-role"
                 >
-                  bot
+                  {{ $t('user_card.bot') }}
                 </span>
               </template>
               <span v-if="user.locked">
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 1025a8e1..3946f3cd 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -716,6 +716,7 @@
     "mute_progress": "Muting…",
     "hide_repeats": "Hide repeats",
     "show_repeats": "Show repeats",
+    "bot": "Bot",
     "admin_menu": {
       "moderation": "Moderation",
       "grant_admin": "Grant Admin",
-- 
cgit v1.2.3-70-g09d2


From 6acf812101f79b450dc4efd2da051c634dd18621 Mon Sep 17 00:00:00 2001
From: rinpatch <rin@patch.cx>
Date: Sat, 13 Feb 2021 16:34:43 +0300
Subject: User card: use general.role instead of card-specific roles

Also removes admin_menu.roles from some localizations since it is not
used anywhere
---
 src/components/user_card/user_card.vue |  2 +-
 src/i18n/en.json                       |  4 ----
 src/i18n/it.json                       | 12 ++++++------
 src/i18n/pt.json                       | 13 +++++++------
 src/i18n/ru.json                       | 12 ++++++------
 src/i18n/uk.json                       | 12 ++++++------
 6 files changed, 26 insertions(+), 29 deletions(-)

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

diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue
index c6c4dfee..572943b5 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"
                 >
-                  {{ $t(`user_card.roles.${visibleRole}`) }}
+                  {{ $t(`general.role.${visibleRole}`) }}
                 </span>
                 <span
                   v-if="user.bot"
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 46614ef1..4cc2af0e 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -737,10 +737,6 @@
       "quarantine": "Disallow user posts from federating",
       "delete_user": "Delete user",
       "delete_user_confirmation": "Are you absolutely sure? This action cannot be undone."
-    },
-    "roles": {
-      "admin": "Admin",
-      "moderator": "Moderator"
     }
   },
   "user_profile": {
diff --git a/src/i18n/it.json b/src/i18n/it.json
index b7d21e7e..ece1f33a 100644
--- a/src/i18n/it.json
+++ b/src/i18n/it.json
@@ -17,7 +17,11 @@
     "close": "Chiudi",
     "retry": "Riprova",
     "error_retry": "Per favore, riprova",
-    "loading": "Carico…"
+    "loading": "Carico…",
+    "role": {
+      "moderator": "Moderatore",
+      "admin": "Amministratore"
+    }
   },
   "nav": {
     "mentions": "Menzioni",
@@ -487,11 +491,7 @@
     "follow_progress": "Richiedo…",
     "follow_sent": "Richiesta inviata!",
     "favorites": "Preferiti",
-    "message": "Contatta",
-    "roles": {
-      "moderator": "Moderatore",
-      "admin": "Amministratore"
-    }
+    "message": "Contatta"
   },
   "chat": {
     "title": "Chat"
diff --git a/src/i18n/pt.json b/src/i18n/pt.json
index b79985e8..841516c0 100644
--- a/src/i18n/pt.json
+++ b/src/i18n/pt.json
@@ -35,7 +35,12 @@
     "retry": "Tenta novamente",
     "error_retry": "Por favor, tenta novamente",
     "loading": "A carregar…",
-    "dismiss": "Ignorar"
+    "dismiss": "Ignorar",
+    "role":
+    {
+      "moderator": "Moderador",
+      "admin": "Admin"
+    }
   },
   "image_cropper": {
     "crop_picture": "Cortar imagem",
@@ -615,11 +620,7 @@
     "report": "Denunciar",
     "message": "Mensagem",
     "mention": "Mencionar",
-    "hidden": "Ocultar",
-    "roles": {
-      "moderator": "Moderador",
-      "admin": "Admin"
-    }
+    "hidden": "Ocultar"
   },
   "user_profile": {
     "timeline_title": "Cronologia do Utilizador",
diff --git a/src/i18n/ru.json b/src/i18n/ru.json
index 30a65741..15ebda95 100644
--- a/src/i18n/ru.json
+++ b/src/i18n/ru.json
@@ -24,7 +24,11 @@
     "retry": "Попробуйте еще раз",
     "error_retry": "Пожалуйста попробуйте еще раз",
     "close": "Закрыть",
-    "loading": "Загрузка…"
+    "loading": "Загрузка…",
+    "role": {
+      "moderator": "Модератор",
+      "admin": "Администратор"
+    }
   },
   "login": {
     "login": "Войти",
@@ -541,11 +545,7 @@
     "mention": "Упомянуть",
     "show_repeats": "Показывать повторы",
     "hide_repeats": "Скрыть повторы",
-    "report": "Пожаловаться",
-    "roles": {
-      "moderator": "Модератор",
-      "admin": "Администратор"
-    }
+    "report": "Пожаловаться"
   },
   "user_profile": {
     "timeline_title": "Лента пользователя"
diff --git a/src/i18n/uk.json b/src/i18n/uk.json
index 040d6f4f..98f65a0e 100644
--- a/src/i18n/uk.json
+++ b/src/i18n/uk.json
@@ -17,7 +17,11 @@
     "more": "Більше",
     "submit": "Відправити",
     "apply": "Застосувати",
-    "peek": "Глянути"
+    "peek": "Глянути",
+    "role": {
+      "moderator": "Модератор",
+      "admin": "Адміністратор"
+    }
   },
   "finder": {
     "error_fetching_user": "Користувача не знайдено",
@@ -760,11 +764,7 @@
     "unblock": "Розблокувати",
     "remote_follow": "Підписатись",
     "muted": "Заглушений",
-    "mute": "Заглушити",
-    "roles": {
-      "moderator": "Модератор",
-      "admin": "Адміністратор"
-    }
+    "mute": "Заглушити"
   },
   "status": {
     "copy_link": "Скопіювати посилання на допис",
-- 
cgit v1.2.3-70-g09d2


From 09fe160e8b9fad7a8c70e44ae894d67211b993e1 Mon Sep 17 00:00:00 2001
From: Shpuld Shpuldson <shp@cock.li>
Date: Fri, 26 Feb 2021 16:23:11 +0200
Subject: separate screen_name and screen_name_ui with decoded punycode

---
 CHANGELOG.md                                                   |  1 +
 src/components/basic_user_card/basic_user_card.vue             |  2 +-
 src/components/chat/chat.js                                    |  2 +-
 src/components/chat_title/chat_title.js                        |  2 +-
 src/components/emoji_input/suggestor.js                        |  4 ++--
 src/components/notification/notification.vue                   | 10 +++++-----
 src/components/status/status.js                                |  4 ++--
 src/components/status/status.vue                               |  6 +++---
 src/components/user_avatar/user_avatar.vue                     |  4 ++--
 src/components/user_card/user_card.vue                         |  4 ++--
 src/components/user_list_popover/user_list_popover.vue         |  2 +-
 src/components/user_reporting_modal/user_reporting_modal.vue   |  2 +-
 src/services/entity_normalizer/entity_normalizer.service.js    |  5 +++--
 .../specs/services/entity_normalizer/entity_normalizer.spec.js |  2 +-
 14 files changed, 26 insertions(+), 24 deletions(-)

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

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2685fd32..20d96f98 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Fixed missing highlighted border in expanded conversations again
 - Fixed some UI jumpiness when opening images particularly in chat view
 - Fixed chat unread badge looking weird
+- Fixed punycode names not working properly
 
 ### Changed
 - Display 'people voted' instead of 'votes' for multi-choice polls
diff --git a/src/components/basic_user_card/basic_user_card.vue b/src/components/basic_user_card/basic_user_card.vue
index 9e410610..c53f6a9c 100644
--- a/src/components/basic_user_card/basic_user_card.vue
+++ b/src/components/basic_user_card/basic_user_card.vue
@@ -42,7 +42,7 @@
           class="basic-user-card-screen-name"
           :to="userProfileLink(user)"
         >
-          @{{ user.screen_name }}
+          @{{ user.screen_name_ui }}
         </router-link>
       </div>
       <slot />
diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js
index 2780be75..b54f5fb2 100644
--- a/src/components/chat/chat.js
+++ b/src/components/chat/chat.js
@@ -73,7 +73,7 @@ const Chat = {
     },
     formPlaceholder () {
       if (this.recipient) {
-        return this.$t('chats.message_user', { nickname: this.recipient.screen_name })
+        return this.$t('chats.message_user', { nickname: this.recipient.screen_name_ui })
       } else {
         return ''
       }
diff --git a/src/components/chat_title/chat_title.js b/src/components/chat_title/chat_title.js
index e424bb1f..edfbe7a4 100644
--- a/src/components/chat_title/chat_title.js
+++ b/src/components/chat_title/chat_title.js
@@ -12,7 +12,7 @@ export default Vue.component('chat-title', {
   ],
   computed: {
     title () {
-      return this.user ? this.user.screen_name : ''
+      return this.user ? this.user.screen_name_ui : ''
     },
     htmlTitle () {
       return this.user ? this.user.name_html : ''
diff --git a/src/components/emoji_input/suggestor.js b/src/components/emoji_input/suggestor.js
index 14a2b41e..e8efbd1e 100644
--- a/src/components/emoji_input/suggestor.js
+++ b/src/components/emoji_input/suggestor.js
@@ -116,8 +116,8 @@ export const suggestUsers = ({ dispatch, state }) => {
 
       return diff + nameAlphabetically + screenNameAlphabetically
       /* eslint-disable camelcase */
-    }).map(({ screen_name, name, profile_image_url_original }) => ({
-      displayText: screen_name,
+    }).map(({ screen_name, screen_name_ui, name, profile_image_url_original }) => ({
+      displayText: screen_name_ui,
       detailText: name,
       imageUrl: profile_image_url_original,
       replacement: '@' + screen_name + ' '
diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue
index f56aa977..0081dee4 100644
--- a/src/components/notification/notification.vue
+++ b/src/components/notification/notification.vue
@@ -11,7 +11,7 @@
     >
       <small>
         <router-link :to="userProfileLink">
-          {{ notification.from_profile.screen_name }}
+          {{ notification.from_profile.screen_name_ui }}
         </router-link>
       </small>
       <button
@@ -54,14 +54,14 @@
             <bdi
               v-if="!!notification.from_profile.name_html"
               class="username"
-              :title="'@'+notification.from_profile.screen_name"
+              :title="'@'+notification.from_profile.screen_name_ui"
               v-html="notification.from_profile.name_html"
             />
             <!-- eslint-enable vue/no-v-html -->
             <span
               v-else
               class="username"
-              :title="'@'+notification.from_profile.screen_name"
+              :title="'@'+notification.from_profile.screen_name_ui"
             >{{ notification.from_profile.name }}</span>
             <span v-if="notification.type === 'like'">
               <FAIcon
@@ -152,7 +152,7 @@
             :to="userProfileLink"
             class="follow-name"
           >
-            @{{ notification.from_profile.screen_name }}
+            @{{ notification.from_profile.screen_name_ui }}
           </router-link>
           <div
             v-if="notification.type === 'follow_request'"
@@ -177,7 +177,7 @@
           class="move-text"
         >
           <router-link :to="targetUserProfileLink">
-            @{{ notification.target.screen_name }}
+            @{{ notification.target.screen_name_ui }}
           </router-link>
         </div>
         <template v-else>
diff --git a/src/components/status/status.js b/src/components/status/status.js
index 2bf93a9e..470c01f1 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -136,7 +136,7 @@ const Status = {
       }
     },
     retweet () { return !!this.statusoid.retweeted_status },
-    retweeter () { return this.statusoid.user.name || this.statusoid.user.screen_name },
+    retweeter () { return this.statusoid.user.name || this.statusoid.user.screen_name_ui },
     retweeterHtml () { return this.statusoid.user.name_html },
     retweeterProfileLink () { return this.generateUserProfileLink(this.statusoid.user.id, this.statusoid.user.screen_name) },
     status () {
@@ -216,7 +216,7 @@ const Status = {
         return this.status.in_reply_to_screen_name
       } else {
         const user = this.$store.getters.findUser(this.status.in_reply_to_user_id)
-        return user && user.screen_name
+        return user && user.screen_name_ui
       }
     },
     replySubject () {
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index 6ee8117f..00e962f3 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -26,7 +26,7 @@
             icon="retweet"
           />
           <router-link :to="userProfileLink">
-            {{ status.user.screen_name }}
+            {{ status.user.screen_name_ui }}
           </router-link>
         </small>
         <small
@@ -156,10 +156,10 @@
                 </h4>
                 <router-link
                   class="account-name"
-                  :title="status.user.screen_name"
+                  :title="status.user.screen_name_ui"
                   :to="userProfileLink"
                 >
-                  {{ status.user.screen_name }}
+                  {{ status.user.screen_name_ui }}
                 </router-link>
                 <img
                   v-if="!!(status.user && status.user.favicon)"
diff --git a/src/components/user_avatar/user_avatar.vue b/src/components/user_avatar/user_avatar.vue
index 0f7c584b..4040e263 100644
--- a/src/components/user_avatar/user_avatar.vue
+++ b/src/components/user_avatar/user_avatar.vue
@@ -2,8 +2,8 @@
   <StillImage
     v-if="user"
     class="Avatar"
-    :alt="user.screen_name"
-    :title="user.screen_name"
+    :alt="user.screen_name_ui"
+    :title="user.screen_name_ui"
     :src="imgSrc(user.profile_image_url_original)"
     :class="{ 'avatar-compact': compact, 'better-shadow': betterShadow }"
     :image-load-error="imageLoadError"
diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue
index 572943b5..60776ebb 100644
--- a/src/components/user_card/user_card.vue
+++ b/src/components/user_card/user_card.vue
@@ -73,10 +73,10 @@
             <div class="bottom-line">
               <router-link
                 class="user-screen-name"
-                :title="user.screen_name"
+                :title="user.screen_name_ui"
                 :to="userProfileLink(user)"
               >
-                @{{ user.screen_name }}
+                @{{ user.screen_name_ui }}
               </router-link>
               <template v-if="!hideBio">
                 <span
diff --git a/src/components/user_list_popover/user_list_popover.vue b/src/components/user_list_popover/user_list_popover.vue
index 95673733..d0aa315e 100644
--- a/src/components/user_list_popover/user_list_popover.vue
+++ b/src/components/user_list_popover/user_list_popover.vue
@@ -26,7 +26,7 @@
             <!-- eslint-disable vue/no-v-html -->
             <span v-html="user.name_html" />
             <!-- eslint-enable vue/no-v-html -->
-            <span class="user-list-screen-name">{{ user.screen_name }}</span>
+            <span class="user-list-screen-name">{{ user.screen_name_ui }}</span>
           </div>
         </div>
       </div>
diff --git a/src/components/user_reporting_modal/user_reporting_modal.vue b/src/components/user_reporting_modal/user_reporting_modal.vue
index fb43094f..a71c02c1 100644
--- a/src/components/user_reporting_modal/user_reporting_modal.vue
+++ b/src/components/user_reporting_modal/user_reporting_modal.vue
@@ -6,7 +6,7 @@
     <div class="user-reporting-panel panel">
       <div class="panel-heading">
         <div class="title">
-          {{ $t('user_reporting.title', [user.screen_name]) }}
+          {{ $t('user_reporting.title', [user.screen_name_ui]) }}
         </div>
       </div>
       <div class="panel-body">
diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js
index 6ed663e1..9b2b30e6 100644
--- a/src/services/entity_normalizer/entity_normalizer.service.js
+++ b/src/services/entity_normalizer/entity_normalizer.service.js
@@ -203,7 +203,8 @@ export const parseUser = (data) => {
   output.rights = output.rights || {}
   output.notification_settings = output.notification_settings || {}
 
-  // Convert punycode to unicode
+  // Convert punycode to unicode for UI
+  output.screen_name_ui = output.screen_name
   if (output.screen_name.includes('@')) {
     const parts = output.screen_name.split('@')
     let unicodeDomain = punycode.toUnicode(parts[1])
@@ -211,7 +212,7 @@ export const parseUser = (data) => {
       // Add some identifier so users can potentially spot spoofing attempts:
       // lain.com and xn--lin-6cd.com would appear identical otherwise.
       unicodeDomain = '🌏' + unicodeDomain
-      output.screen_name = [parts[0], unicodeDomain].join('@')
+      output.screen_name_ui = [parts[0], unicodeDomain].join('@')
     }
   }
 
diff --git a/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js b/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js
index a3f49b2c..759539e0 100644
--- a/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js
+++ b/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js
@@ -315,7 +315,7 @@ describe('API Entities normalizer', () => {
     it('converts IDN to unicode and marks it as internatonal', () => {
       const user = makeMockUserMasto({ acct: 'lain@xn--lin-6cd.com' })
 
-      expect(parseUser(user)).to.have.property('screen_name').that.equal('lain@🌏lаin.com')
+      expect(parseUser(user)).to.have.property('screen_name_ui').that.equal('lain@🌏lаin.com')
     })
   })
 
-- 
cgit v1.2.3-70-g09d2

