patternfly / patternfly/react-component-groups
ShortcutGrid: Add internationalization (i18n) support for Shortcut grid component
Personne n'a encore pris cette issue.
- Langage dominant
- TypeScript
- Étoiles
- 10
- Forks
- 40
- Merge moyen
- 3 j 22 h
- PR mergées (30 j)
- 4
Description
Describe the problem
The Shortcut component (used by ShortcutGrid) currently has hardcoded English strings for mouse action labels with no way to internationalize them for applications that need to support multiple languages.
Current hardcoded strings
-
"Hover"(line 38 of Shortcut.tsx) -
"Click"(line 45) -
"Right click"(line 48) -
"Drag"(line 51) -
"Drag + Drop"(line 54)
These are rendered inside Label components alongside a MouseIcon when the corresponding boolean props (hover, click, rightClick, drag, dragAndDrop) are set to true.
Proposed solution
Add optional label props for each mouse action to allow customization of all user-facing strings:
export interface ShortcutProps {
// ... existing props
/** Custom label for "Hover" mouse action */
hoverLabel?: string;
/** Custom label for "Click" mouse action */
clickLabel?: string;
/** Custom label for "Right click" mouse action */
rightClickLabel?: string;
/** Custom label for "Drag" mouse action */
dragLabel?: string;
/** Custom label for "Drag + Drop" mouse action */
dragAndDropLabel?: string;
}
These would default to the current English strings for backwards compatibility.
Example usage
import { useTranslation } from 'react-i18next';
const MyComponent = () => {
const { t } = useTranslation();
return (
<ShortcutGrid
shortcuts={[
{
keys: ['ctrl'],
drag: true,
dragLabel: t('Drag'),
description: t('Move object'),
},
{
keys: [],
rightClick: true,
rightClickLabel: t('Right click'),
description: t('Open context menu'),
},
]}
/>
);
};
Impact
Applications using Shortcut or ShortcutGrid that need to support non-English languages currently have to either:
-
Accept English-only mouse action labels
-
Avoid the boolean mouse action props entirely and lose the
MouseIcon+Labelbadge rendering -
Build their own shortcut component from scratch
Related
This would align ShortcutGrid with other PatternFly components that support i18n.
Jira Issue: PF-3867
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez dans Shortcut.tsx, en particulier par les labels codés en dur existants autour des lignes 38–54 et par l’interface ShortcutProps. Ajoutez des labels facultatifs qui conservent les valeurs par défaut actuelles en anglais, puis vérifiez que chaque prop booléenne d’action de la souris affiche son label personnalisable, tout en préservant l’utilisation existante de ShortcutGrid.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- react, typescript
- Domaine
- frontend, internationalization
- Type d'issue
- Fonctionnalité
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- Calme
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 58/100