From 72955ffcbf9c72fb352a87f11d76fa9186ad8cc2 Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 17:19:50 +0100 Subject: [PATCH 01/15] feat: language specific pronouns setting in experimental tab --- .../settings/experimental/Experimental.tsx | 5 +- .../general/LanguageSpecificPronouns.tsx | 120 ++++++++++++++++++ src/app/features/settings/general/index.ts | 1 + src/app/hooks/useClientConfig.ts | 5 + 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 src/app/features/settings/general/LanguageSpecificPronouns.tsx diff --git a/src/app/features/settings/experimental/Experimental.tsx b/src/app/features/settings/experimental/Experimental.tsx index 8148c92e..f7962cc4 100644 --- a/src/app/features/settings/experimental/Experimental.tsx +++ b/src/app/features/settings/experimental/Experimental.tsx @@ -1,7 +1,7 @@ import { Box, Text, IconButton, Icon, Icons, Scroll } from 'folds'; import { Page, PageContent, PageHeader } from '$components/page'; import { InfoCard } from '$components/info-card'; -import { Sync } from '../general'; +import { Sync, LanguageSpecificPronouns } from '../general'; type ExperimentalProps = { requestClose: () => void; @@ -42,6 +42,9 @@ export function Experimental({ requestClose }: ExperimentalProps) { + + + diff --git a/src/app/features/settings/general/LanguageSpecificPronouns.tsx b/src/app/features/settings/general/LanguageSpecificPronouns.tsx new file mode 100644 index 00000000..0458136c --- /dev/null +++ b/src/app/features/settings/general/LanguageSpecificPronouns.tsx @@ -0,0 +1,120 @@ +import { Box, Input, Switch, Text } from 'folds'; +import { SettingTile } from '$components/setting-tile'; +import { SequenceCard } from '$components/sequence-card'; +import { useClientConfig } from '$hooks/useClientConfig'; +import { useEffect, useState } from 'react'; +import { SequenceCardStyle } from '../styles.css'; + +// type definition for the language specific pronouns configuration, which can be stored in the client config +export type LanguageSpecificPronounsConfig = { + enabled?: boolean | string; + languages?: string[]; +}; + +export const resolveLanguageSpecificPronounsEnabled = ( + enabled: LanguageSpecificPronounsConfig['enabled'] +): boolean => { + if (enabled === undefined) return false; + if (typeof enabled === 'boolean') return enabled; + const normalized = String(enabled).trim().toLowerCase(); + if (normalized === 'false' || normalized === '0' || normalized === 'off' || normalized === 'no') + return false; + if (normalized === 'true' || normalized === '1' || normalized === 'on' || normalized === 'yes') + return true; + return false; +}; + +// utility function to split a comma separated list of languages and trim whitespace +function splitAndTrimLanguages(languages: string): string[] { + return languages + .split(',') + .map((lang) => lang.trim()) + .filter((lang) => lang.length > 0); +} + +export function LanguageSpecificPronouns() { + const clientConfig = useClientConfig(); + + const [useLanguageSpecificPronouns, setEnabled] = useState(false); + const [languageList, setLanguageList] = useState(''); + + // common handler for saving changes to the language specific pronouns settings + const handleSave = (enabled: boolean, languages: string) => { + clientConfig.languageSpecificPronouns = { + ...clientConfig.languageSpecificPronouns, + enabled, + }; + clientConfig.languageSpecificPronouns = { + ...clientConfig.languageSpecificPronouns, + languages: splitAndTrimLanguages(languages), + }; + }; + + // handler for when the language list input changes + const handleLanguageListChange = (e: React.ChangeEvent) => { + const val = e.target.value.trim(); + setLanguageList(val); + // save the new language list to the client config, keeping the enabled state unchanged + handleSave(clientConfig.languageSpecificPronouns?.enabled ?? false, val); + }; + + useEffect(() => { + setEnabled( + resolveLanguageSpecificPronounsEnabled(clientConfig.languageSpecificPronouns?.enabled) + ); + setLanguageList(clientConfig.languageSpecificPronouns?.languages?.join(',') || ''); + }, [ + clientConfig.languageSpecificPronouns?.enabled, + clientConfig.languageSpecificPronouns?.languages, + ]); + + // handler for toggling the enabled state of language specific pronouns + const handleSetEnabled = (enabled: boolean) => { + console.debug('Updating language specific pronouns enabled to', enabled); + handleSave(enabled, clientConfig.languageSpecificPronouns?.languages?.join(',') || ''); + setEnabled(enabled); + }; + + return ( + + Language Specific Pronouns + + + } + /> + {useLanguageSpecificPronouns && ( + + } + /> + )} + + + ); +} diff --git a/src/app/features/settings/general/index.ts b/src/app/features/settings/general/index.ts index 0ab02c52..abb53556 100644 --- a/src/app/features/settings/general/index.ts +++ b/src/app/features/settings/general/index.ts @@ -1 +1,2 @@ export * from './General'; +export * from './LanguageSpecificPronouns'; \ No newline at end of file diff --git a/src/app/hooks/useClientConfig.ts b/src/app/hooks/useClientConfig.ts index deaf6dc1..04593ad6 100644 --- a/src/app/hooks/useClientConfig.ts +++ b/src/app/hooks/useClientConfig.ts @@ -13,6 +13,11 @@ export type ClientConfig = { disableAccountSwitcher?: boolean; + languageSpecificPronouns?: { + enabled?: boolean; + languages?: string[]; + }; + pushNotificationDetails?: { pushNotifyUrl?: string; vapidPublicKey?: string; From 0297c85e3143d704fd1c9fd4aa3667002bd440fd Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 18:13:08 +0100 Subject: [PATCH 02/15] refactor language specific pronouns handling with new settings structure --- .../general/LanguageSpecificPronouns.tsx | 32 +++++++------------ src/app/hooks/useClientConfig.ts | 5 --- src/app/state/settings.ts | 2 ++ 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/app/features/settings/general/LanguageSpecificPronouns.tsx b/src/app/features/settings/general/LanguageSpecificPronouns.tsx index 0458136c..5132eecd 100644 --- a/src/app/features/settings/general/LanguageSpecificPronouns.tsx +++ b/src/app/features/settings/general/LanguageSpecificPronouns.tsx @@ -1,11 +1,10 @@ import { Box, Input, Switch, Text } from 'folds'; import { SettingTile } from '$components/setting-tile'; import { SequenceCard } from '$components/sequence-card'; -import { useClientConfig } from '$hooks/useClientConfig'; import { useEffect, useState } from 'react'; +import { getSettings, setSettings, Settings } from '$state/settings'; import { SequenceCardStyle } from '../styles.css'; -// type definition for the language specific pronouns configuration, which can be stored in the client config export type LanguageSpecificPronounsConfig = { enabled?: boolean | string; languages?: string[]; @@ -33,21 +32,17 @@ function splitAndTrimLanguages(languages: string): string[] { } export function LanguageSpecificPronouns() { - const clientConfig = useClientConfig(); - const [useLanguageSpecificPronouns, setEnabled] = useState(false); const [languageList, setLanguageList] = useState(''); // common handler for saving changes to the language specific pronouns settings const handleSave = (enabled: boolean, languages: string) => { - clientConfig.languageSpecificPronouns = { - ...clientConfig.languageSpecificPronouns, - enabled, - }; - clientConfig.languageSpecificPronouns = { - ...clientConfig.languageSpecificPronouns, - languages: splitAndTrimLanguages(languages), - }; + const currentSettings = getSettings(); + setSettings({ + ...currentSettings, + languageSpecificPronounsEnabled: enabled, + languageSpecificPronounsLanguages: splitAndTrimLanguages(languages), + }); }; // handler for when the language list input changes @@ -55,23 +50,20 @@ export function LanguageSpecificPronouns() { const val = e.target.value.trim(); setLanguageList(val); // save the new language list to the client config, keeping the enabled state unchanged - handleSave(clientConfig.languageSpecificPronouns?.enabled ?? false, val); + handleSave(getSettings().languageSpecificPronounsEnabled ?? false, val); }; useEffect(() => { setEnabled( - resolveLanguageSpecificPronounsEnabled(clientConfig.languageSpecificPronouns?.enabled) + resolveLanguageSpecificPronounsEnabled(getSettings().languageSpecificPronounsEnabled ?? false) ); - setLanguageList(clientConfig.languageSpecificPronouns?.languages?.join(',') || ''); - }, [ - clientConfig.languageSpecificPronouns?.enabled, - clientConfig.languageSpecificPronouns?.languages, - ]); + setLanguageList(getSettings().languageSpecificPronounsLanguages?.join(',') || ''); + }, []); // handler for toggling the enabled state of language specific pronouns const handleSetEnabled = (enabled: boolean) => { console.debug('Updating language specific pronouns enabled to', enabled); - handleSave(enabled, clientConfig.languageSpecificPronouns?.languages?.join(',') || ''); + handleSave(enabled, getSettings().languageSpecificPronounsLanguages?.join(',') || ''); setEnabled(enabled); }; diff --git a/src/app/hooks/useClientConfig.ts b/src/app/hooks/useClientConfig.ts index 04593ad6..deaf6dc1 100644 --- a/src/app/hooks/useClientConfig.ts +++ b/src/app/hooks/useClientConfig.ts @@ -13,11 +13,6 @@ export type ClientConfig = { disableAccountSwitcher?: boolean; - languageSpecificPronouns?: { - enabled?: boolean; - languages?: string[]; - }; - pushNotificationDetails?: { pushNotifyUrl?: string; vapidPublicKey?: string; diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index a68f8dfc..6e9d0cc9 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -61,6 +61,8 @@ export interface Settings { privacyBlurEmotes: boolean; showPronouns: boolean; renderGlobalNameColors: boolean; + languageSpecificPronounsEnabled?: boolean; + languageSpecificPronounsLanguages?: string[]; // Sable features! mobileGestures: boolean; From 5152627fa94d0d2086c4e8a0e6a5d4ab9c4ab9e7 Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 18:14:04 +0100 Subject: [PATCH 03/15] removed unused import and console output --- src/app/features/settings/general/LanguageSpecificPronouns.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/features/settings/general/LanguageSpecificPronouns.tsx b/src/app/features/settings/general/LanguageSpecificPronouns.tsx index 5132eecd..0b1c3617 100644 --- a/src/app/features/settings/general/LanguageSpecificPronouns.tsx +++ b/src/app/features/settings/general/LanguageSpecificPronouns.tsx @@ -2,7 +2,7 @@ import { Box, Input, Switch, Text } from 'folds'; import { SettingTile } from '$components/setting-tile'; import { SequenceCard } from '$components/sequence-card'; import { useEffect, useState } from 'react'; -import { getSettings, setSettings, Settings } from '$state/settings'; +import { getSettings, setSettings } from '$state/settings'; import { SequenceCardStyle } from '../styles.css'; export type LanguageSpecificPronounsConfig = { @@ -62,7 +62,6 @@ export function LanguageSpecificPronouns() { // handler for toggling the enabled state of language specific pronouns const handleSetEnabled = (enabled: boolean) => { - console.debug('Updating language specific pronouns enabled to', enabled); handleSave(enabled, getSettings().languageSpecificPronounsLanguages?.join(',') || ''); setEnabled(enabled); }; From 3d30bd23c2c2c6f8f253736860cd00ba059aece3 Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 18:43:54 +0100 Subject: [PATCH 04/15] allow setting multi language pronouns --- src/app/features/settings/account/PronounEditor.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/features/settings/account/PronounEditor.tsx b/src/app/features/settings/account/PronounEditor.tsx index 9edfd1c9..4c3ffd72 100644 --- a/src/app/features/settings/account/PronounEditor.tsx +++ b/src/app/features/settings/account/PronounEditor.tsx @@ -14,7 +14,9 @@ type PronounEditorProps = { }; export function PronounEditor({ current, onSave }: PronounEditorProps) { - const initialString = current.map((p) => p.summary).join(', '); + const initialString = current + .map((p) => `${p.language ? `${p.language}:` : ''}${p.summary}`) + .join(', '); const [val, setVal] = useState(initialString); useEffect(() => setVal(initialString), [initialString]); @@ -26,7 +28,10 @@ export function PronounEditor({ current, onSave }: PronounEditorProps) { .split(',') .map((s) => s.trim()) .filter(Boolean) - .map((s) => ({ summary: s.slice(0, 16), language: 'en' })); + .map((s) => { + const [language, summary] = s.split(':'); + return { summary: summary.slice(0, 16), language: language || 'en' }; + }); onSave(next); }; @@ -37,7 +42,9 @@ export function PronounEditor({ current, onSave }: PronounEditorProps) { return ( Date: Thu, 5 Mar 2026 18:47:17 +0100 Subject: [PATCH 05/15] Option for filtering pronouns based on language --- src/app/features/room/message/Message.tsx | 32 +++++++++++++++++-- .../general/LanguageSpecificPronouns.tsx | 5 +-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index cbf85400..acf5d815 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -50,7 +50,7 @@ import { } from '$components/message'; import { canEditEvent, getMemberAvatarMxc } from '$utils/room'; import { mxcUrlToHttp } from '$utils/matrix'; -import { MessageLayout, MessageSpacing, settingsAtom } from '$state/settings'; +import { getSettings, MessageLayout, MessageSpacing, settingsAtom } from '$state/settings'; import { nicknamesAtom, setNicknameAtom } from '$state/nicknames'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { useRecentEmoji } from '$hooks/useRecentEmoji'; @@ -78,6 +78,7 @@ import { MessageDeleteItem } from '$components/message/modals/MessageDelete'; import { MessageReportItem } from '$components/message/modals/MessageReport'; import { MessageEditor } from './MessageEditor'; import * as css from './styles.css'; +import { useClientConfig } from '$hooks/useClientConfig'; export type ReactionHandler = (keyOrMxc: string, shortcode: string) => void; @@ -260,17 +261,42 @@ const Pronouns = as< >(({ as: AsPronouns = 'span', pronouns, tagColor, ...props }, ref) => { if (!pronouns || pronouns.length === 0) return null; + const languageFilterEnabled = Boolean(getSettings().languageSpecificPronounsEnabled ?? false); + // if no language is given use english + const selectedLanguages = (getSettings().languageSpecificPronounsLanguages ?? ['en']) + .map((lang) => lang.trim().toLowerCase()) + .filter(Boolean); + + const visiblePronouns = languageFilterEnabled + ? pronouns.filter((p) => { + const lang = String(p?.language ?? 'en') + .trim() + .toLowerCase(); + return selectedLanguages.some( + (selected) => + lang === selected || + lang.startsWith(`${selected}-`) || // e.g. en-US matches en + selected.startsWith(`${lang}-`) // e.g. en matches en-US (if reversed) + ); + }) + : pronouns; + const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, len)}...` : str); const limit = mobileOrTablet() ? 1 : 3; + // if language specific pronouns can't be found matching the filter return unfiltered + if (visiblePronouns.length === 0) { + visiblePronouns.push(...pronouns); + } + return ( - {pronouns.slice(0, limit).map((p) => ( + {visiblePronouns.slice(0, limit).map((p) => ( {clamp(p.summary, 16)} ))} - {pronouns.length > limit && ...} + {visiblePronouns.length > limit && ...} ); }); diff --git a/src/app/features/settings/general/LanguageSpecificPronouns.tsx b/src/app/features/settings/general/LanguageSpecificPronouns.tsx index 0b1c3617..22fbba4d 100644 --- a/src/app/features/settings/general/LanguageSpecificPronouns.tsx +++ b/src/app/features/settings/general/LanguageSpecificPronouns.tsx @@ -31,6 +31,7 @@ function splitAndTrimLanguages(languages: string): string[] { .filter((lang) => lang.length > 0); } +// MSC4247 allows users to set pronouns in different languages export function LanguageSpecificPronouns() { const [useLanguageSpecificPronouns, setEnabled] = useState(false); const [languageList, setLanguageList] = useState(''); @@ -77,7 +78,7 @@ export function LanguageSpecificPronouns() { > Date: Thu, 5 Mar 2026 19:11:09 +0100 Subject: [PATCH 06/15] feat: add parsePronounsInput utility function and refactor pronoun handling in commands --- src/app/features/room/message/Message.tsx | 1 - .../settings/account/PronounEditor.tsx | 10 ++----- src/app/hooks/useCommands.ts | 29 ++++++++++--------- src/app/utils/pronouns.ts | 11 +++++++ 4 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 src/app/utils/pronouns.ts diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index acf5d815..97af5642 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -78,7 +78,6 @@ import { MessageDeleteItem } from '$components/message/modals/MessageDelete'; import { MessageReportItem } from '$components/message/modals/MessageReport'; import { MessageEditor } from './MessageEditor'; import * as css from './styles.css'; -import { useClientConfig } from '$hooks/useClientConfig'; export type ReactionHandler = (keyOrMxc: string, shortcode: string) => void; diff --git a/src/app/features/settings/account/PronounEditor.tsx b/src/app/features/settings/account/PronounEditor.tsx index 4c3ffd72..29ee9467 100644 --- a/src/app/features/settings/account/PronounEditor.tsx +++ b/src/app/features/settings/account/PronounEditor.tsx @@ -1,6 +1,7 @@ import { useState, useEffect, ChangeEvent } from 'react'; import { Input } from 'folds'; import { SettingTile } from '$components/setting-tile'; +import { parsePronounsInput } from '$utils/pronouns'; type PronounSet = { summary: string; @@ -24,14 +25,7 @@ export function PronounEditor({ current, onSave }: PronounEditorProps) { const handleSave = () => { if (val === initialString) return; const safeVal = val.slice(0, 128); - const next = safeVal - .split(',') - .map((s) => s.trim()) - .filter(Boolean) - .map((s) => { - const [language, summary] = s.split(':'); - return { summary: summary.slice(0, 16), language: language || 'en' }; - }); + const next = parsePronounsInput(safeVal); onSave(next); }; diff --git a/src/app/hooks/useCommands.ts b/src/app/hooks/useCommands.ts index 4322c62b..903acdc9 100644 --- a/src/app/hooks/useCommands.ts +++ b/src/app/hooks/useCommands.ts @@ -30,6 +30,7 @@ import { splitWithSpace } from '$utils/common'; import { useSetting } from '$state/hooks/settings'; import { settingsAtom } from '$state/settings'; import { createRoomEncryptionState } from '$components/create-room'; +import { parsePronounsInput } from '$utils/pronouns'; import { useRoomNavigate } from './useRoomNavigate'; import { enrichWidgetUrl } from './useRoomWidgets'; @@ -888,7 +889,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { [Command.Pronoun]: { name: Command.Pronoun, description: - 'Set your pronouns for this room. Example: /pronoun "they/them, it/its" | /pronoun reset', + 'Set your pronouns for this room. Example: /pronoun "en:they/them, de:sie/ihr" | /pronoun reset', exe: async (payload) => { const match = payload.trim().match(/^"(.*)"$/); const rawInput = match ? match[1].trim() : payload.trim(); @@ -917,11 +918,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { return; } - const pronounsArray = rawInput - .split(',') - .map((p) => p.trim()) - .filter((p) => p.length > 0) - .map((p) => ({ summary: p })); + const pronounsArray = parsePronounsInput(rawInput); await mx.sendStateEvent( room.roomId, @@ -929,7 +926,12 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { { pronouns: pronounsArray }, userId ); - sendFeedback(`Room pronouns set: ${rawInput}`); + + const feedbackString = pronounsArray + .map((p) => (p.language ? `for ${p.language} "${p.summary}" was set` : p.summary)) + .join(', '); + + sendFeedback(`Room pronouns set: ${feedbackString}`); } catch (e: any) { if (e.errcode === 'M_FORBIDDEN') { sendFeedback('Permission Denied. Could not update room pronouns.'); @@ -977,11 +979,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { return; } - const pronounsArray = rawInput - .split(',') - .map((p) => p.trim()) - .filter((p) => p.length > 0) - .map((p) => ({ summary: p })); + const pronounsArray = parsePronounsInput(rawInput); await mx.sendStateEvent( targetSpaceId as any, @@ -989,7 +987,12 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { { pronouns: pronounsArray }, userId ); - sendFeedback(`Global space pronouns set: ${rawInput}`); + + const feedbackString = pronounsArray + .map((p) => (p.language ? `for ${p.language} "${p.summary}" was set` : p.summary)) + .join(', '); + + sendFeedback(`Global space pronouns set: ${feedbackString}`); } catch (e: any) { if (e.errcode === 'M_FORBIDDEN') { sendFeedback('Permission Denied. Could not update space pronouns.'); diff --git a/src/app/utils/pronouns.ts b/src/app/utils/pronouns.ts new file mode 100644 index 00000000..b95ff485 --- /dev/null +++ b/src/app/utils/pronouns.ts @@ -0,0 +1,11 @@ +// helper function to convert a comma-separated pronouns string into an array of objects with summary and optional language +export function parsePronounsInput(pronouns: string): { summary: string; language?: string }[] { + return pronouns + .split(',') + .map((s) => s.trim()) + .filter(Boolean) + .map((s) => { + const [language, summary] = s.split(':'); + return { summary: summary.slice(0, 16), language: language || 'en' }; + }); +} From 504b73753b4af22e8eced31bbdaae0b9127d8d86 Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 19:19:53 +0100 Subject: [PATCH 07/15] refactored LanguageSpecificPronouns --- .../{general => cosmetics}/LanguageSpecificPronouns.tsx | 0 src/app/features/settings/experimental/Experimental.tsx | 3 ++- src/app/features/settings/general/index.ts | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) rename src/app/features/settings/{general => cosmetics}/LanguageSpecificPronouns.tsx (100%) diff --git a/src/app/features/settings/general/LanguageSpecificPronouns.tsx b/src/app/features/settings/cosmetics/LanguageSpecificPronouns.tsx similarity index 100% rename from src/app/features/settings/general/LanguageSpecificPronouns.tsx rename to src/app/features/settings/cosmetics/LanguageSpecificPronouns.tsx diff --git a/src/app/features/settings/experimental/Experimental.tsx b/src/app/features/settings/experimental/Experimental.tsx index f7962cc4..b9719357 100644 --- a/src/app/features/settings/experimental/Experimental.tsx +++ b/src/app/features/settings/experimental/Experimental.tsx @@ -1,7 +1,8 @@ import { Box, Text, IconButton, Icon, Icons, Scroll } from 'folds'; import { Page, PageContent, PageHeader } from '$components/page'; import { InfoCard } from '$components/info-card'; -import { Sync, LanguageSpecificPronouns } from '../general'; +import { LanguageSpecificPronouns } from '../cosmetics/LanguageSpecificPronouns'; +import { Sync } from '../general'; type ExperimentalProps = { requestClose: () => void; diff --git a/src/app/features/settings/general/index.ts b/src/app/features/settings/general/index.ts index abb53556..0ab02c52 100644 --- a/src/app/features/settings/general/index.ts +++ b/src/app/features/settings/general/index.ts @@ -1,2 +1 @@ export * from './General'; -export * from './LanguageSpecificPronouns'; \ No newline at end of file From 2401e34873575303613b9508b3a41a72ab03ae13 Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 19:54:43 +0100 Subject: [PATCH 08/15] language-based filtering for pronouns in a users room profile and message view --- .../user-profile/UserRoomProfile.tsx | 13 ++++++++++- src/app/features/room/message/Message.tsx | 23 +++++++------------ .../cosmetics/LanguageSpecificPronouns.tsx | 12 +++++----- src/app/state/settings.ts | 4 ++-- src/app/utils/pronouns.ts | 17 ++++++++++++++ 5 files changed, 45 insertions(+), 24 deletions(-) diff --git a/src/app/components/user-profile/UserRoomProfile.tsx b/src/app/components/user-profile/UserRoomProfile.tsx index 68812698..c43d03c7 100644 --- a/src/app/components/user-profile/UserRoomProfile.tsx +++ b/src/app/components/user-profile/UserRoomProfile.tsx @@ -36,6 +36,8 @@ import { UserInviteAlert, UserBanAlert, UserModeration, UserKickAlert } from './ import { PowerChip } from './PowerChip'; import { IgnoredUserAlert, MutualRoomsChip, OptionsChip, ServerChip, ShareChip } from './UserChips'; import { UserHero, UserHeroName } from './UserHero'; +import { getSettings } from '$state/settings'; +import { filterPronounsByLanguage } from '$utils/pronouns'; const KNOWN_KEYS = [ 'moe.sable.app.bio', @@ -74,7 +76,16 @@ function UserExtendedSection({ return String(val); }; - const pronouns = profile.pronouns?.map((p: any) => clamp(p.summary, 16)).join(', '); + const languageFilterEnabled = getSettings().filterPronounsBasedOnLanguage ?? false; + const languagesToFilterFor = getSettings().filterPronounsLanguages ?? ['en']; + + const pronouns = filterPronounsByLanguage( + profile.pronouns!, + languageFilterEnabled, + languagesToFilterFor + ) + .map((p) => p.summary) + .join(', '); const localTime = useMemo(() => { if (!profile.timezone) return null; diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index 97af5642..b5ab9560 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -76,6 +76,7 @@ import { MessageReadReceiptItem } from '$components/message/modals/MessageReadRe import { MessageSourceCodeItem } from '$components/message/modals/MessageSource'; import { MessageDeleteItem } from '$components/message/modals/MessageDelete'; import { MessageReportItem } from '$components/message/modals/MessageReport'; +import { filterPronounsByLanguage } from '$utils/pronouns'; import { MessageEditor } from './MessageEditor'; import * as css from './styles.css'; @@ -260,25 +261,17 @@ const Pronouns = as< >(({ as: AsPronouns = 'span', pronouns, tagColor, ...props }, ref) => { if (!pronouns || pronouns.length === 0) return null; - const languageFilterEnabled = Boolean(getSettings().languageSpecificPronounsEnabled ?? false); + const languageFilterEnabled = Boolean(getSettings().filterPronounsBasedOnLanguage ?? false); // if no language is given use english - const selectedLanguages = (getSettings().languageSpecificPronounsLanguages ?? ['en']) + const selectedLanguages = (getSettings().filterPronounsLanguages ?? ['en']) .map((lang) => lang.trim().toLowerCase()) .filter(Boolean); - const visiblePronouns = languageFilterEnabled - ? pronouns.filter((p) => { - const lang = String(p?.language ?? 'en') - .trim() - .toLowerCase(); - return selectedLanguages.some( - (selected) => - lang === selected || - lang.startsWith(`${selected}-`) || // e.g. en-US matches en - selected.startsWith(`${lang}-`) // e.g. en matches en-US (if reversed) - ); - }) - : pronouns; + const visiblePronouns = filterPronounsByLanguage( + pronouns, + languageFilterEnabled, + selectedLanguages + ); const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, len)}...` : str); const limit = mobileOrTablet() ? 1 : 3; diff --git a/src/app/features/settings/cosmetics/LanguageSpecificPronouns.tsx b/src/app/features/settings/cosmetics/LanguageSpecificPronouns.tsx index 22fbba4d..32c57e59 100644 --- a/src/app/features/settings/cosmetics/LanguageSpecificPronouns.tsx +++ b/src/app/features/settings/cosmetics/LanguageSpecificPronouns.tsx @@ -41,8 +41,8 @@ export function LanguageSpecificPronouns() { const currentSettings = getSettings(); setSettings({ ...currentSettings, - languageSpecificPronounsEnabled: enabled, - languageSpecificPronounsLanguages: splitAndTrimLanguages(languages), + filterPronounsBasedOnLanguage: enabled, + filterPronounsLanguages: splitAndTrimLanguages(languages), }); }; @@ -51,19 +51,19 @@ export function LanguageSpecificPronouns() { const val = e.target.value.trim(); setLanguageList(val); // save the new language list to the client config, keeping the enabled state unchanged - handleSave(getSettings().languageSpecificPronounsEnabled ?? false, val); + handleSave(getSettings().filterPronounsBasedOnLanguage ?? false, val); }; useEffect(() => { setEnabled( - resolveLanguageSpecificPronounsEnabled(getSettings().languageSpecificPronounsEnabled ?? false) + resolveLanguageSpecificPronounsEnabled(getSettings().filterPronounsBasedOnLanguage ?? false) ); - setLanguageList(getSettings().languageSpecificPronounsLanguages?.join(',') || ''); + setLanguageList(getSettings().filterPronounsLanguages?.join(',') || ''); }, []); // handler for toggling the enabled state of language specific pronouns const handleSetEnabled = (enabled: boolean) => { - handleSave(enabled, getSettings().languageSpecificPronounsLanguages?.join(',') || ''); + handleSave(enabled, getSettings().filterPronounsLanguages?.join(',') || ''); setEnabled(enabled); }; diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index 6e9d0cc9..e8071ae5 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -61,8 +61,8 @@ export interface Settings { privacyBlurEmotes: boolean; showPronouns: boolean; renderGlobalNameColors: boolean; - languageSpecificPronounsEnabled?: boolean; - languageSpecificPronounsLanguages?: string[]; + filterPronounsBasedOnLanguage?: boolean; + filterPronounsLanguages?: string[]; // Sable features! mobileGestures: boolean; diff --git a/src/app/utils/pronouns.ts b/src/app/utils/pronouns.ts index b95ff485..96a29f19 100644 --- a/src/app/utils/pronouns.ts +++ b/src/app/utils/pronouns.ts @@ -9,3 +9,20 @@ export function parsePronounsInput(pronouns: string): { summary: string; languag return { summary: summary.slice(0, 16), language: language || 'en' }; }); } + +// helper function to filter a list of pronouns based on the user's language settings +export function filterPronounsByLanguage( + pronouns: { summary: string; language?: string }[], + enabled: boolean, + languages: string[] +): { summary: string; language?: string }[] { + if (!enabled) return pronouns; + const normalizedLanguages = languages.map((lang) => lang.trim().toLowerCase()); + const filteredPronouns = pronouns.filter((p) => + normalizedLanguages.includes((p.language || 'en').trim().toLowerCase()) + ); + if (filteredPronouns.length === 0) { + return pronouns; + } + return filteredPronouns; +} From 985567cc9d61ae2ce79087479e78d80bd3aa1b03 Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 19:56:39 +0100 Subject: [PATCH 09/15] adjusted example for the GPronoun command --- src/app/hooks/useCommands.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/hooks/useCommands.ts b/src/app/hooks/useCommands.ts index 903acdc9..ed2ad8cf 100644 --- a/src/app/hooks/useCommands.ts +++ b/src/app/hooks/useCommands.ts @@ -942,7 +942,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { [Command.GPronoun]: { name: Command.GPronoun, description: - 'Set your global pronouns for this space. Example: /gpronoun "they/them, it/its" | /gpronoun reset', + 'Set your global pronouns for this space. Example: /gpronoun "en:they/them, de:sie/ihr" | /gpronoun reset', exe: async (payload) => { const match = payload.trim().match(/^"(.*)"$/); const rawInput = match ? match[1].trim() : payload.trim(); From 6beb784a907cfaa56b9f64cc89c5eb3e14417130 Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 20:05:20 +0100 Subject: [PATCH 10/15] fixed import order --- src/app/components/user-profile/UserRoomProfile.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/components/user-profile/UserRoomProfile.tsx b/src/app/components/user-profile/UserRoomProfile.tsx index c43d03c7..0031943d 100644 --- a/src/app/components/user-profile/UserRoomProfile.tsx +++ b/src/app/components/user-profile/UserRoomProfile.tsx @@ -31,13 +31,13 @@ import { } from '$plugins/react-custom-html-parser'; import { useSpoilerClickHandler } from '$hooks/useSpoilerClickHandler'; import { RenderBody } from '$components/message'; +import { getSettings } from '$state/settings'; +import { filterPronounsByLanguage } from '$utils/pronouns'; import { CreatorChip } from './CreatorChip'; import { UserInviteAlert, UserBanAlert, UserModeration, UserKickAlert } from './UserModeration'; import { PowerChip } from './PowerChip'; import { IgnoredUserAlert, MutualRoomsChip, OptionsChip, ServerChip, ShareChip } from './UserChips'; import { UserHero, UserHeroName } from './UserHero'; -import { getSettings } from '$state/settings'; -import { filterPronounsByLanguage } from '$utils/pronouns'; const KNOWN_KEYS = [ 'moe.sable.app.bio', From abf95e7b82694bb54d6431c589638ebd97eea062 Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 20:20:04 +0100 Subject: [PATCH 11/15] fixed issue where it wouldn't accept "weird" string pronouns as pronouns --- src/app/utils/pronouns.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app/utils/pronouns.ts b/src/app/utils/pronouns.ts index 96a29f19..a306543c 100644 --- a/src/app/utils/pronouns.ts +++ b/src/app/utils/pronouns.ts @@ -5,8 +5,21 @@ export function parsePronounsInput(pronouns: string): { summary: string; languag .map((s) => s.trim()) .filter(Boolean) .map((s) => { - const [language, summary] = s.split(':'); - return { summary: summary.slice(0, 16), language: language || 'en' }; + const parts = s.split(':'); + + if (parts.length === 1) { + return { + summary: parts[0].slice(0, 16), + language: 'en', + }; + } + + const [language, summary] = parts; + + return { + language: language || 'en', + summary: summary.slice(0, 16), + }; }); } From ca17eeebc185ae80dbf887d49647a16d9588cb2f Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 20:28:06 +0100 Subject: [PATCH 12/15] added changeset --- ...pronouns_based_on_the_pronouns_language.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md diff --git a/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md b/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md new file mode 100644 index 00000000..a62b1c07 --- /dev/null +++ b/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md @@ -0,0 +1,28 @@ +--- +default: minor +--- + +# Add option to filter user pronouns based on the pronouns language + +#154 by git@itsrye.dev + +## Description + +the MSC4247 (which we are using in its unstable form) states: + +> All fields within m.pronouns are optional, excluding "language" and "summary" + +Therefore it would be useful to have a possibility to set the language of a pronoun set. + +This can be done by optionally (default: english, so not to cause unexpected behaviour) specifying the language, e.g. `en:she/her`. + +In this case it's equivalent to just entering `she/her` + +Also a way to filter the shown pronouns based on a specified language was introduced. This will find it's home under experimental features for the time being. + +It also accepts "*weird*" string inputs as pronoun, for example setting your pronouns just to `meow` will internally be transformed to `en:meow`. + +There are multiple ways to set your pronouns: + +1. The UI like before but with optional language specifier +2. The `/Pronoun` and `/GPronoun` commands with their behaviour unchanged besides the language based transformation. From 0b75031f1a0aeb1409f38466a5a46de75e30fc01 Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 20:32:56 +0100 Subject: [PATCH 13/15] formatting with fmt --- ...on_to_filter_user_pronouns_based_on_the_pronouns_language.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md b/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md index a62b1c07..80a52dcb 100644 --- a/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md +++ b/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md @@ -20,7 +20,7 @@ In this case it's equivalent to just entering `she/her` Also a way to filter the shown pronouns based on a specified language was introduced. This will find it's home under experimental features for the time being. -It also accepts "*weird*" string inputs as pronoun, for example setting your pronouns just to `meow` will internally be transformed to `en:meow`. +It also accepts "_weird_" string inputs as pronoun, for example setting your pronouns just to `meow` will internally be transformed to `en:meow`. There are multiple ways to set your pronouns: From 88c49fc8e9c53d63c62aec31ed0ec4752a36be36 Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 5 Mar 2026 21:00:39 +0100 Subject: [PATCH 14/15] simplify description for filtering user pronouns by language --- ...pronouns_based_on_the_pronouns_language.md | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md b/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md index 80a52dcb..390e3a43 100644 --- a/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md +++ b/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md @@ -1,28 +1,5 @@ --- -default: minor +sable: minor --- -# Add option to filter user pronouns based on the pronouns language - -#154 by git@itsrye.dev - -## Description - -the MSC4247 (which we are using in its unstable form) states: - -> All fields within m.pronouns are optional, excluding "language" and "summary" - -Therefore it would be useful to have a possibility to set the language of a pronoun set. - -This can be done by optionally (default: english, so not to cause unexpected behaviour) specifying the language, e.g. `en:she/her`. - -In this case it's equivalent to just entering `she/her` - -Also a way to filter the shown pronouns based on a specified language was introduced. This will find it's home under experimental features for the time being. - -It also accepts "_weird_" string inputs as pronoun, for example setting your pronouns just to `meow` will internally be transformed to `en:meow`. - -There are multiple ways to set your pronouns: - -1. The UI like before but with optional language specifier -2. The `/Pronoun` and `/GPronoun` commands with their behaviour unchanged besides the language based transformation. +Add option to filter user pronouns based on the pronouns language From 854f2758e68f5811dca64014c697fc93957aae4d Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 5 Mar 2026 15:09:34 -0600 Subject: [PATCH 15/15] Refactor settings.ts to resolve merge conflicts Remove conflicting lines and clean up settings. --- src/app/state/settings.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index 09ceba44..835984b3 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -61,13 +61,10 @@ export interface Settings { privacyBlurEmotes: boolean; showPronouns: boolean; renderGlobalNameColors: boolean; -<<<<<<< feat-honor-language-of-pronouns filterPronounsBasedOnLanguage?: boolean; filterPronounsLanguages?: string[]; -======= renderRoomColors: boolean; renderRoomFonts: boolean; ->>>>>>> dev // Sable features! mobileGestures: boolean;