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
  • 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.

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.4.0.tar.gz (9.2 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.4.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pybabel_angularjs-1.4.0.tar.gz
  • Upload date:
  • Size: 9.2 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.4.0.tar.gz
Algorithm Hash digest
SHA256 8a42099a309d5e4a1fc8db39cb4149aaeb30c72e4f994a9d50481cf596c62016
MD5 6c5cd435ace883cfe2e0299d1e9ad839
BLAKE2b-256 f8b5b5d54108056a01d0265cb4f46e99af13cd8e0a9410bf341ec6d2660e795e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pybabel_angularjs-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 84ebb16ad779c02247594a7c134358442c498eb195b34e21c512e2b8884d87f0
MD5 c3c7f4c6b26a12635ba5e8902a955ed2
BLAKE2b-256 e341f1629bbbb4437056ab6347551e5c740596b74f34d42e2befb1a53b45077e

See more details on using hashes here.

Provenance

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

1.5.0

2 files

This release

1.4.0 This release

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