i18n: use automatic type inference of translation keys

Finally figured out a way to make typescript strongly type translation
keys so we can avoid the tedium of creating enums of translation keys.
This commit is contained in:
David Lechner
2022-07-22 13:48:50 -05:00
parent 3e10096b6e
commit d6df128860
80 changed files with 402 additions and 875 deletions
+4 -4
View File
@@ -7,7 +7,7 @@ import { OverlayContainer } from 'react-aria';
import { useBoolean } from 'usehooks-ts';
import { Button } from './Button';
import HelpDialog from './HelpDialog';
import { I18nId, useI18n } from './i18n';
import { useI18n } from './i18n';
type HelpButtonProps = {
/** The label of the control this button provides help for. */
@@ -49,9 +49,9 @@ const HelpButton: React.VoidFunctionComponent<HelpButtonProps> = ({
return (
<>
<Button
label={i18n.translate(I18nId.HelpButtonLabel)}
label={i18n.translate('helpButton.label')}
hideLabel
description={i18n.translate(I18nId.HelpButtonDescription, {
description={i18n.translate('helpButton.description', {
helpForLabel,
})}
minimal
@@ -62,7 +62,7 @@ const HelpButton: React.VoidFunctionComponent<HelpButtonProps> = ({
{isDialogMounted && (
<OverlayContainer className={Classes.PORTAL}>
<HelpDialog
title={i18n.translate(I18nId.HelpDialogTitle)}
title={i18n.translate('helpDialog.title')}
isOpen={isDialogOpen}
openButton={openButton}
onClose={setIsDialogOpenFalse}