Provides translations for argparse module
Project description
i18nparse
Localization of the Python argparse module
Current status
The French language translation is provided from the beginning of the project. A Brazilian Portuguese translation has been added in 0.8.0 version by anselmobd.
The binary wheel file contains litte endian mo translation files. Users of big endian systems should use the source distribution to generate the mo files on their own system.
Goals
The argparse module makes it easy to write user-friendly command-line interfaces. Specifically, it automatically generates help and usage messages and issues errors when users give the program invalid arguments. Unfortunately, even if the module is able to use gettext
type localization strings, none is provided by the standard library.
This module provides some translations (at least a French one) and will be simply installable through pip
Installing
End user installation
With pip: pip install i18nparse
.
Developper installation
If you want to contribute, you should get a copy of the full tree from GitHUB:
git clone https://github.com/s-ball/i18nparse.git [your_working_copy_folder]
Usage
The i18nparse
module defines 2 functions:
def activate(lang = None)
which activates the usage of the translation for the required language.
By default, the language for locale.getlocale()
is used.
Note: In order to use the expected locale, it should be loaded prior to
the call to activate
with locale.setlocale(locale.LC_ALL, locale_name)
where locale_name
is the name of a known locale or ''
(empty string) for
the default locale.
def deactivate()
which reverts to the original texts.
Example:
import argparse
import i18nparse
import locale
locale.setlocale(locale.LC_ALL, '') # sets a locale
i18nparse.activate() # Ok use current locale (if translation file exists)
parser = argparse.ArgumentParser('foo')
parser.print_help() # displays the help message for the current locale
Assuming a fr_FR
locale, this displays:
usage : foo [-h]
arguments optionnels:
-h, --help affiche ce message et termine le programme
Contributing
Contribution for new language translations or improvement of existing ones are welcome. See CONTRIBUTING for details
Versioning
This project uses a standard Major.Minor.Patch versioning pattern. Inside a major version, public API stability is expected (at least after 1.0.0 version will be published).
License
This project is licensed under the MIT License - see the LICENSE file for details
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file i18nparse-0.8.0.tar.gz
.
File metadata
- Download URL: i18nparse-0.8.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7538a3ce4f6d0ac7a02b1d5ed438048976f5d7254c48cce820a60a4909b46daa |
|
MD5 | 68c7c432eb08f67000db9e3832489b75 |
|
BLAKE2b-256 | 5d6680062dbf25ea2f3dc59b6d568984273795a7b1491c02d6fb148fd47463eb |
File details
Details for the file i18nparse-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: i18nparse-0.8.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c5a8ee8b2d8cad508378b83c761055896ec86325a27f4dcb848ac292b84fb86 |
|
MD5 | 0d1aff15f5befcc76b41f9cc9661589b |
|
BLAKE2b-256 | f91bdcb7773415520d8e9548fdebc8c01ef65b836c8bca816188285a874ace5e |