sanpo


Namesanpo JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/roskakori/sanpo
SummarySanitize PO files from gettext for version control
upload_time2023-08-23 20:24:29
maintainer
docs_urlNone
authorThomas Aglassinger
requires_python>=3.8,<4.0.0
licenseBSD
keywords clean gettext po sanitize
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI](https://img.shields.io/pypi/v/sanpo)](https://pypi.org/project/sanpo/)
[![Python Versions](https://img.shields.io/pypi/pyversions/sanpo.svg)](https://www.python.org/downloads/)
[![Build Status](https://github.com/roskakori/sanpo/actions/workflows/build.yaml/badge.svg)](https://github.com/roskakori/sanpo/actions/workflows/build.yaml)
[![Test Coverage](https://img.shields.io/coveralls/github/roskakori/sanpo)](https://coveralls.io/r/roskakori/sanpo?branch=main)
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![License](https://img.shields.io/github/license/roskakori/sanpo)](https://opensource.org/licenses/BSD-3-Clause)

# sanpo

`sanpo` is a command line tool to sanitize PO files from gettext for version
control.

## The problem

The [gettext](https://www.gnu.org/software/gettext/) tool collects text to be
translated from source code in PO files that can be sent to translators. These
files contain metadata about the project that can be helpful when using an
email based workflow.

When creating a PO file the first time, these metadata look like this:

```
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-09-06 16:16+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
```

However, when having the PO file under version control, these metadata get in
the way. Most of them are available from the commit history. And when
running `gettext` automatically as part of the build process, the
`PO-Revision-Date` gets updated every time even if none of the messages
changed, resulting in spuriously modified PO files without any actual
changes worth committing.

## The solution

Because your localized software does not use the PO files directly but the MO
files compiled from them, the unhelpful metadata can be removed. Which is
exactly what `sanpo` does.

A typical build chain would look like this:

1. gettext - collect PO file
2. msgfmt - compile into MO file
3. sanpo - remove unhelpful metadata from PO
4. commit possible changes in PO file

`sanpo` simple takes one or more PO files as argument, for example:

```bash
sanpo locale/de/LC_MESSAGES/django.po locale/en/LC_MESSAGES/django.po locale/hu/LC_MESSAGES/django.po
```

After this, the remaining metadata are:

```
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
```

Using the special pattern `**` folders can be scanned recursively.

To sanitize PO files for all languages in a certain folder, use for example:

```bash
sanpo locale/**/django.po
```

## Django

For [Django](https://www.djangoproject.com/) projects, the typical workflow
is:

1. django-admin makemessages
2. django-admin compilemessages
3. sanpo
4. commit possible changes in PO file

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/roskakori/sanpo",
    "name": "sanpo",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0.0",
    "maintainer_email": "",
    "keywords": "clean,gettext,po,sanitize",
    "author": "Thomas Aglassinger",
    "author_email": "roskakori@users.sourceforge.net",
    "download_url": "https://files.pythonhosted.org/packages/93/ba/0c8cbd0e65884bdd7a6c06d620f6461ee172b50e43643b08241155378886/sanpo-0.2.1.tar.gz",
    "platform": null,
    "description": "[![PyPI](https://img.shields.io/pypi/v/sanpo)](https://pypi.org/project/sanpo/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/sanpo.svg)](https://www.python.org/downloads/)\n[![Build Status](https://github.com/roskakori/sanpo/actions/workflows/build.yaml/badge.svg)](https://github.com/roskakori/sanpo/actions/workflows/build.yaml)\n[![Test Coverage](https://img.shields.io/coveralls/github/roskakori/sanpo)](https://coveralls.io/r/roskakori/sanpo?branch=main)\n[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![License](https://img.shields.io/github/license/roskakori/sanpo)](https://opensource.org/licenses/BSD-3-Clause)\n\n# sanpo\n\n`sanpo` is a command line tool to sanitize PO files from gettext for version\ncontrol.\n\n## The problem\n\nThe [gettext](https://www.gnu.org/software/gettext/) tool collects text to be\ntranslated from source code in PO files that can be sent to translators. These\nfiles contain metadata about the project that can be helpful when using an\nemail based workflow.\n\nWhen creating a PO file the first time, these metadata look like this:\n\n```\n\"Project-Id-Version: PACKAGE VERSION\\n\"\n\"Report-Msgid-Bugs-To: \\n\"\n\"POT-Creation-Date: 2021-09-06 16:16+0200\\n\"\n\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"\n\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n\"\n\"Language-Team: LANGUAGE <LL@li.org>\\n\"\n\"Language: \\n\"\n\"MIME-Version: 1.0\\n\"\n\"Content-Type: text/plain; charset=UTF-8\\n\"\n\"Content-Transfer-Encoding: 8bit\\n\"\n\"Plural-Forms: nplurals=2; plural=(n != 1);\\n\"\n```\n\nHowever, when having the PO file under version control, these metadata get in\nthe way. Most of them are available from the commit history. And when\nrunning `gettext` automatically as part of the build process, the\n`PO-Revision-Date` gets updated every time even if none of the messages\nchanged, resulting in spuriously modified PO files without any actual\nchanges worth committing.\n\n## The solution\n\nBecause your localized software does not use the PO files directly but the MO\nfiles compiled from them, the unhelpful metadata can be removed. Which is\nexactly what `sanpo` does.\n\nA typical build chain would look like this:\n\n1. gettext - collect PO file\n2. msgfmt - compile into MO file\n3. sanpo - remove unhelpful metadata from PO\n4. commit possible changes in PO file\n\n`sanpo` simple takes one or more PO files as argument, for example:\n\n```bash\nsanpo locale/de/LC_MESSAGES/django.po locale/en/LC_MESSAGES/django.po locale/hu/LC_MESSAGES/django.po\n```\n\nAfter this, the remaining metadata are:\n\n```\n\"Language: \\n\"\n\"MIME-Version: 1.0\\n\"\n\"Content-Type: text/plain; charset=UTF-8\\n\"\n\"Content-Transfer-Encoding: 8bit\\n\"\n\"Plural-Forms: nplurals=2; plural=(n != 1);\\n\"\n```\n\nUsing the special pattern `**` folders can be scanned recursively.\n\nTo sanitize PO files for all languages in a certain folder, use for example:\n\n```bash\nsanpo locale/**/django.po\n```\n\n## Django\n\nFor [Django](https://www.djangoproject.com/) projects, the typical workflow\nis:\n\n1. django-admin makemessages\n2. django-admin compilemessages\n3. sanpo\n4. commit possible changes in PO file\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Sanitize PO files from gettext for version control",
    "version": "0.2.1",
    "project_urls": {
        "Changes": "https://github.com/roskakori/sanpo/blob/main/CHANGES.md",
        "Homepage": "https://github.com/roskakori/sanpo",
        "Issue Tracker": "https://github.com/roskakori/sanpo/issues",
        "Repository": "https://github.com/roskakori/sanpo.git"
    },
    "split_keywords": [
        "clean",
        "gettext",
        "po",
        "sanitize"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "352c2c6c9fdee1336ea68d1246dbf4e5bd9644544b82ad404d23e2f82bd1c7f5",
                "md5": "e2d317baaee92e09a7f70d3d60f0efe1",
                "sha256": "15c84198fccdfd318cce9309cf98c942d18ea2a6cea1d1245f96b4c883b4567c"
            },
            "downloads": -1,
            "filename": "sanpo-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e2d317baaee92e09a7f70d3d60f0efe1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0.0",
            "size": 5701,
            "upload_time": "2023-08-23T20:24:27",
            "upload_time_iso_8601": "2023-08-23T20:24:27.770729Z",
            "url": "https://files.pythonhosted.org/packages/35/2c/2c6c9fdee1336ea68d1246dbf4e5bd9644544b82ad404d23e2f82bd1c7f5/sanpo-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "93ba0c8cbd0e65884bdd7a6c06d620f6461ee172b50e43643b08241155378886",
                "md5": "0f5a808e0e61826eee2025d99dddfe43",
                "sha256": "8a90ab5497af1033a530a9d99f1063ef12ebd467ddafa042bf083c815ada5116"
            },
            "downloads": -1,
            "filename": "sanpo-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0f5a808e0e61826eee2025d99dddfe43",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0.0",
            "size": 4806,
            "upload_time": "2023-08-23T20:24:29",
            "upload_time_iso_8601": "2023-08-23T20:24:29.486046Z",
            "url": "https://files.pythonhosted.org/packages/93/ba/0c8cbd0e65884bdd7a6c06d620f6461ee172b50e43643b08241155378886/sanpo-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-23 20:24:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "roskakori",
    "github_project": "sanpo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "sanpo"
}
        
Elapsed time: 0.10328s