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.1.tar.gz (9.9 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.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pybabel_angularjs-1.5.1.tar.gz
  • Upload date:
  • Size: 9.9 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.1.tar.gz
Algorithm Hash digest
SHA256 8851cd66060722667d068352fe44a55161e8165f65617329bd78dd64da1e3da1
MD5 be82759820e45e44a8b2c63de5b96e81
BLAKE2b-256 d76eaf203671e8ca3ab9491e4635a6e060487102b89f413e8a486b8e2f529d75

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybabel_angularjs-1.5.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pybabel_angularjs-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eb3210d8b4267d33fb09de6719e3e40cc64ac8294576109b9bc08ca9174d7780
MD5 59326d248ce476a76cc32778bab9a496
BLAKE2b-256 8478627264bdec9c3a07c262db340223ad39e0aa5edcb87e1bc6c944e4f7304a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybabel_angularjs-1.5.1-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

This release

1.5.1 This release

2 files

1.5.0

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