Skip to content

An extractor for producing translation strings from a yaml file.

License

Notifications You must be signed in to change notification settings

giellatekno/babel-yaml

Repository files navigation

Python Babel YAML Extractor

https://badge.fury.io/py/babel_yaml.png https://travis-ci.org/rtxanson/babel_yaml.png?branch=master https://pypip.in/d/babel_yaml/badge.png

Provides an extractor for producing translation strings from a yaml file. Very rough 'cause I needed itt in little time, so feel free to submit fixes and such.

Features

  • Extracts strings from .yaml to .po files!

Not supported

  • Extracting translator comments (TODO: this)

Usage

Recommended to define a custom yaml constructor so that you can easily mark strings you want to be extracted:

def gettext_yaml_wrapper(loader, node):
    return node.value

yaml.add_constructor('!gettext', gettext_yaml_wrapper)

Note that this isn't necessary for the actual extraction process, but it will be necessary for whatever capacity you're using the YAML files in.

Then add stuff to your babel.cfg:

[extractors]
yaml = babel_yaml.yamlextractor:extract_yaml
[yaml: **/tests/**.yaml]
keywords = !gettext

Then you should be able to extract this stuff.

About

An extractor for producing translation strings from a yaml file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published