Repository navigation
Add a translation switcher for localized content pages - #55
Merged
Merged
Conversation
Localized content kept in one directory per locale (content/pages/en/ next to content/pages/cs/) gets a drop-down in the editor's floating toolbar: switch to a translation, open it side by side, or create a missing one. Pages pair by the same path below the locale directory, else by a front matter key (counterpart by default, stem/slug/path, either direction), else by a string map in content.config.ts. Locales come from the settings, the i18n.locales of nuxt.config, or sibling directories named like locale codes. Also Navigate > Switch to Translation, Related Symbol items, and a Missing translation weak warning whose fix creates the page (with counterpart set when its name differs). Settings: show the switcher, locales, front matter keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KGGeqcwjamvMDTrazMJWkz
Show the floating switcher from register() instead of overriding isApplicable, open translations with openFile(file), and restart the daemon with a reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KGGeqcwjamvMDTrazMJWkz
FileEditorManager.openFile(VirtualFile) is deprecated in 2026.3 too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KGGeqcwjamvMDTrazMJWkz
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.
What and why
Requested: a quick way to compare or switch between translations when content is localized in per-locale folders (
content/pages/en/,content/pages/cs/). The request covered a floating button in the top-right corner of the editor with a drop-down of the translated pages, plus Open side by side, Create missing translation, a missing-translation warning, and settings.How a page's translations are found (
ComarkTranslations)Locale directory: a directory whose name is a locale code (ISO 639-1, optionally with a region or script:
en,pt-br,zh-hant). It counts if either:i18n.localesinnuxt.config.*); orA lone
id/orit/folder is not a locale. The nearest locale directory above a page defines its locale, and that directory's parent is the group. Known locales without a directory still count, so the page is reported missing there.Counterpart in another locale: checked in this order, with no fuzzy guessing (several matches are all listed):
threats/en/01.phishing.md↔threats/cs/01.phishing.md);counterpartby default and configurable. The value can be a stem, slug or path, compared without ordering prefixes, and the link works in either direction;content.config.*such as{ about: 'o-nas', terms: 'podminky' }, used only when both sides name pages.Caching: results are cached per group and invalidated on file structure changes, Comark edits, settings changes, and changes to the content or Nuxt config. Front matter is cached per file stamp.
UI
editorFloatingToolbarProvider):EN) and opens a drop-down;register();CS · o-nas.mdto switch,Open CS side by side · o-nas.md(EditorWindow.split), andCreate CS translation…for each missing locale.ComarkTranslationCreator): asks for the path below the locale's directory, prefilled with the same path. It creates missing directories and copies the page as one undoable command, then opens it. When the new name differs, it writescounterpart: <stem or slug>into the front matter.Safety
FloatingToolbarProvider.isApplicableandpriority: the switcher is shown fromregister()instead;FileEditorManager.openFile(...): translations open withOpenFileDescriptor.navigate;DaemonCodeAnalyzer.restart(): replaced byrestart(reason).onHiddenByEscis not overridden.How it was tested
ComarkTranslationsTest(10 tests), on the reporter's layout: pages inen/cswith translated slugs, numbered threats, apagePairsmap incontent.config.ts, and a loneid/folder. It covers:id/negative case;counterpart(both directions) and config-map pairing;i18n.localesfromnuxt.config;counterpart; a new locale directory; validation);./gradlew test: 913 tests, 0 failures.🤖 Generated with Claude Code
https://claude.ai/code/session_01KGGeqcwjamvMDTrazMJWkz