Skip to main content

Language server for Python Babel i18n

Project description

babel-lsp

Language server for Python Babel i18n. Works with .py, Jinja templates, and .po/.pot catalog files.

Features

  • Diagnostics — 32 checks across source files, PO catalogs, and the whole project
  • Hover — translation table for any _("msgid") call
  • Completion — msgid completion in translation calls
  • Inlay hints — inline translation previews next to _() calls
  • Code actions — remove fuzzy flags, fill missing translations, rename msgid across all files
  • Go-to-definition / references / rename — treat msgids as first-class symbols
  • babel-lsp check — headless CLI linter, same rules as the LSP

Diagnostics

Code What it catches
msg/empty-id _("") — empty string is the catalog header sentinel
msg/fstring-in-call _(f"…") — f-string is interpolated before gettext sees it
msg/format-before-call _("…" % x) — format applied before gettext
msg/implicit-concat _("a" "b") — implicit string concatenation
msg/non-constant-id _(variable) — pybabel cannot extract non-literal ids
msg/unknown-id msgid not found in any catalog or template
msg/missing-in-locale msgid translated in some locales but empty in others
po/header-missing missing or incomplete catalog header
po/duplicate-id same msgid appears twice in one file
po/obsolete #~ entry absent from the .pot template
po/missing-translation empty msgstr in a .po file
po/fuzzy entry marked #, fuzzy
po/blank msgstr is whitespace-only
po/plural-count wrong number of plural forms vs. nplurals
po/same-plurals all plural forms are identical
po/format-mismatch printf/brace placeholder missing from translation
po/extra-variable translation has extra placeholders not in source
po/unchanged translation is identical to the source string
po/newline-count \n count differs between source and translation
po/whitespace-edges leading/trailing whitespace differs
po/end-punctuation trailing punctuation differs
po/double-space translation has double space not in source
po/repeated-word consecutive repeated word in translation
po/escape-mismatch backslash escape sequences differ
po/bracket-count bracket count differs
po/accelerator-mismatch & accelerator marker count differs
po/xml-tag-mismatch XML/HTML tag structure differs
po/url-changed URL from source is absent or path-altered
po/number-mismatch numeric literals differ
proj/inconsistent-translation same msgid translated differently in the same locale
proj/missing-locale-file a locale has .po for some domains but not all
proj/unused-id msgid exists in catalog but is never referenced in source

Installation

uv tool install babel-lsp

Or with pip:

pip install babel-lsp

Or download a pre-built binary from the releases page.

Configuration

Place a babel-lsp.toml (or pyproject.toml [tool.babel-lsp] section) at your project root.

# Directories to search for .po/.pot files (auto-detected if absent)
locale_dirs = ["locale"]

# Default locale for features that need one
default_locale = "en"

# Restrict to specific translation domains
# domains = ["messages", "admin"]

# Additional translation functions beyond the built-ins
# (_, gettext, ngettext, pgettext, npgettext, lazy_gettext, …)
extra_keywords = ["my_gettext"]

# Extensions treated as Jinja templates
jinja_extensions = [".html", ".jinja", ".jinja2", ".j2"]

# Locale to show in inlay hints (defaults to first alphabetical locale)
# inlay_hint_locale = "de"

# Path to pybabel (auto-discovered on PATH if absent)
# pybabel_path = "/path/to/pybabel"

[diagnostics]
# Run only these checks (default: all)
# select = ["po/fuzzy", "po/missing-translation"]

# Suppress specific checks
ignore = ["po/unchanged", "po/same-plurals"]

# Override severity per code
[diagnostics.severity]
"po/fuzzy" = "warning"
"proj/unused-id" = "hint"

[unchanged]
# msgids to skip for po/unchanged (e.g. single-word proper nouns)
ignore = ["OK", "PDF"]

CLI

# Check the current project
babel-lsp check

# Check specific paths
babel-lsp check locale/ src/

# Run only selected checks
babel-lsp check --select po/fuzzy,po/missing-translation

# Suppress checks
babel-lsp check --ignore po/unchanged

# Auto-fix what can be fixed (fuzzy flags, missing translations)
babel-lsp check --fix

# Output formats: concise (default), full, json, json-lines, grouped,
#                 github, gitlab, junit, pylint
babel-lsp check --output-format github

# Exit 0 even with findings (useful in pre-commit hooks that only annotate)
babel-lsp check --exit-zero

Editor Setup

Zed

Install from the Zed extensions panel (Cmd+Shift+X) — search for babel-lsp and click Install. It activates automatically for Python files.

To control server order alongside other language servers, add to ~/.config/zed/settings.json:

{
  "languages": {
    "Python": { "language_servers": ["babel-lsp", "..."] }
  }
}

Helix

Merge editors/helix/languages.toml into ~/.config/helix/languages.toml.

Neovim

Requires Neovim 0.11+. Add to your init.lua:

require("lspconfig").babel_lsp.setup {}

Or use the minimal snippet from editors/neovim/babel_lsp.lua.

Other editors

The server speaks standard LSP over stdio:

babel-lsp lsp --stdio

Fixtures

fixtures/ contains one minimal workspace per diagnostic code. Use them to verify diagnostics work or as templates for your own test setups:

babel-lsp check fixtures/po-fuzzy/
babel-lsp check fixtures/po-fuzzy/ --select po/fuzzy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

babel_lsp-0.2.1-py3-none-win_amd64.whl (2.7 MB view details)

Uploaded Python 3Windows x86-64

babel_lsp-0.2.1-py3-none-manylinux_2_28_x86_64.whl (2.7 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

babel_lsp-0.2.1-py3-none-manylinux_2_28_aarch64.whl (2.6 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

babel_lsp-0.2.1-py3-none-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

babel_lsp-0.2.1-py3-none-macosx_10_12_x86_64.whl (2.6 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file babel_lsp-0.2.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: babel_lsp-0.2.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for babel_lsp-0.2.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 52c03e547549dc165d33f4e28f250e20770fb21057ed53de794a629764484a98
MD5 d9ce267aad3cb60f41f80649eb84034b
BLAKE2b-256 693c02d4c90be6bd5c14c01239a6e7d0b8c21ce5e14759212c8353f18d2ed738

See more details on using hashes here.

File details

Details for the file babel_lsp-0.2.1-py3-none-manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: babel_lsp-0.2.1-py3-none-manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: Python 3, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for babel_lsp-0.2.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9d2ca45c5ff8e1218670c555bb3334705376274dfd7d018d142b60703464d2db
MD5 2bdc1ef835399537b43fde03d0566218
BLAKE2b-256 62508d9c61b68f5ee55c96e36395abc37b831c469cfc677f625e0bc3a4933b41

See more details on using hashes here.

File details

Details for the file babel_lsp-0.2.1-py3-none-manylinux_2_28_aarch64.whl.

File metadata

  • Download URL: babel_lsp-0.2.1-py3-none-manylinux_2_28_aarch64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: Python 3, manylinux: glibc 2.28+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for babel_lsp-0.2.1-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 af4cf306a5492de5223508c03e0b0646439abde2548aba294589a3044826038c
MD5 18e8767af93b01cf3be67c2c5e7d7cb3
BLAKE2b-256 9c87f2b04449ea661c0824760ca6f66f5be8365430941bb14c1eb8aa803c2945

See more details on using hashes here.

File details

Details for the file babel_lsp-0.2.1-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: babel_lsp-0.2.1-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for babel_lsp-0.2.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f4641fe7de1d4fa39a88d5cf4aaa89df7912897f34cb824805671b99e90de089
MD5 578ee7879809c71d304142531b657307
BLAKE2b-256 9ae640c15f64f1121d36ed0e81346e395b4ccd3e7ef8729f3219b6f03049d6f7

See more details on using hashes here.

File details

Details for the file babel_lsp-0.2.1-py3-none-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: babel_lsp-0.2.1-py3-none-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: Python 3, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for babel_lsp-0.2.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 54f5370a13845e0ff27933d4c89f4178469e615f5bd5678f2895fd88e00e2149
MD5 50555c24cd4ce305f4986d29067ce378
BLAKE2b-256 c1adef3fe2d609e265a507f1acdad5ca589c99cef6f0c692f39d9abe4bdf6cd1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page