Skip to content

Toolbar button broken on non-English systems — actionName hardcoded to English #2

Description

@renky25

Bug Description

The toolbar Toggle Preview button doesn't work on non-English systems because actionName is hardcoded to "Change Mode", but MarkEdit-preview localizes menu item titles.

Root Cause

firstActionNamed in MarkEdit does an exact title match:

// MarkEditMac/Sources/Extensions/NSMenu+Extension.swift
func firstActionNamed(_ title: String) -> NSMenuItem? {
    firstDescendant {
      $0.title == title && $0.action != nil
    }
}

And MarkEdit-preview localizes the menu title per system language:

https://github.com/MarkEdit-app/MarkEdit-preview/blob/main/src/shared/strings.ts

'zh-CN':  { changeMode: '切换模式' },
'zh-TW':  { changeMode: '切換模式' },
'default': { changeMode: 'Change Mode' },

But Apply One-Click Toggle Setup always writes:

jsonc
"actionName": "Change Mode"   // ❌ only works on English systems

Steps to Reproduce

1. Set macOS system language to 简体中文 (zh-CN)
2. Install MarkEdit-preview + Direct Preview
3. Run "Apply One-Click Toggle Setup"
4. Restart MarkEdit, add the Toggle Preview toolbar button
5. Click the 👁 button → nothing happens

Expected Behavior

The toolbar button should toggle Edit ↔ Preview regardless of system language.

Suggested Fix

Instead of hardcoding English, there are a few options:

1. Simplest: Accept multiple actionName values and try them in order:
jsonc
"actionName": ["Change Mode", "切换模式", "切換模式"]
2. Robust: Read the localized string from MarkEdit-preview's settings.json or expose it via an API.
3. Workaround for users: Document in README that non-English users need to manually change actionName to match their locale.

Environment

- macOS 26 (Sequoia)
- MarkEdit 1.33+
- MarkEdit-preview v1.8.1
- Direct Preview v0.1.0
- System Language: zh-CN (简体中文)

---

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions