patternfly / patternfly/react-component-groups

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

オープン
#909 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

rehor-ai-patternfly
主要言語
TypeScript
スター
10
フォーク
40
平均マージ
3日 22時間
マージ済み PR(30日)
4

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Shortcut.tsx から始め、特に 38–54 行付近にある既存のハードコードされたラベルと ShortcutProps インターフェースを確認してください。現在の英語のデフォルト値を維持するオプションのラベルを追加し、その後、各 boolean マウスアクション prop がカスタマイズ可能なラベルをレンダリングすることを、既存の ShortcutGrid の使用方法を維持したまま確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
react, typescript
領域
frontend, internationalization
issue の種類
機能追加
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
58/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。