Skip to main content

pybabel-angularjs

CI PyPI

A Babel message extractor for AngularJS HTML templates. It extracts element content and attributes marked for translation, including strings containing AngularJS expressions such as {{ name }}.

Requires Python 3.12 or newer.

Installation

python -m pip install pybabel-angularjs

The package installs the angularjs Babel extractor entry point. Add it to a Babel mapping file such as babel.cfg:

[angularjs: **/*.html]
encoding = utf-8

Then extract messages in the usual way:

pybabel extract -F babel.cfg -o messages.pot .

Marking messages

Mark an element's content with i18n:

<div i18n>Hello world!</div>
<p i18n>Hello {{ name }}!</p>

The value of i18n, when present, is included as a comment for translators:

<h1 i18n="Page heading">Welcome</h1>

Mark an individual attribute by adding the i18n- prefix:

<input placeholder="Your name" i18n-placeholder>

Configuration

Options are set in the extractor section of the Babel mapping file. Lists can be separated by commas or whitespace.

[angularjs: **/*.html]
encoding = utf-8
include_tags = h1, h2, p
include_attributes = title, alt, placeholder
allowed_tags = a, strong, br, i
allowed_attributes_a = href, target
include_format_flags = false
  • extract_attribute changes the marker from the default i18n, for example to data-translate.
  • include_tags extracts all content from the listed tags without requiring an explicit marker.
  • include_attributes extracts the listed attributes wherever they occur.
  • allowed_tags controls which nested HTML tags may appear inside a translated message. The default is strong, br, i.
  • allowed_attributes_<tag> controls attributes allowed on a nested tag, for example allowed_attributes_a = href, target.
  • encoding controls template decoding and defaults to utf-8.
  • include_format_flags makes the extractor return an extended five-value result and marks messages containing AngularJS interpolation with angularjs-format. It defaults to false because official Babel releases accept only the standard four-value extractor result. Enable it only with a Babel build that explicitly supports extractor-provided flags.

Use no-i18n to exclude an automatically included tag. A <div no-i18n> excludes its entire subtree. For automatically included attributes, use the corresponding marker such as no-i18n-title.

License

Apache License 2.0. The project was heavily inspired by the original shoreware/pybabel-angularjs.

Download files

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

Source Distribution

pybabel_angularjs-1.5.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

pybabel_angularjs-1.5.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file pybabel_angularjs-1.5.0.tar.gz.

File metadata

  • Download URL: pybabel_angularjs-1.5.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pybabel_angularjs-1.5.0.tar.gz
Algorithm Hash digest
SHA256 5353c6ade0af1f642ecb7cf9fd581e26a94eedb9f04ae0bf1b0b9ac88e5c1d6f
MD5 e4b26462003024f2d39f64cc121dae30
BLAKE2b-256 9ce50d1d89c8450df036569cf2cd16f1ca3aae15acac10ffada28f600b5b62e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybabel_angularjs-1.5.0.tar.gz:

Publisher: release.yml on chuckyblack/pybabel-angularjs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pybabel_angularjs-1.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pybabel_angularjs-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6f2e107d002cac208c1cdaba03543a00a332e48563ae0931fd8c601cbd3e479
MD5 4bf4e35c6b06a7963c8a580108a8f057
BLAKE2b-256 77bda62e3518cd92e37bbc95e4efe1264101711e96d7ab14d4a3be26a222e1d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybabel_angularjs-1.5.0-py3-none-any.whl:

Publisher: release.yml on chuckyblack/pybabel-angularjs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.5.1

2 files

This release

1.5.0 This release

2 files

1.4.0

2 files

1.3.5

1 file

1.3.3

1 file

1.3.0

1 file

1.2.0

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page