Skip to main content

An AngularJS extractor for Babel

Project description


[![Build Status](](

A Babel extractor for AngularJS templates.

To translate the content of an HTML element use the `i18n`

<div i18n>hello world!</div>

To give somme context to your translators add value to the attribute:

<div i18n="page title">hello world!</div>

## Babel configuration

### extract_attribute

To change default `i18n` attribute use `extract_attribute` options:

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

Then use in template:

<div translate="page title">hello world!</div>

### include_attributes

To translate attributes of HTML nodes use `include_attributes` options:

[angularjs: **/*.html]
encoding = utf-8
include_attributes = title, alt

Then use in template:

<div title="some title">hello world!</div>
<img src="..." alt="some image description">

### allowed_tags

Content of every translated tag is checked for tags it contains. You have to define sub-tags that can occur.
Tags allowed by default are: strong, br, i

[angularjs: **/*.html]
encoding = utf-8
allowed_tags = a, strong, br

### allowed_attributes_x

Sub-tags (described in 'allowed_tags') may by default contain NO attributes at all.
If you want to enable them to, you have to use this notation:

[angularjs: **/*.html]
encoding = utf-8
allowed_tags = a, i
allowed_attributes_a = href
allowed_attributes_i = class

The allowed_attribues_x setting needs to be accompanied by appropriate 'allowed_tags' setting.

Heavily inspired by

Project details

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.3.5.tar.gz (8.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page