Metadata-Version: 2.4
Name: pybabel-angularjs
Version: 1.5.0
Summary: An AngularJS extractor for Babel
Author-email: Jaromír Pufler <jaromir.pufler@gmail.com>
License: Apache Software License
Project-URL: Homepage, https://github.com/chuckyblack/pybabel-angularjs
Keywords: angularjs,gettext,babel,i18n,translate
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Internationalization
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: babel
Dynamic: license-file

# pybabel-angularjs

[![CI](https://github.com/chuckyblack/pybabel-angularjs/actions/workflows/release.yml/badge.svg?branch=master)](https://github.com/chuckyblack/pybabel-angularjs/actions/workflows/release.yml)
[![PyPI](https://img.shields.io/pypi/v/pybabel-angularjs.svg)](https://pypi.org/project/pybabel-angularjs/)

A [Babel](https://babel.pocoo.org/) 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

```console
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`:

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

Then extract messages in the usual way:

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

## Marking messages

Mark an element's content with `i18n`:

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

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

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

Mark an individual attribute by adding the `i18n-` prefix:

```html
<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.

```ini
[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](https://bitbucket.org/shoreware/pybabel-angularjs).
