Metadata-Version: 2.1
Name: potojson
Version: 0.0.2
Summary: Pofile to JSON conversion without pain.
Home-page: https://github.com/mondeja/potojson
Author: Álvaro Mondéjar Rubio
Author-email: mondejar1994@gmail.com
License: BSD License
Project-URL: Documentation, https://github.com/mondeja/potojson/blob/master/README.md
Project-URL: GitHub Project, https://github.com/mondeja/potojson
Project-URL: Issue Tracker, https://github.com/mondeja/potojson/issues
Platform: UNKNOWN
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Internationalization
Classifier: Topic :: Text Processing
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: polib (>=1.1.0)
Provides-Extra: dev
Requires-Dist: twine ; extra == 'dev'
Requires-Dist: bump2version ; extra == 'dev'
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: flake8-print ; extra == 'dev'
Requires-Dist: flake8-implicit-str-concat ; extra == 'dev'
Requires-Dist: isort ; extra == 'dev'
Requires-Dist: tox ; extra == 'dev'
Provides-Extra: test
Requires-Dist: pytest ; extra == 'test'
Requires-Dist: pytest-cov ; extra == 'test'
Requires-Dist: flake8 ; extra == 'test'
Requires-Dist: flake8-print ; extra == 'test'
Requires-Dist: flake8-implicit-str-concat ; extra == 'test'
Requires-Dist: isort ; extra == 'test'
Requires-Dist: tox ; extra == 'test'


# 📦 potojson

[![PyPI](https://img.shields.io/pypi/v/potojson)](https://pypi.org/project/potojson/) [![Tests](https://img.shields.io/travis/mondeja/potojson?label=tests&logo=travis)](https://travis-ci.com/github/mondeja/potojson) [![Coveralls](https://img.shields.io/coveralls/github/mondeja/potojson?logo=coveralls)](https://coveralls.io/github/mondeja/potojson)

Pofile to JSON conversion without pain.

## Installation

```bash
pip install potojson
```

## Documentation

### API

<a name="pofile_to_json" href="#pofile_to_json">#</a> <b>pofile_to_json</b>(<i>content</i>, <i>fallback_to_msgid=False</i>, <i>fuzzy=False</i>, <i>pretty=False</i>, <i>indent=2</i>, <i>language=None</i>, <i>plural_forms=None</i>) ⇒ `str`

Converts a pofile passed as string or filepath and returns a JSON formatted output with next style:

```json
{
  "": {
    "language": "es",
    "plural-forms": "nplurals=2; plural=n != 1;",
  },
  "msgid": "msgstr",
  "msgctxt": {
    "msgid": "msgstr",
  },
  "msgid": ["msgstr[0]", "msgstr[1]", "msgstr[2]"],
  "msgctxt": {
    "msgid": ["msgstr[0]", "msgstr[1]", "msgstr[2]"],
  }
}
```

This output can be customized tuning the parameters of the function.

- **content** (str) Content or filepath of the pofile to convert.
- **fallback_to_msgid** (bool) Use msgid if translation is missing.
- **fuzzy** (bool) Include fuzzy messages.
- **pretty** (bool) Pretty-print JSON output.
- **indent** (int) Number of spaces for indentation used pretty-printing JSON output. Only takes effect if ``pretty is True``.
- **language** (str) Language for the translations. Will be inserted in the empty key of the JSON output. If not provided and the passed pofile includes the "Language" header, will be extrated from it.
- **plural_forms** (str) Plural forms for the language of the translations. Will be insertedin the empty key of the JSON output. If not provided and the passed pofile includes the "Plural-Forms" header, will be extrated from it.

### CLI

```
usage: potojson [-h] [-v] [-m] [-f] [-p] [-i N] [-l LANGUAGE] [-s PLURAL_FORMS] PO_FILEPATH_OR_CONTENT

Pofile to JSON conversion without pain.

positional arguments:
  PO_FILEPATH_OR_CONTENT
                        Path to pofile or pofile content as a string. If not provided, will be read from STDIN.

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         Show program version number and exit.
  -m, --fallback-to-msgid
                        Use msgid if translation is missing.
  -f, --fuzzy           Include fuzzy messages.
  -p, --pretty          Pretty-print JSON output.
  -i N, --indent N      Number of spaces for indentation used pretty-printing JSON output. Only takes effect passing '--fuzzy' option.
  -l LANGUAGE, --language LANGUAGE
                        Language for the translations. Will be inserted in the empty key of the JSON output. If not provided and the passed pofile includes the "Language" header, will be extrated from it.
  -s PLURAL_FORMS, --plural-forms PLURAL_FORMS
                        Plural forms for the language of the translations. Will be insertedin the empty key of the JSON output. If not provided and the passed pofile includes the "Plural-Forms" header, will be extrated from it.
```

