Make valid-i18n-keys rule strict and fix most exceptions
This commit is contained in:
parent
18a6da310f
commit
11cfcb4e32
36 changed files with 796 additions and 687 deletions
|
@ -7,6 +7,7 @@ import type { ConversationType } from '../state/ducks/conversations';
|
|||
import type { PreferredBadgeSelectorType } from '../state/selectors/badges';
|
||||
import { GroupDialog } from './GroupDialog';
|
||||
import { sortByTitle } from '../util/sortByTitle';
|
||||
import { missingCaseError } from '../util';
|
||||
|
||||
export type DataPropsType = {
|
||||
conversationId: string;
|
||||
|
@ -70,8 +71,6 @@ export const GroupV1MigrationDialog: React.FunctionComponent<PropsType> =
|
|||
const keepHistory = hasMigrated
|
||||
? i18n('GroupV1--Migration--info--keep-history')
|
||||
: i18n('GroupV1--Migration--migrate--keep-history');
|
||||
const migrationKey = hasMigrated ? 'after' : 'before';
|
||||
const droppedMembersKey = `GroupV1--Migration--info--removed--${migrationKey}`;
|
||||
|
||||
let primaryButtonText: string;
|
||||
let onClickPrimaryButton: () => void;
|
||||
|
@ -116,14 +115,16 @@ export const GroupV1MigrationDialog: React.FunctionComponent<PropsType> =
|
|||
getPreferredBadge,
|
||||
i18n,
|
||||
members: invitedMembers,
|
||||
prefix: 'GroupV1--Migration--info--invited',
|
||||
hasMigrated,
|
||||
kind: 'invited',
|
||||
theme,
|
||||
})}
|
||||
{renderMembers({
|
||||
getPreferredBadge,
|
||||
i18n,
|
||||
members: droppedMembers,
|
||||
prefix: droppedMembersKey,
|
||||
hasMigrated,
|
||||
kind: 'dropped',
|
||||
theme,
|
||||
})}
|
||||
</>
|
||||
|
@ -136,26 +137,49 @@ function renderMembers({
|
|||
getPreferredBadge,
|
||||
i18n,
|
||||
members,
|
||||
prefix,
|
||||
hasMigrated,
|
||||
kind,
|
||||
theme,
|
||||
}: Readonly<{
|
||||
getPreferredBadge: PreferredBadgeSelectorType;
|
||||
i18n: LocalizerType;
|
||||
members: Array<ConversationType>;
|
||||
prefix: string;
|
||||
hasMigrated: boolean;
|
||||
kind: 'invited' | 'dropped';
|
||||
theme: ThemeType;
|
||||
}>): React.ReactNode {
|
||||
if (!members.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const postfix = members.length === 1 ? '--one' : '--many';
|
||||
const key = `${prefix}${postfix}`;
|
||||
let text: string;
|
||||
switch (kind) {
|
||||
case 'invited':
|
||||
text =
|
||||
members.length === 1
|
||||
? i18n('GroupV1--Migration--info--invited--one')
|
||||
: i18n('GroupV1--Migration--info--invited--many');
|
||||
break;
|
||||
case 'dropped':
|
||||
if (hasMigrated) {
|
||||
text =
|
||||
members.length === 1
|
||||
? i18n('GroupV1--Migration--info--removed--before--one')
|
||||
: i18n('GroupV1--Migration--info--removed--before--many');
|
||||
} else {
|
||||
text =
|
||||
members.length === 1
|
||||
? i18n('GroupV1--Migration--info--removed--after--one')
|
||||
: i18n('GroupV1--Migration--info--removed--after--many');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw missingCaseError(kind);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* eslint-disable-next-line local-rules/valid-i18n-keys */}
|
||||
<GroupDialog.Paragraph>{i18n(key)}</GroupDialog.Paragraph>
|
||||
<GroupDialog.Paragraph>{text}</GroupDialog.Paragraph>
|
||||
<GroupDialog.Contacts
|
||||
contacts={sortByTitle(members)}
|
||||
getPreferredBadge={getPreferredBadge}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue