feat: localize selection menu labels via selectionMenuLabels prop#415
Open
marcellov7 wants to merge 1 commit into
Open
feat: localize selection menu labels via selectionMenuLabels prop#415marcellov7 wants to merge 1 commit into
marcellov7 wants to merge 1 commit into
Conversation
The built-in copy actions (Copy, Copy as Markdown, Copy Image URL) were
hardcoded in English in the native code, so on non-English apps they did
not match the rest of the UI (the OS-provided items are localized, these
were not).
Add a `selectionMenuLabels` prop on `EnrichedMarkdownText` to override the
labels from JS — typically wired to the app's i18n. Any label left
undefined keeps its English default, so it is fully backward compatible.
- TS: new `SelectionMenuLabels` type + prop; labels folded into the
existing `selectionMenuConfig` codegen struct and normalized JS-side
(empty string = use native default).
- Android: labels read in `MarkdownViewManagerUtils`, applied in
`SelectionActionMode` and threaded to the table and math copy menus.
- iOS/macOS: labels carried on `ENRMSelectionMenuConfig` and applied in
`EditMenuUtils` (+macOS) and the table/math container menus.
- `copyImageUrls` is a `{count}` template for the multi-image case.
- Docs: COPY_OPTIONS.md and API_REFERENCE.md.
Scope: `EnrichedMarkdownText` (and github flavor). `EnrichedMarkdownTextInput`
keeps only the visibility config for now — can follow up.
Closes software-mansion#198
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #198.
The built-in copy actions (Copy, Copy as Markdown, Copy Image URL) are hardcoded in English in the native code. On non-English apps they stay in English while the OS-provided menu items (Look Up, Translate…) are localized, creating an inconsistent menu — exactly the problem reported in #198.
This adds a
selectionMenuLabelsprop onEnrichedMarkdownTextso the labels can be overridden from JS (option 2 in the issue), typically wired to the app's i18n:Any label left
undefinedkeeps its English default, so the change is fully backward compatible.How it works
The labels are folded into the existing
selectionMenuConfigcodegen struct (normalized JS-side, where an empty string means "use the native default"), so no new native prop plumbing is introduced.SelectionMenuLabelstype + prop; normalization innative/EnrichedMarkdownText.tsx; struct fields added to both text/github codegen specs.MarkdownViewManagerUtils, applied inSelectionActionModeand threaded to the table and math copy menus.ENRMSelectionMenuConfig(strong owners on the view) and applied inEditMenuUtils(+macOS) and theTableContainerView/ENRMMathContainerViewmenus.Scope
Covers
EnrichedMarkdownText(commonmark + github flavor), including the table and math block copy menus listed in #198.EnrichedMarkdownTextInputkeeps only its visibility config for now (the Format submenu labels could be a follow-up).Notes for reviewers
docs/COPY_OPTIONS.md(new "Localizing Menu Labels" section) anddocs/API_REFERENCE.md.yarn typecheckandeslintpass locally. I couldn't run the native (Xcode/Gradle) builds or clang-format/ktlint in my environment, so please double-check the native formatting matches the hooks — happy to adjust.🤖 Generated with Claude Code