hatch-gettext


Namehatch-gettext JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummaryHatch build hook plugin for GNU gettext
upload_time2024-04-24 03:25:29
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords build gettext hatch i18n plugin typing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Hatch Gettext

| |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| --- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Package | [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hatch-gettext.svg)](https://pypi.org/project/hatch-gettext) [![PyPI - Version](https://img.shields.io/pypi/v/hatch-gettext.svg)](https://pypi.org/project/hatch-gettext)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Meta | [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![GitButler](https://img.shields.io/badge/GitButler-%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BCjxzdG9wIG9mZnNldD0iMSIvPgo8L3JhZGlhbEdyYWRpZW50Pgo8L2RlZnM%2BCjwvc3ZnPgo%3D)](https://gitbutler.com/) [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![GitHub Sponsors](https://img.shields.io/github/sponsors/damonlynch?logo=GitHub%20Sponsors&style=social)](https://github.com/sponsors/damonlynch)  |


-----

This provides a [build hook](https://hatch.pypa.io/latest/config/build/#build-hooks) plugin 
for [Hatch](https://github.com/pypa/hatch) that compiles multi-lingual messages with GNU 
gettext's tools `msgfmt`. It can also (optionally) use `intltool` to: 
- translate .xml and .desktop files
- search for left out files
- regenerate the .pot template 
- display a status report for all translations

**Table of Contents**

<!-- TOC -->
* [Hatch Gettext](#hatch-gettext)
  * [Configuration](#configuration)
    * [Calling the plugin](#calling-the-plugin)
    * [Compiling messages with msgfmt](#compiling-messages-with-msgfmt)
    * [Identifying left out files using intltool-update](#identifying-left-out-files-using-intltool-update)
    * [Regenerating the .pot template using intltool-update](#regenerating-the-pot-template-using-intltool-update)
    * [Displaying a status report using intltool-update](#displaying-a-status-report-using-intltool-update)
    * [Translating files using intltool-merge](#translating-files-using-intltool-merge)
  * [Cleaning output files](#cleaning-output-files)
  * [Related Hatch plugin](#related-hatch-plugin)
  * [License](#license)
<!-- TOC -->

## Configuration

The [build hook plugin](https://hatch.pypa.io/latest/plugins/build-hook/) 
name is `gettext`.

### Calling the plugin

Modify `pyproject.toml` to include the plugin as a build dependency:

```toml
[build-system]
requires = ["hatchling", "hatch-gettext"]
build-backend = "hatchling.build"
```

### Compiling messages with msgfmt
 
This plugin requires `.mo` files be created; it also requires that the 
directory storing them is within the project's base directory, and is not 
equal to the project's base directory or the directory in which `po` files
are sourced. The mo file directory is set using `locale-directory`, which is 
required. 

For example, for a project named `myproject`, and a src layout 
`src/myproject`, an acceptable directory in which to store the 
`LC_MESSAGES/myproject.mo` files would be `src/myproject/locale`

```toml
[tool.hatch.build.hooks.gettext]
locale-directory = "src/myproject/locale"
```

Optionally, specify values for the gexttext output name
and the source directory where po files are found:

```toml
[tool.hatch.build.hooks.gettext]
locale-directory = "src/myproject/locale"
i18n-name = "myproject" 
po-directory = "po-files"
```

If `i18n-name` is not specified, the `name` in `[project]` in the 
`pyproject.toml` is used. If `po-directory` is not specified, the 
directory `po` is used.

### Identifying left out files using intltool-update

With every source distribution (sdist) build, to search for left out files, 
which should have been listed in `POTFILES.in` or `POTFILES.skip`, set 
`identify-left-out` to true (the default value is false):

```toml
[tool.hatch.build.hooks.gettext]
locale-directory = "src/myproject/locale"
identify-left-out = true
```

### Regenerating the .pot template using intltool-update

To regenerate the .pot template with every sdist build, set 
`regenerate-template` to true (the default value is false):

```toml
[tool.hatch.build.hooks.gettext]
locale-directory = "src/myproject/locale"
regenerate-template = true
```

### Displaying a status report using intltool-update

To display a status report for all translations, set `show-report` to true 
(the default value is false):

```toml
[tool.hatch.build.hooks.gettext]
locale-directory = "src/myproject/locale"
show-report = true
```

### Translating files using intltool-merge

This plugin allows for but does not mandate translating `.xml` and 
`.desktop` files using `intltool-merge`. Using 
`[tool.hatch.build.hooks.gettext.files]`, specify the destination directories
for the translated files using keys, and arrays of source files as values. For 
example:  

```toml
[tool.hatch.build.hooks.gettext.files]
"share/applications" = ["data/net.myproject.desktop.in"]
"share/solid/actions" = ["data/kde/net.myproject.desktop.in"]
"share/metainfo" = ["data/net.myproject.metainfo.xml.in"]
```

## Cleaning output files

The plugin includes logic to remove the files it outputs using hatch's
`clean` hook. As well as individual files, any output directories created 
will also be removed, as long as these directories do not contain files 
created by something other than this plugin.

## Related Hatch plugin

To automatically generate a manual page from an `ArgumentParser` object,
see [hatch-argparse-manpage](https://github.com/damonlynch/hatch-argparse-manpage).

## License

`hatch-gettext` is distributed under the terms of the [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later.html) license.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hatch-gettext",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "build, gettext, hatch, i18n, plugin, typing",
    "author": null,
    "author_email": "Damon Lynch <damonlynch@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/cd/b2/4d4832953d048af2c6cf6e56c5dc50cd2b661848c05346d7c13702ead6fa/hatch_gettext-1.1.0.tar.gz",
    "platform": null,
    "description": "# Hatch Gettext\n\n| |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| --- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Package | [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hatch-gettext.svg)](https://pypi.org/project/hatch-gettext) [![PyPI - Version](https://img.shields.io/pypi/v/hatch-gettext.svg)](https://pypi.org/project/hatch-gettext)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| Meta | [![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercont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LjgzODMpIj4KPHN0b3Agb2Zmc2V0PSIwLjMwMTA1NiIgc3RvcC1vcGFjaXR5PSIwIi8%2BCjxzdG9wIG9mZnNldD0iMSIvPgo8L3JhZGlhbEdyYWRpZW50Pgo8L2RlZnM%2BCjwvc3ZnPgo%3D)](https://gitbutler.com/) [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![GitHub Sponsors](https://img.shields.io/github/sponsors/damonlynch?logo=GitHub%20Sponsors&style=social)](https://github.com/sponsors/damonlynch)  |\n\n\n-----\n\nThis provides a [build hook](https://hatch.pypa.io/latest/config/build/#build-hooks) plugin \nfor [Hatch](https://github.com/pypa/hatch) that compiles multi-lingual messages with GNU \ngettext's tools `msgfmt`. It can also (optionally) use `intltool` to: \n- translate .xml and .desktop files\n- search for left out files\n- regenerate the .pot template \n- display a status report for all translations\n\n**Table of Contents**\n\n<!-- TOC -->\n* [Hatch Gettext](#hatch-gettext)\n  * [Configuration](#configuration)\n    * [Calling the plugin](#calling-the-plugin)\n    * [Compiling messages with msgfmt](#compiling-messages-with-msgfmt)\n    * [Identifying left out files using intltool-update](#identifying-left-out-files-using-intltool-update)\n    * [Regenerating the .pot template using intltool-update](#regenerating-the-pot-template-using-intltool-update)\n    * [Displaying a status report using intltool-update](#displaying-a-status-report-using-intltool-update)\n    * [Translating files using intltool-merge](#translating-files-using-intltool-merge)\n  * [Cleaning output files](#cleaning-output-files)\n  * [Related Hatch plugin](#related-hatch-plugin)\n  * [License](#license)\n<!-- TOC -->\n\n## Configuration\n\nThe [build hook plugin](https://hatch.pypa.io/latest/plugins/build-hook/) \nname is `gettext`.\n\n### Calling the plugin\n\nModify `pyproject.toml` to include the plugin as a build dependency:\n\n```toml\n[build-system]\nrequires = [\"hatchling\", \"hatch-gettext\"]\nbuild-backend = \"hatchling.build\"\n```\n\n### Compiling messages with msgfmt\n \nThis plugin requires `.mo` files be created; it also requires that the \ndirectory storing them is within the project's base directory, and is not \nequal to the project's base directory or the directory in which `po` files\nare sourced. The mo file directory is set using `locale-directory`, which is \nrequired. \n\nFor example, for a project named `myproject`, and a src layout \n`src/myproject`, an acceptable directory in which to store the \n`LC_MESSAGES/myproject.mo` files would be `src/myproject/locale`\n\n```toml\n[tool.hatch.build.hooks.gettext]\nlocale-directory = \"src/myproject/locale\"\n```\n\nOptionally, specify values for the gexttext output name\nand the source directory where po files are found:\n\n```toml\n[tool.hatch.build.hooks.gettext]\nlocale-directory = \"src/myproject/locale\"\ni18n-name = \"myproject\" \npo-directory = \"po-files\"\n```\n\nIf `i18n-name` is not specified, the `name` in `[project]` in the \n`pyproject.toml` is used. If `po-directory` is not specified, the \ndirectory `po` is used.\n\n### Identifying left out files using intltool-update\n\nWith every source distribution (sdist) build, to search for left out files, \nwhich should have been listed in `POTFILES.in` or `POTFILES.skip`, set \n`identify-left-out` to true (the default value is false):\n\n```toml\n[tool.hatch.build.hooks.gettext]\nlocale-directory = \"src/myproject/locale\"\nidentify-left-out = true\n```\n\n### Regenerating the .pot template using intltool-update\n\nTo regenerate the .pot template with every sdist build, set \n`regenerate-template` to true (the default value is false):\n\n```toml\n[tool.hatch.build.hooks.gettext]\nlocale-directory = \"src/myproject/locale\"\nregenerate-template = true\n```\n\n### Displaying a status report using intltool-update\n\nTo display a status report for all translations, set `show-report` to true \n(the default value is false):\n\n```toml\n[tool.hatch.build.hooks.gettext]\nlocale-directory = \"src/myproject/locale\"\nshow-report = true\n```\n\n### Translating files using intltool-merge\n\nThis plugin allows for but does not mandate translating `.xml` and \n`.desktop` files using `intltool-merge`. Using \n`[tool.hatch.build.hooks.gettext.files]`, specify the destination directories\nfor the translated files using keys, and arrays of source files as values. For \nexample:  \n\n```toml\n[tool.hatch.build.hooks.gettext.files]\n\"share/applications\" = [\"data/net.myproject.desktop.in\"]\n\"share/solid/actions\" = [\"data/kde/net.myproject.desktop.in\"]\n\"share/metainfo\" = [\"data/net.myproject.metainfo.xml.in\"]\n```\n\n## Cleaning output files\n\nThe plugin includes logic to remove the files it outputs using hatch's\n`clean` hook. As well as individual files, any output directories created \nwill also be removed, as long as these directories do not contain files \ncreated by something other than this plugin.\n\n## Related Hatch plugin\n\nTo automatically generate a manual page from an `ArgumentParser` object,\nsee [hatch-argparse-manpage](https://github.com/damonlynch/hatch-argparse-manpage).\n\n## License\n\n`hatch-gettext` is distributed under the terms of the [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later.html) license.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Hatch build hook plugin for GNU gettext",
    "version": "1.1.0",
    "project_urls": {
        "Documentation": "https://github.com/damonlynch/hatch-gettext#readme",
        "Homepage": "https://github.com/damonlynch/hatch-gettext",
        "Issues": "https://github.com/damonlynch/hatch-gettext/issues"
    },
    "split_keywords": [
        "build",
        " gettext",
        " hatch",
        " i18n",
        " plugin",
        " typing"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3853c6f3c7fcc2dc8aa93323ea546ae1e701301bdef5c93719e43ea953cfe4eb",
                "md5": "c6c4d40ecddfd908fe6ddc78b3936ffe",
                "sha256": "3356492a7f90a57a8ea1e0c4702ac62da3fd5f8e5e92790b5274d01e5f2420c6"
            },
            "downloads": -1,
            "filename": "hatch_gettext-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c6c4d40ecddfd908fe6ddc78b3936ffe",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 20742,
            "upload_time": "2024-04-24T03:25:31",
            "upload_time_iso_8601": "2024-04-24T03:25:31.424771Z",
            "url": "https://files.pythonhosted.org/packages/38/53/c6f3c7fcc2dc8aa93323ea546ae1e701301bdef5c93719e43ea953cfe4eb/hatch_gettext-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cdb24d4832953d048af2c6cf6e56c5dc50cd2b661848c05346d7c13702ead6fa",
                "md5": "e2ad35559f9763027c6ff78212da54ed",
                "sha256": "d08e4ab9f612ace00ed034fad92101c91637ea2c26f9f9926b9cb070c9295017"
            },
            "downloads": -1,
            "filename": "hatch_gettext-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e2ad35559f9763027c6ff78212da54ed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 22082,
            "upload_time": "2024-04-24T03:25:29",
            "upload_time_iso_8601": "2024-04-24T03:25:29.665943Z",
            "url": "https://files.pythonhosted.org/packages/cd/b2/4d4832953d048af2c6cf6e56c5dc50cd2b661848c05346d7c13702ead6fa/hatch_gettext-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-24 03:25:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "damonlynch",
    "github_project": "hatch-gettext#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "hatch-gettext"
}
        
Elapsed time: 0.23665s