Repository: wagtail/wagtail
File: wagtail/admin/templatetags/wagtailadmin_tags.py (Python)

Code before:
def workflow_status_with_date(workflow_state):
    translation_context = {
        "finished_at": naturaltime(workflow_state.current_task_state.finished_at),
        "started_at": naturaltime(workflow_state.current_task_state.started_at),
        "task_name": workflow_state.current_task_state.task.name,
        "status_display": workflow_state.get_status_display,
    }

    if workflow_state.status == "needs_changes":
        return _("Changes requested %(finished_at)s") % translation_context

    if workflow_state.status == "in_progress":
        return _("Sent to %(task_name)s %(started_at)s") % translation_context

    return _("%(status_display)s %(task_name)s %(started_at)s") % translation_context


@register.inclusion_tag(
    "wagtailadmin/shared/keyboard_shortcuts_dialog.html", takes_context=True
)
def keyboard_shortcuts_dialog(context):
    user_agent = context["request"].headers.get("User-Agent", "")
    is_mac = re.search(r"Mac|iPod|iPhone|iPad", user_agent)
    shortcuts_category = {
        "Actions": [
            {"Label": "Save", "Shortcut": ("⌘" if is_mac else "Ctrl") + " + s"},
            {"Label": "Preview", "Shortcut": ("⌘" if is_mac else "Ctrl") + " + p"},
        ],
        "Common actions": [
            {"Label": "Copy", "Shortcut": ("⌘" if is_mac else "Ctrl") + " + c"},
            {"Label": "Cut", "Shortcut": ("⌘" if is_mac else "Ctrl") + " + x"},
            {"Label": "Paste", "Shortcut": ("⌘" if is_mac else "Ctrl") + " + v"},
            {
                "Label": "Paste without formatting",
                "Shortcut": ("⌘" if is_mac else "Ctrl") + " + shift + v",
            },
            {"Label": "Undo", "Shortcut": ("⌘" if is_mac else "Ctrl") + " + z"},
            {"Label": "Redo", "Shortcut": ("⌘" if is_mac else "Ctrl") + " + y"},
        ],
        "Text formatting": [
            {"Label": "Bold", "Shortcut": ("⌘" if is_mac else "Ctrl") + " + b"},
            {"Label": "Italic", "Shortcut": ("⌘" if is_mac else "Ctrl") + " + i"},
            {"Label": "Underline", "Shortcut": ("⌘" if is_mac else "Ctrl") + " + u"},
            {
                "Label": "Monospace (code)",
                "Shortcut": ("⌘" if is_mac else "Ctrl") + " + j",
            },
            {
                "Label": "Strike-through",
                "Shortcut": ("⌘" if is_mac else "Ctrl") + " + x",
            },

Review comment (refactor):
Instead of repeating the logic, we can extract this to a variable, e.g.

```py
modifier = "⌘" if is_mac else "Ctrl"
```

and in this case I think the keys should be in snake case, e.g.

```suggestion
            {"label": "Save", "shortcut": f"{modifier} + s"},
```

Code after:
        "status_display": workflow_state.get_status_display,
    }

    if workflow_state.status == "needs_changes":
        return _("Changes requested %(finished_at)s") % translation_context

    if workflow_state.status == "in_progress":
        return _("Sent to %(task_name)s %(started_at)s") % translation_context

    return _("%(status_display)s %(task_name)s %(started_at)s") % translation_context


@register.inclusion_tag(
    "wagtailadmin/shared/keyboard_shortcuts_dialog.html",
    takes_context=True,
)
def keyboard_shortcuts_dialog(context):
    """
    Renders the keyboard shortcuts dialog content with the
    appropriate shortcuts for the user's platform.
    Note: Shortcut keys are intentionally not translated.
    """

    user_agent = context["request"].headers.get("User-Agent", "")
    is_mac = re.search(r"Mac|iPod|iPhone|iPad", user_agent)
    modifier = "⌘" if is_mac else "Ctrl"

    return {
        "shortcuts": {
            ("actions-common", _("Common actions")): [
                (_("Copy"), f"{modifier} + c"),
                (_("Cut"), f"{modifier} + x"),
                (_("Paste"), f"{modifier} + v"),
                (
                    _("Paste and match style")
                    if is_mac
                    else _("Paste without formatting"),
                    f"{modifier} + Shift + v",
                ),
                (_("Undo"), f"{modifier} + z"),
                (
                    _("Redo"),
                    f"{modifier} + Shift + z" if is_mac else f"{modifier} + y",
                ),
            ],
            ("actions-model", _("Actions")): [
                (_("Save changes"), f"{modifier} + s"),
                (_("Preview"), f"{modifier} + p"),
            ],
            ("rich-text-content", _("Text content")): [
                (_("Insert or edit a link"), f"{modifier} + k")