pybabel-angularjs
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_attributechanges the marker from the defaulti18n, for example todata-translate.include_tagsextracts all content from the listed tags without requiring an explicit marker.include_attributesextracts the listed attributes wherever they occur.allowed_tagscontrols which nested HTML tags may appear inside a translated message. The default isstrong, br, i.allowed_attributes_<tag>controls attributes allowed on a nested tag, for exampleallowed_attributes_a = href, target.encodingcontrols template decoding and defaults toutf-8.include_format_flagsmakes the extractor return an extended five-value result and marks messages containing AngularJS interpolation withangularjs-format. It defaults tofalsebecause 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5353c6ade0af1f642ecb7cf9fd581e26a94eedb9f04ae0bf1b0b9ac88e5c1d6f
|
|
| MD5 |
e4b26462003024f2d39f64cc121dae30
|
|
| BLAKE2b-256 |
9ce50d1d89c8450df036569cf2cd16f1ca3aae15acac10ffada28f600b5b62e8
|
Provenance
The following attestation bundles were made for pybabel_angularjs-1.5.0.tar.gz:
Publisher:
release.yml on chuckyblack/pybabel-angularjs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybabel_angularjs-1.5.0.tar.gz -
Subject digest:
5353c6ade0af1f642ecb7cf9fd581e26a94eedb9f04ae0bf1b0b9ac88e5c1d6f - Sigstore transparency entry: 2339211237
- Sigstore integration time:
-
Permalink:
chuckyblack/pybabel-angularjs@ea8260b8b30fd8a1a1e92c1cfb40fcdd2fd23d5b -
Branch / Tag:
refs/tags/v1.5.0 - Owner: https://github.com/chuckyblack
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ea8260b8b30fd8a1a1e92c1cfb40fcdd2fd23d5b -
Trigger Event:
push
-
Statement type:
File details
Details for the file pybabel_angularjs-1.5.0-py3-none-any.whl.
File metadata
- Download URL: pybabel_angularjs-1.5.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6f2e107d002cac208c1cdaba03543a00a332e48563ae0931fd8c601cbd3e479
|
|
| MD5 |
4bf4e35c6b06a7963c8a580108a8f057
|
|
| BLAKE2b-256 |
77bda62e3518cd92e37bbc95e4efe1264101711e96d7ab14d4a3be26a222e1d2
|
Provenance
The following attestation bundles were made for pybabel_angularjs-1.5.0-py3-none-any.whl:
Publisher:
release.yml on chuckyblack/pybabel-angularjs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybabel_angularjs-1.5.0-py3-none-any.whl -
Subject digest:
f6f2e107d002cac208c1cdaba03543a00a332e48563ae0931fd8c601cbd3e479 - Sigstore transparency entry: 2339211248
- Sigstore integration time:
-
Permalink:
chuckyblack/pybabel-angularjs@ea8260b8b30fd8a1a1e92c1cfb40fcdd2fd23d5b -
Branch / Tag:
refs/tags/v1.5.0 - Owner: https://github.com/chuckyblack
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ea8260b8b30fd8a1a1e92c1cfb40fcdd2fd23d5b -
Trigger Event:
push
-
Statement type: