allow setting multi language pronouns
This commit is contained in:
1 file changed
+10
-3
@@ -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 (
|
||||
<SettingTile
|
||||
title="Pronouns"
|
||||
description="Separate sets with commas (e.g. 'they/them, it/its')."
|
||||
// let people specify multiple sets of pronouns for different languages
|
||||
// the input is a comma separated list of pronoun sets, each set can have an optional language tag (e.g. "en:they/them, de:sie/ihr")
|
||||
description="Separate sets with commas (e.g. 'en:they/them, en:it/its, de:sie/ihr')."
|
||||
after={
|
||||
<Input
|
||||
value={val}
|
||||
|
||||
Reference in new issue
Block a user