cinnyapp / cinny-desktop

Yet another matrix client for desktop
GNU Affero General Public License v3.0
415 stars 49 forks source link

Open room view failed when starting cinny on linux with env `LANG=C.UTF-8` #216

Closed LindsayZhou closed 1 year ago

LindsayZhou commented 1 year ago

Describe the bug

My LANG environment variable value is C.UTF-8 (It's the default value for alpine linux).

When I start cinny and enter room view, nothing is displayed on the page. There is a Uncaught RangeError: invalid language tag: "C" error log in the console.

Reproduction

For Desktop:

  1. Use the command env LANG=C.UTF-8 cinny to open cinny
  2. Log in to a account and enter room view.

For WebUI (FireFox):

  1. Open about:config, change the intl.accept_languages value to C
  2. Log in to a account and enter room view.

Expected behavior

No response

Platform and versions

1. OS: Alpine linux edge
2. Cinny version: v3.0.0
3. Matrix homeserver: envs.net
4. Downloaded from: Compiled by myself

Additional context

It's work for me to set the empty locates array.

diff --git a/src/app/organisms/room/MembersDrawer.tsx b/src/app/organisms/room/MembersDrawer.tsx
index 365dc62..76d5a13 100644
--- a/src/app/organisms/room/MembersDrawer.tsx
+++ b/src/app/organisms/room/MembersDrawer.tsx
@@ -265,13 +265,19 @@ export function MembersDrawer({ room }: MembersDrawerProps) {
     openProfileViewer(userId, room.roomId);
   };

+  let locales;
+  try {
+    locales = Intl.getCanonicalLocales(Array.from(navigator.languages));
+  } catch (e) {
+    locales = [];
+  }
   return (
     <Box className={css.MembersDrawer} direction="Column">
       <Header className={css.MembersDrawerHeader} variant="Background" size="600">
         <Box grow="Yes" alignItems="Center" gap="200">
           <Box grow="Yes" alignItems="Center" gap="200">
             <Text size="H5" truncate>
-              {`${millify(room.getJoinedMemberCount(), { precision: 1 })} Members`}
+              {`${millify(room.getJoinedMemberCount(), { precision: 1, locales: locales })} Members`}
             </Text>
           </Box>
           <Box shrink="No" alignItems="Center">
kfiven commented 1 year ago

Fixed in https://github.com/cinnyapp/cinny/pull/1504 and now live in v3.1.0