ShortcutGrid: Add internationalization (i18n) support for Shortcut grid component
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 58/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- react, typescript
调研方向
从 Shortcut.tsx 开始,重点查看第 38–54 行附近现有的硬编码标签以及 ShortcutProps 接口。添加可选标签,同时保留当前的英文默认值,然后验证每个布尔型鼠标操作 prop 都会渲染其可自定义的标签,并保持现有的 ShortcutGrid 用法不变。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- TypeScript
- 星标
- 10
- 派生
- 40
- 平均合并
- 3 天 22 小时
- 30 天内合并 PR
- 4
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
patternfly/react-component-groups 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
patternfly/react-component-groups#968 · 1 条评论 ·
-
PF Team
patternfly/react-component-groups#979 · 已指派 1 人 ·
-
难度 3/5 1-2 天 新手友好度 68/100
-
难度 3/5 1-2 天 新手友好度 55/100
patternfly/react-component-groups#942 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
查看 patternfly/react-component-groups 的全部 Issue
相似的 Issue
-
blocklist removal
难度 2/5 1-3 小时 新手友好度 65/100
MetaMask/eth-phishing-detect#296544 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
pastelsky/bundlephobia#1122 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100