[![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": null,
"docs_url": null,
"requires_python": "<4.0.0,>=3.9",
"maintainer_email": null,
"keywords": "clean, gettext, po, sanitize",
"author": "Thomas Aglassinger",
"author_email": "roskakori@users.sourceforge.net",
"download_url": "https://files.pythonhosted.org/packages/6f/37/7b8ff5ee4af98e1ce7c695554b62be394f9bbab3dda384dc12e78a6af469/sanpo-0.2.2.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.2",
"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": "b2e53dc27cc9fff4bd757d0ec74ecf317755c0f93b3134696e188a24b8f2f556",
"md5": "ec46c9396ec9037ac2760956613dcf3d",
"sha256": "4a7421b26f967c2d3512ddd9774c1263665279fc6b05a6d8592fbe3ac4897505"
},
"downloads": -1,
"filename": "sanpo-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ec46c9396ec9037ac2760956613dcf3d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0.0,>=3.9",
"size": 5705,
"upload_time": "2024-12-10T14:57:49",
"upload_time_iso_8601": "2024-12-10T14:57:49.746978Z",
"url": "https://files.pythonhosted.org/packages/b2/e5/3dc27cc9fff4bd757d0ec74ecf317755c0f93b3134696e188a24b8f2f556/sanpo-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6f377b8ff5ee4af98e1ce7c695554b62be394f9bbab3dda384dc12e78a6af469",
"md5": "c59cd3e00427a0ecab86ff14cb3c5345",
"sha256": "a2a1ffcb14ff37095b79ea34695e51246ad10cb8eb5a314944c145ce51aaa18d"
},
"downloads": -1,
"filename": "sanpo-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "c59cd3e00427a0ecab86ff14cb3c5345",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0.0,>=3.9",
"size": 4806,
"upload_time": "2024-12-10T14:57:59",
"upload_time_iso_8601": "2024-12-10T14:57:59.474524Z",
"url": "https://files.pythonhosted.org/packages/6f/37/7b8ff5ee4af98e1ce7c695554b62be394f9bbab3dda384dc12e78a6af469/sanpo-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-10 14:57:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "roskakori",
"github_project": "sanpo",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "sanpo"
}