Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

ShortcutGrid: Add internationalization (i18n) support for Shortcut grid component

Aberta
#909 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
58/100
Tipo de issue
Funcionalidade
Clareza
Claramente especificada
Status de atividade
Pouca atividade
Stack de tecnologia
react, typescript

Direção de pesquisa

Comece em Shortcut.tsx, especialmente pelos labels codificados diretamente existentes em torno das linhas 38–54 e pela interface ShortcutProps. Adicione labels opcionais que mantenham os valores padrão atuais em inglês e, em seguida, verifique se cada prop booleana de ação do mouse renderiza seu label personalizável, preservando o uso existente de ShortcutGrid.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

rehor-ai-patternfly

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 + Label badge rendering

  • Build their own shortcut component from scratch

Related

This would align ShortcutGrid with other PatternFly components that support i18n.


Jira Issue: PF-3867

Linguagem predominante
TypeScript
Estrelas
10
Forks
40
Merge médio
12min
PRs com merge (30d)
1

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de patternfly/react-component-groups

Todas as issues de patternfly/react-component-groups

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.