8000 feat(language): set or correct an asset's language as a BCP 47 tag with a region by adeelahmad · Pull Request #693 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(language): set or correct an asset's language as a BCP 47 tag with a region - #693

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-xfmkzn
Oct 19, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-xfmkzn

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: an asset's language was whatever transcription detected, shown upper-cased with no way to edit it, and transcribing again (or importing its text again) overwrote it. There was no region, so British and American English, or Brazilian and European Portuguese, looked the same.

After: editors set or correct an asset's language as a BCP 47 tag, with a region when it matters. It works from the Details tab (a pencil on the Language row; Enter saves, Escape cancels), through PATCH /api/v1/resources/<id> {"language": "en-gb"}, or with the MCP tool set_language. The tag is checked and written in its standard form (en-GB, zh-Hant-TW, es-419), and anything that isn't a tag gets a 400. A person's language is kept when the asset is transcribed or its text imported again; null forgets it so the next transcription detects it. The row reads like "British English (en-GB) · set by a person" or "… · detected". Changes are audited; the IIIF manifest and Dublin Core record carry the tag. A pipeline step's languages: ["en"] condition now matches en-GB and en-US too.

How: metadata.language_tag validates and normalizes; library.set_language stores it with a language_set flag; ingest.write_transcript keeps a person's language.

Motivation and Context

Item from the personal feature plan sheet (languages: no BCP 47 region).

Screenshots (if appropriate):

n/a

Steps to reproduce (if appropriate):

Open an English recording's Details tab, edit Language, type en-gb and press Enter: it shows "British English (en-GB) · set by a person". Transcribe it again: the language stays en-GB.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests (tests/api/test_language.py, tests/api/test_mcp.py, __tests__/recording-language.test.tsx).
  • My change requires documentation updates, and I have updated docs/ accordingly (docs/api.md#an-assets-language, docs/mcp.md, docs/processing.md, docs/database.md).
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md. Written as changelog.d/asset-language.md, per build(release): changelog fragments in changelog.d/ instead of one Unreleased section #581.

Done questions (AGENTS.md)

  • Goal: delivers what the user wanted, merged on green CI.
  • Agents: usable through the API, MCP or an assistant tool. PATCH /resources/<id> and MCP set_language; get_recording returns language_set.
  • Zero setup: no new prerequisite, .env edit or manual step.
  • Fewest clicks and keystrokes. Pencil, type, Enter; suggestions from the browser's languages.
  • Configurable: new settings in the web app with defaults; wizard asks only what is required. n/a: no settings.
  • Light: default install still runs on a Raspberry Pi with cloud models. A regex check; no registry download.
  • Private and secure: data local and encrypted, passkeys, threat model updated. A validated field on an existing editor-only route; no new surface.
  • Cost: cheapest path, model calls in the activity ledger, budgets respected. n/a: no model calls.
  • User decides: consequential or new actions wait for the user; defaults unchanged. A person's choice wins over detection; detected languages stay as they were.
  • Upgrades: existing installs upgrade safely (upgrade step for stored-data changes). language stays a string; language_set is a new field older rows simply lack (noted in docs/database.md).
  • Honest: sources cited; labelled built, in progress or planned. README built list and docs/requirements.md name the checks.
  • Tests, docs and generated files updated (make openapi).
  • Open standards; dependencies keep Lens MIT. BCP 47 language tags; no new dependencies.
  • Result reported with evidence; "refine later" items written down. Speech providers still report base codes (en), so a region comes from a person.
  • Reuse: existing Lens code and permissive libraries reused, nothing reinvented. Reuses the resource PATCH route, audit and the browser-language list from the Files tab.

Local CI: the container runs several times slower than usual, so I ran the changed tests directly: test_language.py, test_mcp.py, test_pipelines.py, test_translations.py (57 passed), recording-language and recording-translate jest (11 passed). ruff, mypy and tsc are clean, and make openapi shows no drift. GitHub CI decides the merge.


Generated by Claude Code

…th a region

The language transcription hears stays on the asset; editors can now set or
correct it as a BCP 47 tag (en-GB, pt-BR), validated and normalized, through
PATCH /resources/{id}, the MCP tool set_language and the Details tab. A
person's language (language_set) is kept when the asset is transcribed again;
null forgets it. Stored languages stay valid; the new field is only added.
The Language filter writes tags the usual way, and a pipeline condition on en
takes en-GB and en-US too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QFUNzy1QZy5HhKAyJxTAYJ
@adeelahmad adeelahmad self-assigned this Oct 19, 2026
@adeelahmad
adeelahmad merged commit 586bfdb into main Oct 19, 2026
12 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-xfmkzn branch October 19, 2026 17:12
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.

2 participants

0