Skip to content

fix: translation directory detection to require 'translations' parent dir#743

Merged
cjbell merged 1 commit intomainfrom
cjbell-KNO-12176-cli-translation-directory-detection-d20f
Mar 20, 2026
Merged

fix: translation directory detection to require 'translations' parent dir#743
cjbell merged 1 commit intomainfrom
cjbell-KNO-12176-cli-translation-directory-detection-d20f

Conversation

@cjbell
Copy link
Copy Markdown
Contributor

@cjbell cjbell commented Mar 20, 2026

Description

The isTranslationDir function previously only checked if a directory name was a valid locale code, causing false positives when any ancestor directory in the path had a locale-code name (e.g., a username like mr which matches the Marathi locale). This caused non-translation commands like workflow:push to fail with Error: Cannot run workflow:push inside a translation directory.

Changes:

  • Updated isTranslationDir in src/lib/marshal/translation/helpers.ts to also verify that the parent directory is named translations, matching the expected Knock project structure (translations/{locale})
  • In the translation reader (src/lib/marshal/translation/reader.ts), the translationsIndexDir case now uses isValidLocale directly instead of isTranslationDir, since it already knows it's iterating within a translations index directory
  • Removed the now-unnecessary cautionary comment in src/lib/run-context/loader.ts
  • Added test cases covering the false-positive scenario (locale-code directory names outside of a translations parent)

Screenshots

Not applicable — this is a logic fix with no UI changes. All 766 tests pass, including 4 updated isTranslationDir tests.

Linear Issue: KNO-12176

Open in Web Open in Cursor 

The isTranslationDir function previously only checked if a directory name
was a valid locale code, which caused false positives when any ancestor
directory in the path happened to have a locale-code name (e.g. a username
like 'mr' which is a valid Marathi locale code).

Now isTranslationDir also verifies that the parent directory is named
'translations', matching the expected Knock project structure of
translations/{locale}.

In the translation reader, the translationsIndexDir case already knows it
is iterating within a translations directory, so it uses isValidLocale
directly instead of isTranslationDir (which would fail since the parent
is the translations index dir, not always named 'translations').

Fixes KNO-12176

Co-authored-by: Chris Bell <chris@cjbell.co>
@linear
Copy link
Copy Markdown

linear bot commented Mar 20, 2026

@cjbell cjbell changed the title Fix translation directory detection to require 'translations' parent dir fix: translation directory detection to require 'translations' parent dir Mar 20, 2026
@cjbell cjbell marked this pull request as ready for review March 20, 2026 21:09
Copy link
Copy Markdown
Contributor Author

cjbell commented Mar 20, 2026

Merge activity

  • Mar 20, 9:46 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 20, 9:47 PM UTC: @cjbell merged this pull request with Graphite.

@cjbell cjbell merged commit 88d2738 into main Mar 20, 2026
8 checks passed
@cjbell cjbell deleted the cjbell-KNO-12176-cli-translation-directory-detection-d20f branch March 20, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants