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.0-py3-none-win_amd64.whl (2.7 MB view details)

Uploaded Python 3Windows x86-64

babel_lsp-0.2.0-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.0-py3-none-manylinux_2_28_aarch64.whl (2.6 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

babel_lsp-0.2.0-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.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: babel_lsp-0.2.0-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.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 5de0834cb5ec743b71257e1431505bfe002bdd442a905fdd58ef3b972cc42a45
MD5 64c958113877fe2b37e0b0d54e72f125
BLAKE2b-256 9efbc7b7fd51c53607a95f1773f4c490c689f9f34d8e913124bdd1d9876fe36f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: babel_lsp-0.2.0-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.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9305f1935459ea3360bec51d744ec0c067720739b500eec478ee0f224cace502
MD5 6cc8da6626467eab2ea668c26cc0c9ee
BLAKE2b-256 bb2b65d6d58ee348581e589c9e4288043fb0a52ea0f71907ae421ee98f4ab849

See more details on using hashes here.

File details

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

File metadata

  • Download URL: babel_lsp-0.2.0-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.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e2930957066762cf203da1b3d5ea30a8d64ab700d03059d7dde70fef9c3b7613
MD5 7cdcede96ba2e5da7708fd24379d3868
BLAKE2b-256 0a076c1340afe087afb6efa3255c01c00e7a70d8d7636c691b6425a0ddbfb561

See more details on using hashes here.

File details

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

File metadata

  • Download URL: babel_lsp-0.2.0-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.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93d9f38655d60b16c9d89b00bd587c6cc028bb17807cedf333e10ef368f5a1fe
MD5 0d91a968885676d21edc1df80415220a
BLAKE2b-256 33bf7f1f6fbf1f5286894976d30da2dd256c98510c39bc1f9386a74e00ca20cf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: babel_lsp-0.2.0-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.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f4068638e8bc774d79ac04f3c87eec546307d457d64bfef76ae609a55a588c07
MD5 2eb2595415d2aeba8b94e6e0f891d238
BLAKE2b-256 a8b35faf623fe2e2a51688a0884a6e113574c97b3f2dbbd5646d8be652b8942c

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