Package: potojson
📦 potojsonPofile to JSON conversion without pain.StatusInstallationpipinstallpotojsonDocumentationAPI#pofile_to_json(content,fallback_to_msgid=False,fuzzy=False,pretty=False,indent=2,language=None,plural_forms=None,as_dict=False) ⇒strConverts a pofile passed as string or filepath and returns a JSON formatted
output. Given this pofile:##, fuzzymsgid""msgstr"""Language:es\n""Plural-Forms:nplurals=2; plural=n != 1;\n"msgid"msgid"msgstr"msgstr"msgctxt"msgctxt"msgid"msgid"msgstr"msgstr"msgid"msgid"msgid_plural"msgid_plural"msgstr[0]"msgstr[0]"msgstr[1]"msgstr[1]"msgctxt"msgctxt"msgid"msgid"msgid_plural"msgid_plural"msgstr[0]"msgstr[0]"msgstr[1]"msgstr[1]"... the output will be:{"":{"language":"es","plural-forms":"nplurals=2; plural=n != 1;",},"msgid":"msgstr","msgctxt":{"msgid":"msgstr",},"msgid":["msgstr[0]","msgstr[1]"],"msgctxt":{"msgid":["msgstr[0]","msgstr[1]"],}}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.sort_keys(bool) Sort dictionary by key. Combined withas_dictparameter, returns an instance ofcollections.OrderedDict.indent(int) Number of spaces for indentation used pretty-printing JSON
output. Only takes effect ifprettyis enabled.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 extracted from it.plural_forms(str) Plural forms for the language of the translations.
Will be inserted in the empty key of the JSON output. If not provided and the
passed pofile includes the "Plural-Forms" header, will be extracted from it.as_dict(bool) Returns the output as a Python dictionary.encoding(str) The encoding to use reading the pofile. By default will
be auto-detected.CLIusage: potojson [-h] [-v] [-m] [-f] [-p] [-k] [-i N] [-l LANGUAGE] [-s PLURAL_FORMS] [-e ENCODING] [PO_FILEPATH_OR_CONTENT ...]

Pofile to JSON conversion without pain.

positional arguments:
  PO_FILEPATH_OR_CONTENT
                        Path to pofile or pofile content as string. If the input file stream is interactive, will be read from STDIN.

options:
  -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.
  -k, --sort-keys       Sort JSON output by keys.
  -i N, --indent N      Number of spaces for indentation used pretty-printing JSON output. Only takes effect passing the "--pretty" 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 extracted from it.
  -s PLURAL_FORMS, --plural-forms PLURAL_FORMS
                        Plural forms for the language of the translations. Will be inserted in the empty key of the JSON output. If not provided and the passed pofile includes the "Plural-Forms" header, will be extracted from it.
  -e ENCODING, --encoding ENCODING
                        The encoding to use reading the pofile. By default will be auto-detected.