././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1726565643.6058002 zope_i18nmessageid-7.0/0000755000076500000240000000000014672246414013752 5ustar00jensstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726558791.0 zope_i18nmessageid-7.0/.manylinux-install.sh0000755000076500000240000000373014672231107020053 0ustar00jensstaff#!/usr/bin/env bash # Generated from: # https://github.com/zopefoundation/meta/tree/master/config/c-code set -e -x # Running inside docker # Set a cache directory for pip. This was # mounted to be the same as it is outside docker so it # can be persisted. export XDG_CACHE_HOME="/cache" # XXX: This works for macOS, where everything bind-mounted # is seen as owned by root in the container. But when the host is Linux # the actual UIDs come through to the container, triggering # pip to disable the cache when it detects that the owner doesn't match. # The below is an attempt to fix that, taken from bcrypt. It seems to work on # Github Actions. if [ -n "$GITHUB_ACTIONS" ]; then echo Adjusting pip cache permissions mkdir -p $XDG_CACHE_HOME/pip chown -R $(whoami) $XDG_CACHE_HOME fi ls -ld /cache ls -ld /cache/pip # We need some libraries because we build wheels from scratch: yum -y install libffi-devel tox_env_map() { case $1 in *"cp38"*) echo 'py38';; *"cp39"*) echo 'py39';; *"cp310"*) echo 'py310';; *"cp311"*) echo 'py311';; *"cp312"*) echo 'py312';; *"cp313"*) echo 'py313';; *) echo 'py';; esac } # Compile wheels for PYBIN in /opt/python/*/bin; do if \ [[ "${PYBIN}" == *"cp38/"* ]] || \ [[ "${PYBIN}" == *"cp39/"* ]] || \ [[ "${PYBIN}" == *"cp310/"* ]] || \ [[ "${PYBIN}" == *"cp311/"* ]] || \ [[ "${PYBIN}" == *"cp312/"* ]] || \ [[ "${PYBIN}" == *"cp313/"* ]] ; then "${PYBIN}/pip" install -e /io/ "${PYBIN}/pip" wheel /io/ -w wheelhouse/ if [ `uname -m` == 'aarch64' ]; then cd /io/ ${PYBIN}/pip install tox TOXENV=$(tox_env_map "${PYBIN}") ${PYBIN}/tox -e ${TOXENV} cd .. fi rm -rf /io/build /io/*.egg-info fi done # Bundle external shared libraries into the wheels for whl in wheelhouse/zope.i18nmessageid*.whl; do auditwheel repair "$whl" -w /io/wheelhouse/ done ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726558791.0 zope_i18nmessageid-7.0/.manylinux.sh0000755000076500000240000000077514672231107016415 0ustar00jensstaff#!/usr/bin/env bash # Generated from: # https://github.com/zopefoundation/meta/tree/master/config/c-code set -e -x # Mount the current directory as /io # Mount the pip cache directory as /cache # `pip cache` requires pip 20.1 echo Setting up caching python --version python -mpip --version LCACHE="$(dirname `python -mpip cache dir`)" echo Sharing pip cache at $LCACHE $(ls -ld $LCACHE) docker run --rm -e GITHUB_ACTIONS -v "$(pwd)":/io -v "$LCACHE:/cache" $DOCKER_IMAGE $PRE_CMD /io/.manylinux-install.sh ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726558791.0 zope_i18nmessageid-7.0/.pre-commit-config.yaml0000644000076500000240000000132214672231107020222 0ustar00jensstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/c-code minimum_pre_commit_version: '3.6' repos: - repo: https://github.com/pycqa/isort rev: "5.13.2" hooks: - id: isort - repo: https://github.com/hhatto/autopep8 rev: "v2.3.1" hooks: - id: autopep8 args: [--in-place, --aggressive, --aggressive] - repo: https://github.com/asottile/pyupgrade rev: v3.17.0 hooks: - id: pyupgrade args: [--py38-plus] - repo: https://github.com/isidentical/teyit rev: 0.4.3 hooks: - id: teyit - repo: https://github.com/PyCQA/flake8 rev: "7.1.1" hooks: - id: flake8 additional_dependencies: - flake8-debugger == 4.1.2 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726558791.0 zope_i18nmessageid-7.0/.readthedocs.yaml0000644000076500000240000000123014672231107017166 0ustar00jensstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/c-code # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required version: 2 # Set the version of Python and other tools you might need build: os: ubuntu-22.04 tools: python: "3.11" # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py # We recommend specifying your dependencies to enable reproducible builds: # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html python: install: - requirements: docs/requirements.txt - method: pip path: . ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726565630.0 zope_i18nmessageid-7.0/CHANGES.rst0000644000076500000240000001346514672246376015574 0ustar00jensstaff========= Changes ========= 7.0 (2024-09-17) ================ - Drop support for Python 3.7. - Build Windows wheels on GHA. - Add support for Python 3.13. - Enable multi-phase module initialization (PEP 489) for all supported Python versions. See this "how-to" doc for rationale and steps: https://docs.python.org/3.13/howto/isolating-extensions.html - Make the ``hookable`` extension type heap-allocated for Python >= 3.9. Likewise, see the doc above for rationale and steps. For Python < 3.9, the ``hookable`` extension type continues to be allocated statically, even though the module itself is allocated dynamically. 6.1.0 (2023-10-05) ================== - Add support for Python 3.12. 6.0.1 (2023-03-24) ================== - Drop dependency on ``six``. 6.0.0 (2023-03-23) ================== - Drop support for Python 2.7, 3.5, 3.6. - Add preliminary support for Python 3.12a5. 5.1.1 (2022-11-17) ================== - Add support for building arm64 wheels on macOS. 5.1.0 (2022-11-06) ================== - Added support for Python 3.9, 3.10 and 3.11. 5.0.1 (2020-03-10) ================== - Remove deprecated use of setuptools features. See `issue 22 `_. 5.0.0 (2019-11-12) ================== - Drop support for Python 3.4. - Add support for Python 3.8. 4.3.1 (2018-10-19) ================== - Fix a regression copying Message objects in the Python implementation. See `issue 14 `_. 4.3.0 (2018-10-18) ================== - Add attributes to support pluralization on a Message and update the MessageFactory accordingly. 4.2.0 (2018-10-05) ================== - Fix the possibility of a rare crash in the C extension when deallocating items. See `issue 7 `_. - Drop support for Python 3.3. - Add support for Python 3.7. 4.1.0 (2017-05-02) ================== - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5 and 3.6. - Fix the C extension not being used in Python 3. See `issue 4 `_. - Make the Python implementation of Message accept any object for the ``default`` argument, just as the C extension does. This should be a unicode or byte string. See `issue 5 `_. 4.0.3 (2014-03-19) ================== - Add support for Python 3.4. - Update ``boostrap.py`` to version 2.2. 4.0.2 (2012-12-31) ================== - Flesh out PyPI Trove classifiers. 4.0.1 (2012-11-21) ================== - Add support for Python 3.3. 4.0.0 (2012-05-16) ================== - Automate generation of Sphinx HTML docs and running doctest snippets via tox. - Remove use of '2to3' and associated fixers when installing under Py3k. The code is now in a "compatible subset" which supports Python 2.6, 2.7, and 3.2, including PyPy 1.8 (the version compatible with the 2.7 language spec). - Bring unit test coverage to 100%. - Move doctest examples into Sphinx documentation. - Drop explicit support for Python 2.4 / 2.5 / 3.1. - Add explicit support for PyPy. - Add 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Add 'setup.py docs' alias (installs ``Sphinx`` and dependencies). 3.6.1 (2011-07-20) ================== - Correct metadata in this file for release date. 3.6.0 (2011-07-20) ================== - Python 3 support. - Suppress compiling C extensions on PyPy or Jython. - Add a tox.ini (see http://tox.readthedocs.org/en/latest/) for easier automated testing. 3.5.3 (2010-08-10) ================== - Make compilation of C extension optional again; 3.5.1 broke this inasmuch as this package become unusable on non-CPython platforms. Making the compilation of the C extension optional again implied removing ``setup.py`` code added in 3.5.1 which made the C extension a setuptools "Feature" and readding code from 3.5.0 which overrides the distutils ``build_ext`` command. - Move pickle equality tests into a unittest.TestCase test to make it easier to condition the tests on whether the C extension has been compiled. This also makes the tests pass on Jython. 3.5.2 (2010-04-30) ================== - Remove use of 'zope.testing.doctestunit' in favor of stdlib's 'doctest. 3.5.1 (2010-04-10) ================== - LP #257657 / 489529: Fix memory leak in C extension. - Fix the compilation of the C extension with python 2.6: refactored it as a setuptools Feature. 3.5.0 (2009-06-27) ================== - Make compilation of C extension optional. - Add support to bootstrap on Jython. - Change package's mailing list address from zope3-dev at zope.org to zope-dev at zope.org, because zope3-dev is now retired. - Reformat change log to common formatting style. - Update package description and docs a little. - Remove old .cfg files for zpkg. 3.4.3 (2007-09-26) ================== - Make PyPI the home URL. 3.4.2 (2007-09-25) ================== - Move the ``ZopeMessageFactory`` from ``zope.app.i18n`` to this package. 3.4.0 (2007-07-19) ================== - Remove incorrect dependency. - Create final release to reflect package status. 3.2.0 (2006-01-05) ================== - Corresponds to the verison of the zope.i18nmessageid package shipped as part of the Zope 3.2.0 release. - Implement 'zope.i18nmessageid.message' as a C extension. - Deprecate 'zope.i18nmessageid.messageid' APIs ('MessageID', 'MessageIDFactory') in favor of replacements in 'zope.i18nmessageid.message' ('Message', 'MessageFactory'). Deprecated items are scheduled for removal in Zope 3.3. 3.0.0 (2004-11-07) ================== - Corresponds to the verison of the zope.i18nmessageid package shipped as part of the Zope X3.0.0 release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726558791.0 zope_i18nmessageid-7.0/CONTRIBUTING.md0000644000076500000240000000143714672231107016201 0ustar00jensstaff # Contributing to zopefoundation projects The projects under the zopefoundation GitHub organization are open source and welcome contributions in different forms: * bug reports * code improvements and bug fixes * documentation improvements * pull request reviews For any changes in the repository besides trivial typo fixes you are required to sign the contributor agreement. See https://www.zope.dev/developer/becoming-a-committer.html for details. Please visit our [Developer Guidelines](https://www.zope.dev/developer/guidelines.html) if you'd like to contribute code changes and our [guidelines for reporting bugs](https://www.zope.dev/developer/reporting-bugs.html) if you want to file a bug report. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667486254.0 zope_i18nmessageid-7.0/COPYRIGHT.txt0000644000076500000240000000004014330751056016047 0ustar00jensstaffZope Foundation and Contributors././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667486254.0 zope_i18nmessageid-7.0/LICENSE.txt0000644000076500000240000000402614330751056015571 0ustar00jensstaffZope Public License (ZPL) Version 2.1 A copyright notice accompanies this license document that identifies the copyright holders. This license has been certified as open source. It has also been designated as GPL compatible by the Free Software Foundation (FSF). Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions in source code must retain the accompanying copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the accompanying copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Names of the copyright holders must not be used to endorse or promote products derived from this software without prior written permission from the copyright holders. 4. The right to distribute this software or to use it for any purpose does not give you the right to use Servicemarks (sm) or Trademarks (tm) of the copyright holders. Use of them is covered by separate agreement with the copyright holders. 5. If any files are modified, you must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. Disclaimer THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726558791.0 zope_i18nmessageid-7.0/MANIFEST.in0000644000076500000240000000061714672231107015505 0ustar00jensstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/c-code include *.md include *.rst include *.txt include buildout.cfg include tox.ini include .pre-commit-config.yaml recursive-include docs *.py recursive-include docs *.rst recursive-include docs *.txt recursive-include docs Makefile recursive-include src *.py include *.yaml include *.sh recursive-include docs *.bat ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1726565643.6057105 zope_i18nmessageid-7.0/PKG-INFO0000644000076500000240000002217014672246414015051 0ustar00jensstaffMetadata-Version: 2.1 Name: zope.i18nmessageid Version: 7.0 Summary: Message Identifiers for internationalization Home-page: https://github.com/zopefoundation/zope.i18nmessageid Author: Zope Foundation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Keywords: zope i18n message factory Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope :: 3 Requires-Python: >=3.8 License-File: LICENSE.txt Requires-Dist: setuptools Provides-Extra: testing Requires-Dist: zope.testrunner; extra == "testing" Requires-Dist: coverage; extra == "testing" Provides-Extra: test Requires-Dist: zope.testrunner; extra == "test" Requires-Dist: coverage; extra == "test" Provides-Extra: docs Requires-Dist: Sphinx; extra == "docs" Requires-Dist: sphinx_rtd_theme; extra == "docs" ``zope.i18nmessageid`` ====================== .. image:: https://img.shields.io/pypi/v/zope.i18nmessageid.svg :target: https://pypi.python.org/pypi/zope.i18nmessageid/ :alt: Latest Version .. image:: https://github.com/zopefoundation/zope.i18nmessageid/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.i18nmessageid/actions/workflows/tests.yml .. image:: https://readthedocs.org/projects/zopei18nmessageid/badge/?version=latest :target: http://zopei18nmessageid.readthedocs.org/en/latest/ :alt: Documentation Status To translate any text, we must be able to discover the source domain of the text. A source domain is an identifier that identifies a project that produces program source strings. Source strings occur as literals in python programs, text in templates, and some text in XML data. The project implies a source language and an application context. We can think of a source domain as a collection of messages and associated translation strings. We often need to create unicode strings that will be displayed by separate views. The view cannot translate the string without knowing its source domain. A string or unicode literal carries no domain information, therefore we use messages. Messages are unicode strings which carry a translation source domain and possibly a default translation. They are created by a message factory. The message factory is created by calling ``MessageFactory`` with the source domain. This package provides facilities for *declaring* such messages within program source text; translation of the messages is the responsiblitiy of the 'zope.i18n' package. Please see http://zopei18nmessageid.readthedocs.org/en/latest/ for the documentation. ========= Changes ========= 7.0 (2024-09-17) ================ - Drop support for Python 3.7. - Build Windows wheels on GHA. - Add support for Python 3.13. - Enable multi-phase module initialization (PEP 489) for all supported Python versions. See this "how-to" doc for rationale and steps: https://docs.python.org/3.13/howto/isolating-extensions.html - Make the ``hookable`` extension type heap-allocated for Python >= 3.9. Likewise, see the doc above for rationale and steps. For Python < 3.9, the ``hookable`` extension type continues to be allocated statically, even though the module itself is allocated dynamically. 6.1.0 (2023-10-05) ================== - Add support for Python 3.12. 6.0.1 (2023-03-24) ================== - Drop dependency on ``six``. 6.0.0 (2023-03-23) ================== - Drop support for Python 2.7, 3.5, 3.6. - Add preliminary support for Python 3.12a5. 5.1.1 (2022-11-17) ================== - Add support for building arm64 wheels on macOS. 5.1.0 (2022-11-06) ================== - Added support for Python 3.9, 3.10 and 3.11. 5.0.1 (2020-03-10) ================== - Remove deprecated use of setuptools features. See `issue 22 `_. 5.0.0 (2019-11-12) ================== - Drop support for Python 3.4. - Add support for Python 3.8. 4.3.1 (2018-10-19) ================== - Fix a regression copying Message objects in the Python implementation. See `issue 14 `_. 4.3.0 (2018-10-18) ================== - Add attributes to support pluralization on a Message and update the MessageFactory accordingly. 4.2.0 (2018-10-05) ================== - Fix the possibility of a rare crash in the C extension when deallocating items. See `issue 7 `_. - Drop support for Python 3.3. - Add support for Python 3.7. 4.1.0 (2017-05-02) ================== - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5 and 3.6. - Fix the C extension not being used in Python 3. See `issue 4 `_. - Make the Python implementation of Message accept any object for the ``default`` argument, just as the C extension does. This should be a unicode or byte string. See `issue 5 `_. 4.0.3 (2014-03-19) ================== - Add support for Python 3.4. - Update ``boostrap.py`` to version 2.2. 4.0.2 (2012-12-31) ================== - Flesh out PyPI Trove classifiers. 4.0.1 (2012-11-21) ================== - Add support for Python 3.3. 4.0.0 (2012-05-16) ================== - Automate generation of Sphinx HTML docs and running doctest snippets via tox. - Remove use of '2to3' and associated fixers when installing under Py3k. The code is now in a "compatible subset" which supports Python 2.6, 2.7, and 3.2, including PyPy 1.8 (the version compatible with the 2.7 language spec). - Bring unit test coverage to 100%. - Move doctest examples into Sphinx documentation. - Drop explicit support for Python 2.4 / 2.5 / 3.1. - Add explicit support for PyPy. - Add 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Add 'setup.py docs' alias (installs ``Sphinx`` and dependencies). 3.6.1 (2011-07-20) ================== - Correct metadata in this file for release date. 3.6.0 (2011-07-20) ================== - Python 3 support. - Suppress compiling C extensions on PyPy or Jython. - Add a tox.ini (see http://tox.readthedocs.org/en/latest/) for easier automated testing. 3.5.3 (2010-08-10) ================== - Make compilation of C extension optional again; 3.5.1 broke this inasmuch as this package become unusable on non-CPython platforms. Making the compilation of the C extension optional again implied removing ``setup.py`` code added in 3.5.1 which made the C extension a setuptools "Feature" and readding code from 3.5.0 which overrides the distutils ``build_ext`` command. - Move pickle equality tests into a unittest.TestCase test to make it easier to condition the tests on whether the C extension has been compiled. This also makes the tests pass on Jython. 3.5.2 (2010-04-30) ================== - Remove use of 'zope.testing.doctestunit' in favor of stdlib's 'doctest. 3.5.1 (2010-04-10) ================== - LP #257657 / 489529: Fix memory leak in C extension. - Fix the compilation of the C extension with python 2.6: refactored it as a setuptools Feature. 3.5.0 (2009-06-27) ================== - Make compilation of C extension optional. - Add support to bootstrap on Jython. - Change package's mailing list address from zope3-dev at zope.org to zope-dev at zope.org, because zope3-dev is now retired. - Reformat change log to common formatting style. - Update package description and docs a little. - Remove old .cfg files for zpkg. 3.4.3 (2007-09-26) ================== - Make PyPI the home URL. 3.4.2 (2007-09-25) ================== - Move the ``ZopeMessageFactory`` from ``zope.app.i18n`` to this package. 3.4.0 (2007-07-19) ================== - Remove incorrect dependency. - Create final release to reflect package status. 3.2.0 (2006-01-05) ================== - Corresponds to the verison of the zope.i18nmessageid package shipped as part of the Zope 3.2.0 release. - Implement 'zope.i18nmessageid.message' as a C extension. - Deprecate 'zope.i18nmessageid.messageid' APIs ('MessageID', 'MessageIDFactory') in favor of replacements in 'zope.i18nmessageid.message' ('Message', 'MessageFactory'). Deprecated items are scheduled for removal in Zope 3.3. 3.0.0 (2004-11-07) ================== - Corresponds to the verison of the zope.i18nmessageid package shipped as part of the Zope X3.0.0 release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667486254.0 zope_i18nmessageid-7.0/README.rst0000644000076500000240000000335514330751056015441 0ustar00jensstaff``zope.i18nmessageid`` ====================== .. image:: https://img.shields.io/pypi/v/zope.i18nmessageid.svg :target: https://pypi.python.org/pypi/zope.i18nmessageid/ :alt: Latest Version .. image:: https://github.com/zopefoundation/zope.i18nmessageid/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.i18nmessageid/actions/workflows/tests.yml .. image:: https://readthedocs.org/projects/zopei18nmessageid/badge/?version=latest :target: http://zopei18nmessageid.readthedocs.org/en/latest/ :alt: Documentation Status To translate any text, we must be able to discover the source domain of the text. A source domain is an identifier that identifies a project that produces program source strings. Source strings occur as literals in python programs, text in templates, and some text in XML data. The project implies a source language and an application context. We can think of a source domain as a collection of messages and associated translation strings. We often need to create unicode strings that will be displayed by separate views. The view cannot translate the string without knowing its source domain. A string or unicode literal carries no domain information, therefore we use messages. Messages are unicode strings which carry a translation source domain and possibly a default translation. They are created by a message factory. The message factory is created by calling ``MessageFactory`` with the source domain. This package provides facilities for *declaring* such messages within program source text; translation of the messages is the responsiblitiy of the 'zope.i18n' package. Please see http://zopei18nmessageid.readthedocs.org/en/latest/ for the documentation. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667737083.0 zope_i18nmessageid-7.0/buildout.cfg0000644000076500000240000000027314331722773016263 0ustar00jensstaff[buildout] develop = . parts = test python [test] recipe = zc.recipe.testrunner eggs = zope.i18nmessageid [python] recipe = zc.recipe.egg eggs = zope.i18nmessageid interpreter = python ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1726565643.601813 zope_i18nmessageid-7.0/docs/0000755000076500000240000000000014672246414014702 5ustar00jensstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667486254.0 zope_i18nmessageid-7.0/docs/Makefile0000644000076500000240000001275014330751056016341 0ustar00jensstaff# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/zopei18nmessageid.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/zopei18nmessageid.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/zopei18nmessageid" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/zopei18nmessageid" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1726565643.5974724 zope_i18nmessageid-7.0/docs/_build/0000755000076500000240000000000014672246414016140 5ustar00jensstaff././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1726565643.6020248 zope_i18nmessageid-7.0/docs/_build/doctest/0000755000076500000240000000000014672246414017605 5ustar00jensstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726558829.0 zope_i18nmessageid-7.0/docs/_build/doctest/output.txt0000644000076500000240000000056614672231155021711 0ustar00jensstaffResults of doctest builder run on 2024-09-17 09:40:29 ===================================================== Document: narr -------------- 1 items passed all tests: 35 tests in default 35 tests in 1 items. 35 passed and 0 failed. Test passed. Doctest summary =============== 35 tests 0 failures in tests 0 failures in setup code 0 failures in cleanup code ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1726565643.5975208 zope_i18nmessageid-7.0/docs/_build/html/0000755000076500000240000000000014672246414017104 5ustar00jensstaff././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1726565643.6027637 zope_i18nmessageid-7.0/docs/_build/html/_sources/0000755000076500000240000000000014672246414020726 5ustar00jensstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667486254.0 zope_i18nmessageid-7.0/docs/_build/html/_sources/api.rst.txt0000644000076500000240000000037614330751056023047 0ustar00jensstaff:mod:`zope.i18nmessageid` API Reference ======================================= :mod:`zope.i18nmessageid.message` --------------------------------- .. automodule:: zope.i18nmessageid.message .. autoclass:: Message .. autoclass:: MessageFactory ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1717223323.0 zope_i18nmessageid-7.0/docs/_build/html/_sources/hacking.rst.txt0000644000076500000240000002110114626537633023702 0ustar00jensstaffHacking on :mod:`zope.i18nmessageid` ==================================== Getting the Code ################ The main repository for :mod:`zope.i18nmessageid` is in the Zope Foundation Github repository: https://github.com/zopefoundation/zope.i18nmessageid You can get a read-only checkout from there: .. code-block:: sh $ git clone https://github.com/zopefoundation/zope.i18nmessageid.git or fork it and get a writeable checkout of your fork: .. code-block:: sh $ git clone git@github.com/jrandom/zope.i18nmessageid.git Working in a Python virtual environment ####################################### Installing ---------- You can use Python's standard ``venv`` package to create lightweight Python development environments, where you can run the tests using nothing more than the ``python`` binary in a virtualenv. First, create a scratch environment: .. code-block:: sh $ python3.12 -m venv /tmp/hack-zope.i18nmessageid Next, install this package in "development mod" in the newly-created environment: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/pip install -e . Running the tests ----------------- Once installed, you can run the tests using the standard library's ``unittest`` module: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/python -m unittest discover -s src ......................................... ---------------------------------------------------------------------- Ran 41 tests in 0.002s OK You can install a more comprehensive set of tools using the ``testing`` extra: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/pip install -e ".[testing]" That command installs the tools needed to run the tests: in particular, the ``zope.testrunner`` (see :external+testrunner:std:doc:`getting-started`) and :external+coverage:std:doc:`index` tools. To run the tests via ``zope.testrunner``: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/zope-testrunner --test-path=src Running zope.testrunner.layer.UnitTests tests: Set up zope.testrunner.layer.UnitTests in 0.000 seconds. Ran 41 tests with 0 failures, 0 errors and 0 skipped in 0.003 seconds. Tearing down left over layers: Tear down zope.testrunner.layer.UnitTests in 0.000 seconds. Running the tests under :mod:`coverage` lets you see how well the tests cover the code: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/coverage run -m zope.testrunner \ --test-path=src ... $ coverage report -i -m --fail-under=100 Name Stmts Miss Branch BrPart Cover Missing ---------------------------------------------------------------------------------- src/zope/i18nmessageid/__init__.py 4 0 0 0 100.00% src/zope/i18nmessageid/message.py 52 0 18 0 100.00% src/zope/i18nmessageid/tests.py 189 0 38 0 100.00% ---------------------------------------------------------------------------------- TOTAL 245 0 56 0 100.00% Building the documentation -------------------------- :mod:`zope.i18nmessageid` uses the nifty :mod:`Sphinx` documentation system for building its docs. Using the same virtualenv you set up to run the tests, you can build the docs: The ``docs`` command alias downloads and installs Sphinx and its dependencies: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/pip install ".[docs]" ... $ /tmp/hack-zope.i8nmessageid/bin/sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html ... build succeeded. The HTML pages are in docs/_build/html. You can also test the code snippets in the documentation: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest ... running tests... Document: narr -------------- 1 items passed all tests: 35 tests in default 35 tests in 1 items. 35 passed and 0 failed. Test passed. Doctest summary =============== 35 tests 0 failures in tests 0 failures in setup code 0 failures in cleanup code build succeeded. Testing of doctests in the sources finished, look at the results in docs/_build/doctest/output.txt. Using :mod:`tox` ################ Running Tests on Multiple Python Versions ----------------------------------------- `tox `_ is a Python-based test automation tool designed to run tests against multiple Python versions. It creates a virtual environment for each configured version, installs the current package and configured dependencies into each environment, and then runs the configured commands. :mod:`zope.i18nmessageid` configures the following :mod:`tox` environments via its ``tox.ini`` file: - The ``lint`` environment runs various "code quality" tests on the source, and fails on any errors they find. - The ``py38``, ``py39``, ``py310``, ``py311``, ``py312``, ``py313``, and ``pypy3`` environments each build an environment from the corresponding Python version, install :mod:`zope.i18nmessageid` and testing dependencies, and runs the tests. It then installs ``Sphinx`` and runs the doctest snippets. - The ``coverage`` environment builds a virtual environment, installs :mod:`zope.i18nmessageid` and dependencies, installs :mod:`coverage`, and runs the tests with statement and branch coverage. - The ``docs`` environment builds a virtual environment, installs :mod:`zope.i18nmessageid` and dependencies, installs ``Sphinx`` and dependencies, and then builds the docs and exercises the doctest snippets. This example requires that you have a working ``python3.12`` on your path, as well as installing ``tox``: .. code-block:: sh $ tox -e py312 py312: install_deps> python -I -m pip install 'setuptools<69' Sphinx ... py312: commands[0]> zope-testrunner --test-path=src -vc Running tests at level 1 Running zope.testrunner.layer.UnitTests tests: Set up zope.testrunner.layer.UnitTests in 0.000 seconds. Running: ......................................... Ran 41 tests with 0 failures, 0 errors, 0 skipped in 0.003 seconds. Tearing down left over layers: Tear down zope.testrunner.layer.UnitTests in 0.000 seconds. py312: commands[1]> sphinx-build -b doctest -d /home/tseaver/projects/Zope/Z3/zope.i18nmessageid/.tox/py312/.cache/doctrees docs /home/tseaver/projects/Zope/Z3/zope.i18nmessageid/.tox/py312/.cache/doctest Running Sphinx v7.3.7 ... running tests... Document: narr -------------- 1 items passed all tests: 35 tests in default 35 tests in 1 items. 35 passed and 0 failed. Test passed. Doctest summary =============== 35 tests 0 failures in tests 0 failures in setup code 0 failures in cleanup code build succeeded. Testing of doctests in the sources finished, look at the results in .tox/py312/.cache/doctest/output.txt. py312: OK (16.29=setup[15.11]+cmd[0.26,0.92] seconds) congratulations :) (16.56 seconds) Running ``tox`` with no arguments runs all the configured environments, including building the docs and testing their snippets: .. code-block:: sh $ tox lint: commands[0]> isort --check-only --diff /home/tseaver/projects/Zope/Z3/zope.i18nmessageid/src /home/tseaver/projects/Zope/Z3/zope.i18nmessageid/setup.py lint: commands[1]> flake8 src setup.py lint: OK (0.50=setup[0.02]+cmd[0.19,0.28] seconds) congratulations :) (0.73 seconds) ... __________________________________ summary ____________________________________ lint: commands succeeded py37: commands succeeded ... pypy3: commands succeeded docs: commands succeeded coverage: commands succeeded congratulations :) Contributing to :mod:`zope.i18nmessageid` ######################################### Submitting a Bug Report ----------------------- :mod:`zope.i18nmessageid` tracks its bugs on Github: https://github.com/zopefoundation/zope.i18nmessageid/issues Please submit bug reports and feature requests there. Sharing Your Changes -------------------- .. note:: Please ensure that all tests are passing before you submit your code. If possible, your submission should include new tests for new features or bug fixes, although it is possible that you may have tested your new code by updating existing tests. If have made a change you would like to share, the best route is to fork the Githb repository, check out your fork, make your changes on a branch in your fork, and push it. You can then submit a pull request from your branch: https://github.com/zopefoundation/zope.i18nmessageid/pulls ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667486254.0 zope_i18nmessageid-7.0/docs/_build/html/_sources/index.rst.txt0000644000076500000240000000036314330751056023401 0ustar00jensstaff:mod:`zope.i18nmessageid` Documentation ======================================= Contents: .. toctree:: :maxdepth: 2 narr api hacking Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726466817.0 zope_i18nmessageid-7.0/docs/_build/html/_sources/narr.rst.txt0000644000076500000240000001131314671745401023236 0ustar00jensstaffUsing :mod:`zope.i18nmessageid` =============================== Rationale --------- To translate any text, we must be able to discover the source domain of the text. A source domain is an identifier that identifies a project that produces program source strings. Source strings occur as literals in python programs, text in templates, and some text in XML data. The project implies a source language and an application context. Messages and Domains -------------------- We can think of a source domain as a collection of messages and associated translation strings. The domain helps to disambiguate messages based on context: for instance, the message whose source string is ``draw`` means one thing in a first-person shooter game, and quite another in a graphics package: in the first case, the domain for the message might be ``ok_corral``, while in the second it might be ``gimp``. We often need to create unicode strings that will be displayed by separate views. The view cannot translate the string without knowing its source domain. A string or unicode literal carries no domain information, therefore we use instances of the :class:`~zope.i18nmessageid.message.Message` class. Messages are unicode strings which carry a translation source domain and possibly a default translation. Message Factories ----------------- Messages are created by a message factory belonging to a given translation domain. Each message factory is created by instantiating a :class:`~zope.i18nmessageid.message.MessageFactory`, passing the domain corresponding to the project which manages the corrresponding translations. .. doctest:: >>> from zope.i18nmessageid import MessageFactory >>> factory = MessageFactory('myproject') >>> foo = factory('foo') >>> foo.domain 'myproject' The Zope project uses the ``zope`` domain for its messages. This package exports an already-created factory for that domain: .. doctest:: >>> from zope.i18nmessageid import ZopeMessageFactory as _z_ >>> foo = _z_('foo') >>> foo.domain 'zope' Example Usage ------------- In this example, we create a message factory and assign it to _. By convention, we use _ as the name of our factory to be compatible with translatable string extraction tools such as xgettext. We then call _ with a string that needs to be translatable: .. doctest:: >>> from zope.i18nmessageid import MessageFactory, Message >>> _ = MessageFactory("futurama") >>> robot = _(u"robot-message", u"${name} is a robot.") Messages at first seem like they are text strings: .. doctest:: >>> robot == 'robot-message' True >>> isinstance(robot, str) True The additional domain, default and mapping information is available through attributes: .. doctest:: >>> robot.default == '${name} is a robot.' True >>> robot.mapping is None True >>> robot.domain 'futurama' The message's attributes are considered part of the immutable message object. They cannot be changed once the message id is created: .. doctest:: >>> robot.domain = "planetexpress" Traceback (most recent call last): ... AttributeError: readonly attribute >>> robot.default = u"${name} is not a robot." Traceback (most recent call last): ... AttributeError: readonly attribute >>> robot.mapping = {'name': 'Bender'} Traceback (most recent call last): ... AttributeError: readonly attribute If you need to change their information, yo'll have to make a new message id object: .. doctest:: >>> new_robot = Message(robot, mapping={'name': 'Bender'}) >>> new_robot == 'robot-message' True >>> new_robot.domain 'futurama' >>> new_robot.default == '${name} is a robot.' True >>> new_robot.mapping == {'name': 'Bender'} True Last but not least, messages are reduceable for pickling: .. doctest:: >>> callable, args = new_robot.__reduce__() >>> callable is Message True >>> args == ('robot-message', ... 'futurama', ... '${name} is a robot.', ... {'name': 'Bender'}, ... None, ... None, ... None) True >>> fembot = Message('fembot') >>> callable, args = fembot.__reduce__() >>> callable is Message True >>> args == ('fembot', None, None, None, None, None, None) True Pickling and unpickling works, which means we can store message IDs in a database: .. doctest:: >>> from pickle import dumps, loads >>> pystate = dumps(new_robot) >>> pickle_bot = loads(pystate) >>> (pickle_bot, ... pickle_bot.domain, ... pickle_bot.default, ... pickle_bot.mapping) == ('robot-message', ... 'futurama', ... '${name} is a robot.', ... {'name': 'Bender'}) True >>> pickle_bot.__reduce__()[0] is Message True ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667486254.0 zope_i18nmessageid-7.0/docs/api.rst0000644000076500000240000000037614330751056016205 0ustar00jensstaff:mod:`zope.i18nmessageid` API Reference ======================================= :mod:`zope.i18nmessageid.message` --------------------------------- .. automodule:: zope.i18nmessageid.message .. autoclass:: Message .. autoclass:: MessageFactory ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726466817.0 zope_i18nmessageid-7.0/docs/conf.py0000644000076500000240000000260714671745401016205 0ustar00jensstaff# Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html import datetime # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information year = datetime.datetime.now().year project = 'zope.i18nmessageid' copyright = f'2012-{year}, Zope Foundation and contributors' author = 'Zope Foundation and contributors' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', ] templates_path = ['_templates'] exclude_patterns = [] # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output html_theme = 'sphinx_rtd_theme' html_static_path = ['_static'] # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { 'python': ('https://docs.python.org/3', None), 'testrunner': ('https://zopetestrunner.readthedocs.io/en/stable/', None), 'coverage': ('https://coverage.readthedocs.io/en/latest', None), } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1717223323.0 zope_i18nmessageid-7.0/docs/hacking.rst0000644000076500000240000002110114626537633017040 0ustar00jensstaffHacking on :mod:`zope.i18nmessageid` ==================================== Getting the Code ################ The main repository for :mod:`zope.i18nmessageid` is in the Zope Foundation Github repository: https://github.com/zopefoundation/zope.i18nmessageid You can get a read-only checkout from there: .. code-block:: sh $ git clone https://github.com/zopefoundation/zope.i18nmessageid.git or fork it and get a writeable checkout of your fork: .. code-block:: sh $ git clone git@github.com/jrandom/zope.i18nmessageid.git Working in a Python virtual environment ####################################### Installing ---------- You can use Python's standard ``venv`` package to create lightweight Python development environments, where you can run the tests using nothing more than the ``python`` binary in a virtualenv. First, create a scratch environment: .. code-block:: sh $ python3.12 -m venv /tmp/hack-zope.i18nmessageid Next, install this package in "development mod" in the newly-created environment: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/pip install -e . Running the tests ----------------- Once installed, you can run the tests using the standard library's ``unittest`` module: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/python -m unittest discover -s src ......................................... ---------------------------------------------------------------------- Ran 41 tests in 0.002s OK You can install a more comprehensive set of tools using the ``testing`` extra: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/pip install -e ".[testing]" That command installs the tools needed to run the tests: in particular, the ``zope.testrunner`` (see :external+testrunner:std:doc:`getting-started`) and :external+coverage:std:doc:`index` tools. To run the tests via ``zope.testrunner``: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/zope-testrunner --test-path=src Running zope.testrunner.layer.UnitTests tests: Set up zope.testrunner.layer.UnitTests in 0.000 seconds. Ran 41 tests with 0 failures, 0 errors and 0 skipped in 0.003 seconds. Tearing down left over layers: Tear down zope.testrunner.layer.UnitTests in 0.000 seconds. Running the tests under :mod:`coverage` lets you see how well the tests cover the code: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/coverage run -m zope.testrunner \ --test-path=src ... $ coverage report -i -m --fail-under=100 Name Stmts Miss Branch BrPart Cover Missing ---------------------------------------------------------------------------------- src/zope/i18nmessageid/__init__.py 4 0 0 0 100.00% src/zope/i18nmessageid/message.py 52 0 18 0 100.00% src/zope/i18nmessageid/tests.py 189 0 38 0 100.00% ---------------------------------------------------------------------------------- TOTAL 245 0 56 0 100.00% Building the documentation -------------------------- :mod:`zope.i18nmessageid` uses the nifty :mod:`Sphinx` documentation system for building its docs. Using the same virtualenv you set up to run the tests, you can build the docs: The ``docs`` command alias downloads and installs Sphinx and its dependencies: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/pip install ".[docs]" ... $ /tmp/hack-zope.i8nmessageid/bin/sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html ... build succeeded. The HTML pages are in docs/_build/html. You can also test the code snippets in the documentation: .. code-block:: sh $ /tmp/hack-zope.i8nmessageid/bin/sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest ... running tests... Document: narr -------------- 1 items passed all tests: 35 tests in default 35 tests in 1 items. 35 passed and 0 failed. Test passed. Doctest summary =============== 35 tests 0 failures in tests 0 failures in setup code 0 failures in cleanup code build succeeded. Testing of doctests in the sources finished, look at the results in docs/_build/doctest/output.txt. Using :mod:`tox` ################ Running Tests on Multiple Python Versions ----------------------------------------- `tox `_ is a Python-based test automation tool designed to run tests against multiple Python versions. It creates a virtual environment for each configured version, installs the current package and configured dependencies into each environment, and then runs the configured commands. :mod:`zope.i18nmessageid` configures the following :mod:`tox` environments via its ``tox.ini`` file: - The ``lint`` environment runs various "code quality" tests on the source, and fails on any errors they find. - The ``py38``, ``py39``, ``py310``, ``py311``, ``py312``, ``py313``, and ``pypy3`` environments each build an environment from the corresponding Python version, install :mod:`zope.i18nmessageid` and testing dependencies, and runs the tests. It then installs ``Sphinx`` and runs the doctest snippets. - The ``coverage`` environment builds a virtual environment, installs :mod:`zope.i18nmessageid` and dependencies, installs :mod:`coverage`, and runs the tests with statement and branch coverage. - The ``docs`` environment builds a virtual environment, installs :mod:`zope.i18nmessageid` and dependencies, installs ``Sphinx`` and dependencies, and then builds the docs and exercises the doctest snippets. This example requires that you have a working ``python3.12`` on your path, as well as installing ``tox``: .. code-block:: sh $ tox -e py312 py312: install_deps> python -I -m pip install 'setuptools<69' Sphinx ... py312: commands[0]> zope-testrunner --test-path=src -vc Running tests at level 1 Running zope.testrunner.layer.UnitTests tests: Set up zope.testrunner.layer.UnitTests in 0.000 seconds. Running: ......................................... Ran 41 tests with 0 failures, 0 errors, 0 skipped in 0.003 seconds. Tearing down left over layers: Tear down zope.testrunner.layer.UnitTests in 0.000 seconds. py312: commands[1]> sphinx-build -b doctest -d /home/tseaver/projects/Zope/Z3/zope.i18nmessageid/.tox/py312/.cache/doctrees docs /home/tseaver/projects/Zope/Z3/zope.i18nmessageid/.tox/py312/.cache/doctest Running Sphinx v7.3.7 ... running tests... Document: narr -------------- 1 items passed all tests: 35 tests in default 35 tests in 1 items. 35 passed and 0 failed. Test passed. Doctest summary =============== 35 tests 0 failures in tests 0 failures in setup code 0 failures in cleanup code build succeeded. Testing of doctests in the sources finished, look at the results in .tox/py312/.cache/doctest/output.txt. py312: OK (16.29=setup[15.11]+cmd[0.26,0.92] seconds) congratulations :) (16.56 seconds) Running ``tox`` with no arguments runs all the configured environments, including building the docs and testing their snippets: .. code-block:: sh $ tox lint: commands[0]> isort --check-only --diff /home/tseaver/projects/Zope/Z3/zope.i18nmessageid/src /home/tseaver/projects/Zope/Z3/zope.i18nmessageid/setup.py lint: commands[1]> flake8 src setup.py lint: OK (0.50=setup[0.02]+cmd[0.19,0.28] seconds) congratulations :) (0.73 seconds) ... __________________________________ summary ____________________________________ lint: commands succeeded py37: commands succeeded ... pypy3: commands succeeded docs: commands succeeded coverage: commands succeeded congratulations :) Contributing to :mod:`zope.i18nmessageid` ######################################### Submitting a Bug Report ----------------------- :mod:`zope.i18nmessageid` tracks its bugs on Github: https://github.com/zopefoundation/zope.i18nmessageid/issues Please submit bug reports and feature requests there. Sharing Your Changes -------------------- .. note:: Please ensure that all tests are passing before you submit your code. If possible, your submission should include new tests for new features or bug fixes, although it is possible that you may have tested your new code by updating existing tests. If have made a change you would like to share, the best route is to fork the Githb repository, check out your fork, make your changes on a branch in your fork, and push it. You can then submit a pull request from your branch: https://github.com/zopefoundation/zope.i18nmessageid/pulls ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667486254.0 zope_i18nmessageid-7.0/docs/index.rst0000644000076500000240000000036314330751056016537 0ustar00jensstaff:mod:`zope.i18nmessageid` Documentation ======================================= Contents: .. toctree:: :maxdepth: 2 narr api hacking Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667486254.0 zope_i18nmessageid-7.0/docs/make.bat0000644000076500000240000001177614330751056016315 0ustar00jensstaff@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\zopei18nmessageid.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\zopei18nmessageid.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726466817.0 zope_i18nmessageid-7.0/docs/narr.rst0000644000076500000240000001131314671745401016374 0ustar00jensstaffUsing :mod:`zope.i18nmessageid` =============================== Rationale --------- To translate any text, we must be able to discover the source domain of the text. A source domain is an identifier that identifies a project that produces program source strings. Source strings occur as literals in python programs, text in templates, and some text in XML data. The project implies a source language and an application context. Messages and Domains -------------------- We can think of a source domain as a collection of messages and associated translation strings. The domain helps to disambiguate messages based on context: for instance, the message whose source string is ``draw`` means one thing in a first-person shooter game, and quite another in a graphics package: in the first case, the domain for the message might be ``ok_corral``, while in the second it might be ``gimp``. We often need to create unicode strings that will be displayed by separate views. The view cannot translate the string without knowing its source domain. A string or unicode literal carries no domain information, therefore we use instances of the :class:`~zope.i18nmessageid.message.Message` class. Messages are unicode strings which carry a translation source domain and possibly a default translation. Message Factories ----------------- Messages are created by a message factory belonging to a given translation domain. Each message factory is created by instantiating a :class:`~zope.i18nmessageid.message.MessageFactory`, passing the domain corresponding to the project which manages the corrresponding translations. .. doctest:: >>> from zope.i18nmessageid import MessageFactory >>> factory = MessageFactory('myproject') >>> foo = factory('foo') >>> foo.domain 'myproject' The Zope project uses the ``zope`` domain for its messages. This package exports an already-created factory for that domain: .. doctest:: >>> from zope.i18nmessageid import ZopeMessageFactory as _z_ >>> foo = _z_('foo') >>> foo.domain 'zope' Example Usage ------------- In this example, we create a message factory and assign it to _. By convention, we use _ as the name of our factory to be compatible with translatable string extraction tools such as xgettext. We then call _ with a string that needs to be translatable: .. doctest:: >>> from zope.i18nmessageid import MessageFactory, Message >>> _ = MessageFactory("futurama") >>> robot = _(u"robot-message", u"${name} is a robot.") Messages at first seem like they are text strings: .. doctest:: >>> robot == 'robot-message' True >>> isinstance(robot, str) True The additional domain, default and mapping information is available through attributes: .. doctest:: >>> robot.default == '${name} is a robot.' True >>> robot.mapping is None True >>> robot.domain 'futurama' The message's attributes are considered part of the immutable message object. They cannot be changed once the message id is created: .. doctest:: >>> robot.domain = "planetexpress" Traceback (most recent call last): ... AttributeError: readonly attribute >>> robot.default = u"${name} is not a robot." Traceback (most recent call last): ... AttributeError: readonly attribute >>> robot.mapping = {'name': 'Bender'} Traceback (most recent call last): ... AttributeError: readonly attribute If you need to change their information, yo'll have to make a new message id object: .. doctest:: >>> new_robot = Message(robot, mapping={'name': 'Bender'}) >>> new_robot == 'robot-message' True >>> new_robot.domain 'futurama' >>> new_robot.default == '${name} is a robot.' True >>> new_robot.mapping == {'name': 'Bender'} True Last but not least, messages are reduceable for pickling: .. doctest:: >>> callable, args = new_robot.__reduce__() >>> callable is Message True >>> args == ('robot-message', ... 'futurama', ... '${name} is a robot.', ... {'name': 'Bender'}, ... None, ... None, ... None) True >>> fembot = Message('fembot') >>> callable, args = fembot.__reduce__() >>> callable is Message True >>> args == ('fembot', None, None, None, None, None, None) True Pickling and unpickling works, which means we can store message IDs in a database: .. doctest:: >>> from pickle import dumps, loads >>> pystate = dumps(new_robot) >>> pickle_bot = loads(pystate) >>> (pickle_bot, ... pickle_bot.domain, ... pickle_bot.default, ... pickle_bot.mapping) == ('robot-message', ... 'futurama', ... '${name} is a robot.', ... {'name': 'Bender'}) True >>> pickle_bot.__reduce__()[0] is Message True ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1696504779.0 zope_i18nmessageid-7.0/docs/requirements.txt0000644000076500000240000000005014507515713020157 0ustar00jensstaffSphinx sphinx_rtd_theme>1 docutils<0.19 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726558791.0 zope_i18nmessageid-7.0/pyproject.toml0000644000076500000240000000131014672231107016652 0ustar00jensstaff# # Generated from: # https://github.com/zopefoundation/meta/tree/master/config/c-code [build-system] requires = ["setuptools<74"] build-backend = "setuptools.build_meta" [tool.coverage.run] branch = true source = ["zope.i18nmessageid"] relative_files = true [tool.coverage.report] fail_under = 95 precision = 2 ignore_errors = true show_missing = true exclude_lines = ["pragma: no cover", "pragma: nocover", "except ImportError:", "raise NotImplementedError", "if __name__ == '__main__':", "self.fail", "raise AssertionError", "raise unittest.Skip"] [tool.coverage.html] directory = "parts/htmlcov" [tool.coverage.paths] source = ["src/", ".tox/*/lib/python*/site-packages/", ".tox/pypy*/site-packages/"] ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1726565643.6060762 zope_i18nmessageid-7.0/setup.cfg0000644000076500000240000000103214672246414015567 0ustar00jensstaff[zest.releaser] create-wheel = no [flake8] doctests = 1 per-file-ignores = src/zope/i18nmessageid/__init__.py: F401 [check-manifest] ignore = .editorconfig .meta.toml docs/_build/html/_sources/* docs/_build/doctest/* [isort] force_single_line = True combine_as_imports = True sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER known_third_party = docutils, pkg_resources, pytz known_zope = known_first_party = default_section = ZOPE line_length = 79 lines_after_imports = 2 [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726565630.0 zope_i18nmessageid-7.0/setup.py0000644000076500000240000001132214672246376015472 0ustar00jensstaff############################################################################## # # Copyright (c) 2006 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## # This package is developed by the Zope Toolkit project, documented here: # http://docs.zope.org/zopetoolkit # When developing and releasing this package, please follow the documented # Zope Toolkit policies as described by this documentation. ############################################################################## """Setup for zope.i18nmessageid package """ import os import platform import sys from distutils.command.build_ext import build_ext from distutils.errors import CCompilerError from distutils.errors import DistutilsExecError from distutils.errors import DistutilsPlatformError from setuptools import Extension from setuptools import find_packages from setuptools import setup py_impl = getattr(platform, 'python_implementation', lambda: None) is_pypy = py_impl() == 'PyPy' is_jython = 'java' in sys.platform codeoptimization_c = os.path.join('src', 'zope', 'i18nmessageid', "_zope_i18nmessageid_message.c") codeoptimization = [ Extension( "zope.i18nmessageid._zope_i18nmessageid_message", [os.path.normcase(codeoptimization_c)] ), ] ext_modules = [] if not is_pypy and not is_jython: # Jython cannot build the C optimizations, while on PyPy they are # anti-optimizations (the C extension compatibility layer is known-slow, # and defeats JIT opportunities). ext_modules = codeoptimization tests_require = [ 'zope.testrunner', 'coverage', ] def read(*rnames): with open(os.path.join(os.path.dirname(__file__), *rnames)) as stream: return stream.read() class optional_build_ext(build_ext): """This class subclasses build_ext and allows the building of C extensions to fail. """ def run(self): try: build_ext.run(self) except DistutilsPlatformError as e: self._unavailable(e) def build_extension(self, ext): try: build_ext.build_extension(self, ext) except (CCompilerError, DistutilsExecError) as e: self._unavailable(e) def _unavailable(self, e): print('*' * 80, file=sys.stderr) print("""WARNING: An optional code optimization (C extension) could not be compiled. Optimizations for this package will not be available! """, file=sys.stderr) print(str(e), file=sys.stderr) print('*' * 80, file=sys.stderr) setup( name='zope.i18nmessageid', version='7.0', author='Zope Foundation and Contributors', author_email='zope-dev@zope.org', description='Message Identifiers for internationalization', long_description=( read('README.rst') + '\n\n' + read('CHANGES.rst') ), keywords="zope i18n message factory", classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: Zope Public License', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', 'Programming Language :: Python :: 3.13', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Natural Language :: English', 'Operating System :: OS Independent', 'Topic :: Internet :: WWW/HTTP', 'Framework :: Zope :: 3', ], license='ZPL 2.1', url='https://github.com/zopefoundation/zope.i18nmessageid', packages=find_packages('src'), package_dir={'': 'src'}, namespace_packages=['zope'], install_requires=['setuptools'], python_requires='>=3.8', include_package_data=True, zip_safe=False, cmdclass={'build_ext': optional_build_ext}, ext_modules=ext_modules, extras_require={ 'testing': tests_require, 'test': tests_require, 'docs': ['Sphinx', 'sphinx_rtd_theme'], }, ) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1726565643.5976954 zope_i18nmessageid-7.0/src/0000755000076500000240000000000014672246414014541 5ustar00jensstaff././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1726565643.603026 zope_i18nmessageid-7.0/src/zope/0000755000076500000240000000000014672246414015516 5ustar00jensstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667735277.0 zope_i18nmessageid-7.0/src/zope/__init__.py0000644000076500000240000000011414331717355017622 0ustar00jensstaff__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1726565643.6050131 zope_i18nmessageid-7.0/src/zope/i18nmessageid/0000755000076500000240000000000014672246414020157 5ustar00jensstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667735237.0 zope_i18nmessageid-7.0/src/zope/i18nmessageid/__init__.py0000644000076500000240000000154314331717305022265 0ustar00jensstaff############################################################################## # # Copyright (c) 2004 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """I18n Messages """ from zope.i18nmessageid.message import Message from zope.i18nmessageid.message import MessageFactory # import this as _ to create i18n messages in the zope domain ZopeMessageFactory = MessageFactory('zope') ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726466817.0 zope_i18nmessageid-7.0/src/zope/i18nmessageid/_zope_i18nmessageid_message.c0000644000076500000240000003022514671745401025665 0ustar00jensstaff/*############################################################################ # # Copyright (c) 2004 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################*/ #include "Python.h" #include "structmember.h" /* * Don't use heap-allocated types for Python < 3.9. */ #if PY_VERSION_HEX < 0x030a0000 #define USE_STATIC_TYPES 1 #define USE_HEAP_TYPES 0 #else #define USE_STATIC_TYPES 0 #define USE_HEAP_TYPES 1 #endif static int is_message(PyTypeObject* type, PyObject* obj); /* forward ref */ /* * Message type subclasses str */ typedef struct { PyUnicodeObject base; PyObject* domain; PyObject* default_; PyObject* mapping; PyObject* value_plural; PyObject* default_plural; PyObject* number; } Message; /* * Message type slot handlers */ static int Message_traverse(PyObject* pyobj_self, visitproc visit, void* arg) { #if USE_HEAP_TYPES PyTypeObject* tp = Py_TYPE(pyobj_self); Py_VISIT(tp); #endif Message* self = (Message*)pyobj_self; Py_VISIT(self->domain); Py_VISIT(self->default_); Py_VISIT(self->mapping); Py_VISIT(self->value_plural); Py_VISIT(self->default_plural); Py_VISIT(self->number); return 0; } static int Message_clear(PyObject* pyobj_self) { Message* self = (Message*)pyobj_self; Py_CLEAR(self->domain); Py_CLEAR(self->default_); Py_CLEAR(self->mapping); Py_CLEAR(self->value_plural); Py_CLEAR(self->default_plural); Py_CLEAR(self->number); return 0; } static void Message_dealloc(PyObject* self) { #if USE_HEAP_TYPES PyTypeObject* tp = Py_TYPE(self); #endif PyObject_GC_UnTrack(self); Message_clear(self); PyUnicode_Type.tp_dealloc((PyObject*)self); #if USE_HEAP_TYPES Py_DECREF(tp); #endif } static PyObject* Message_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { PyObject *value; PyObject *domain = NULL; PyObject *default_ = NULL; PyObject *mapping = NULL; PyObject *value_plural = NULL; PyObject *default_plural = NULL; PyObject *number = NULL; static char* kwlist[] = { "value", "domain", "default", "mapping", "msgid_plural", "default_plural", "number", NULL }; PyObject *new_args; PyObject *new_str; Message *new_msg; Message *other = NULL; if (!PyArg_ParseTupleAndKeywords( args, kwds, "O|OOOOOO", kwlist, &value, &domain, &default_, &mapping, &value_plural, &default_plural, &number) ) { return NULL; } if (number != NULL && Py_None != number) { if (!(PyLong_Check(number) || PyFloat_Check(number))) { PyErr_SetString(PyExc_TypeError, "`number` should be an integer or a float"); return NULL; } } new_args = Py_BuildValue("(O)", value); if (new_args == NULL) { return NULL; } new_str = PyUnicode_Type.tp_new(type, new_args, NULL); Py_DECREF(new_args); if (new_str == NULL) { return NULL; } if (!is_message(type, new_str)) { PyErr_SetString(PyExc_TypeError, "unicode.__new__ didn't return a Message"); Py_DECREF(new_str); return NULL; } new_msg = (Message*)new_str; if (is_message(type, value)) { /* value is a Message so we copy it and use it as base */ other = (Message*)value; new_msg->domain = other->domain; new_msg->default_ = other->default_; new_msg->mapping = other->mapping; new_msg->value_plural = other->value_plural; new_msg->default_plural = other->default_plural; new_msg->number = other->number; } else { new_msg->domain = NULL; new_msg->default_ = NULL; new_msg->mapping = NULL; new_msg->value_plural = NULL; new_msg->default_plural = NULL; new_msg->number = NULL; } if (domain != NULL) { new_msg->domain = domain; } if (default_ != NULL) { new_msg->default_ = default_; } if (mapping == Py_None) { new_msg->mapping = Py_None; Py_INCREF(Py_None); } else if (mapping != NULL) { /* Ensure that our mapping is immutable */ new_msg->mapping = PyDictProxy_New(mapping); } else if (other != NULL && new_msg->mapping == other->mapping) { /* borrowed? */ Py_XINCREF(new_msg->mapping); } if (value_plural != NULL) { new_msg->value_plural = value_plural; } if (default_plural != NULL) { new_msg->default_plural = default_plural; } if (number != NULL) { new_msg->number = number; } /* Don't: Py_XINCREF(new_msg->mapping); we handed it above */ Py_XINCREF(new_msg->default_); Py_XINCREF(new_msg->domain); Py_XINCREF(new_msg->value_plural); Py_XINCREF(new_msg->default_plural); Py_XINCREF(new_msg->number); return (PyObject*)new_msg; } /* * Message type methods */ static char Message_reduce__doc__[] = ( "Reduce messages to a serializable form\n\n" "Notably, for use in pickling." ); static PyObject* Message_reduce(Message* self) { PyObject *value; PyObject *mapping; PyObject *result; value = PyObject_CallFunctionObjArgs( (PyObject*)&PyUnicode_Type, self, NULL); if (value == NULL) { return NULL;} if (self->mapping == NULL) { mapping = Py_None; /* borrowed: Py_BuildValue will incref */ } else if (self->mapping == Py_None) { mapping = Py_None; /* borrowed: Py_BuildValue will incref */ } else { mapping = PyObject_CallFunctionObjArgs( (PyObject*)&PyDict_Type, self->mapping, NULL); if (mapping == NULL) { return NULL; } } result = Py_BuildValue( "(O(OOOOOOO))", Py_TYPE(&(self->base)), value, self->domain ? self->domain : Py_None, self->default_ ? self->default_ : Py_None, mapping, self->value_plural ? self->value_plural : Py_None, self->default_plural ? self->default_plural : Py_None, self->number ? self->number : Py_None ); if (mapping != Py_None) { Py_DECREF(mapping); } Py_DECREF(value); return result; } /* * Message type declaration structures */ static PyMemberDef Message_members[] = { { "domain", T_OBJECT, offsetof(Message, domain), READONLY }, { "default", T_OBJECT, offsetof(Message, default_), READONLY }, { "mapping", T_OBJECT, offsetof(Message, mapping), READONLY }, { "msgid_plural", T_OBJECT, offsetof(Message, value_plural), READONLY }, { "default_plural", T_OBJECT, offsetof(Message, default_plural), READONLY }, { "number", T_OBJECT, offsetof(Message, number), READONLY }, { NULL } /* Sentinel */ }; static PyMethodDef Message_methods[] = { { "__reduce__", (PyCFunction)Message_reduce, METH_NOARGS, Message_reduce__doc__ }, { NULL } /* Sentinel */ }; static char Message__name__[] = "zope.i18nmessageid.message.Message"; static char Message__doc__[] = "Message\n" "\n" "This is a string used as a message. It has a domain attribute that is\n" "its source domain, and a default attribute that is its default text to\n" "display when there is no translation. domain may be None meaning there is\n" "no translation domain. default may also be None, in which case the\n" "message id itself implicitly serves as the default text.\n"; #if USE_STATIC_TYPES /* * Static type: MessageType */ static PyTypeObject MessageType = { PyVarObject_HEAD_INIT(NULL, 0) .tp_name = Message__name__, .tp_doc = Message__doc__, .tp_basicsize = sizeof(Message), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .tp_new = Message_new, .tp_traverse = Message_traverse, .tp_clear = Message_clear, .tp_dealloc = Message_dealloc, .tp_methods = Message_methods, .tp_members = Message_members, }; #else /* * Heap type: MessageType */ static PyType_Slot Message_type_slots[] = { {Py_tp_doc, Message__doc__}, {Py_tp_new, Message_new}, {Py_tp_dealloc, Message_dealloc}, {Py_tp_traverse, Message_traverse}, {Py_tp_clear, Message_clear}, {Py_tp_methods, Message_methods}, {Py_tp_members, Message_members}, {0, NULL} }; static PyType_Spec Message_type_spec = { .name = Message__name__, .basicsize = sizeof(Message), .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | #if PY_VERSION_HEX >= 0x030a0000 Py_TPFLAGS_IMMUTABLETYPE | #endif Py_TPFLAGS_HAVE_GC, .slots = Message_type_slots }; #endif /* * Module initialization structures */ static char _zim__name__[] = "_zope_i18nmessageid_message"; static char _zim__doc__[] = "I18n Messages"; typedef struct { PyTypeObject* message_type; } _zim_module_state; /* * Macro to speed lookup of state members */ #define _zim_state(o) ((_zim_module_state*)PyModule_GetState(o)) /* * Utility: returns True if 'obj' is an instance of 'MessageType'. */ static int is_message(PyTypeObject* type, PyObject* obj) { PyTypeObject* message_type; #if USE_STATIC_TYPES message_type = &MessageType; #else _zim_module_state* rec = (_zim_module_state*)PyType_GetModuleState(type); /* PT_GMS will already have set the exception */ if (rec == NULL) { return 0; } message_type = rec->message_type; #endif return PyObject_TypeCheck(obj, message_type); } static _zim_module_state* _zim_state_init(PyObject* module) { _zim_module_state* rec = _zim_state(module); rec->message_type = NULL; return rec; } static int _zim_state_traverse(PyObject* module, visitproc visit, void* arg) { _zim_module_state* rec = _zim_state(module); Py_VISIT(rec->message_type); return 0; } static int _zim_state_clear(PyObject* module) { _zim_module_state* rec = _zim_state(module); Py_CLEAR(rec->message_type); return 0; } static int _zim_module_exec(PyObject* module) { _zim_module_state* rec = _zim_state_init(module); /* Initialize / add types: */ #if USE_STATIC_TYPES MessageType.tp_base = &PyUnicode_Type; if (PyType_Ready(&MessageType) < 0) { return -1; } Py_INCREF(&MessageType); rec->message_type = &MessageType; if (PyModule_AddObject(module, "Message", (PyObject*)&MessageType) < 0) { return -1; } #else PyObject* message_bases; /* Python 3.9 insists on a tuple */ PyObject* message_type; message_bases = Py_BuildValue("(O)", (PyObject*)&PyUnicode_Type); if (message_bases == NULL) { return -1; } message_type = PyType_FromModuleAndSpec( module, &Message_type_spec, message_bases ); Py_DECREF(message_bases); if (message_type == NULL) { return -1; } rec->message_type = (PyTypeObject*)message_type; if (PyModule_AddObject(module, "Message", message_type) < 0) { return -1; } Py_INCREF(message_type); /* Recover stolen ref */ #endif return 0; } /* * Slot definitions for multi-phase initialization * * See: https://docs.python.org/3/c-api/module.html#multi-phase-initialization * and: https://peps.python.org/pep-0489 */ static PyModuleDef_Slot _zim_module_slots[] = { {Py_mod_exec, _zim_module_exec}, {0, NULL} }; static struct PyModuleDef _zim_module = { PyModuleDef_HEAD_INIT, .m_name =_zim__name__, .m_doc =_zim__doc__, .m_size = sizeof(_zim_module_state), .m_traverse = _zim_state_traverse, .m_clear = _zim_state_clear, .m_slots = _zim_module_slots, }; static PyObject* init(void) { return PyModuleDef_Init(&_zim_module); } PyMODINIT_FUNC PyInit__zope_i18nmessageid_message(void) { return init(); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1717223323.0 zope_i18nmessageid-7.0/src/zope/i18nmessageid/message.py0000644000076500000240000001001614626537633022160 0ustar00jensstaff############################################################################## # # Copyright (c) 2004 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """I18n Messages and factories. """ import types __docformat__ = "reStructuredText" _marker = object() class Message(str): """Message (Python implementation) This is a string used as a message. It has a domain attribute that is its source domain, and a default attribute that is its default text to display when there is no translation. domain may be None meaning there is no translation domain. default may also be None, in which case the message id itself implicitly serves as the default text. """ __slots__ = ( 'domain', 'default', 'mapping', '_readonly', 'msgid_plural', 'default_plural', 'number') def __new__(cls, ustr, domain=_marker, default=_marker, mapping=_marker, msgid_plural=_marker, default_plural=_marker, number=_marker): self = str.__new__(cls, ustr) if isinstance(ustr, self.__class__): self.domain = ustr.domain self.default = ustr.default self.mapping = ustr.mapping self.msgid_plural = ustr.msgid_plural self.default_plural = ustr.default_plural self.number = ustr.number else: self.domain = None self.default = None self.mapping = None self.msgid_plural = None self.default_plural = None self.number = None if domain is not _marker: self.domain = domain if default is not _marker: self.default = default if mapping is None: self.mapping = None elif mapping is not _marker: self.mapping = types.MappingProxyType(mapping) if msgid_plural is not _marker: self.msgid_plural = msgid_plural if default_plural is not _marker: self.default_plural = default_plural if number is not _marker: self.number = number if self.number is not None and not isinstance( self.number, (int, float)): raise TypeError('`number` should be an integer or a float') self._readonly = True return self def __setattr__(self, key, value): """Message is immutable It cannot be changed once the message id is created. """ if getattr(self, '_readonly', False): raise AttributeError('readonly attribute') else: return str.__setattr__(self, key, value) def __getstate__(self): # types.MappingProxyType is not picklable mapping = None if self.mapping is None else dict(self.mapping) return ( str(self), self.domain, self.default, mapping, self.msgid_plural, self.default_plural, self.number, ) def __reduce__(self): return self.__class__, self.__getstate__() # Name the fallback Python implementation to make it easier to test. pyMessage = Message try: from ._zope_i18nmessageid_message import Message except ImportError: # pragma: no cover pass class MessageFactory: """Factory for creating i18n messages.""" def __init__(self, domain): self._domain = domain def __call__(self, ustr, default=None, mapping=None, msgid_plural=None, default_plural=None, number=None): return Message(ustr, self._domain, default, mapping, msgid_plural, default_plural, number) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726466817.0 zope_i18nmessageid-7.0/src/zope/i18nmessageid/tests.py0000644000076500000240000002707214671745401021702 0ustar00jensstaff############################################################################## # # Copyright (c) 2003 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Message ID tests. """ import sys import unittest from zope.i18nmessageid import message as messageid class PyMessageTests(unittest.TestCase): _TEST_READONLY = True def _getTargetClass(self): return messageid.pyMessage def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) def test_defaults(self): message = self._makeOne('testing') self.assertEqual(message, 'testing') self.assertEqual(message.domain, None) self.assertEqual(message.default, None) self.assertEqual(message.mapping, None) self.assertEqual(message.msgid_plural, None) self.assertEqual(message.default_plural, None) self.assertEqual(message.number, None) if self._TEST_READONLY: self.assertTrue(message._readonly) def test_values(self): mapping = {'key': 'value'} message = self._makeOne( 'testing', 'domain', 'default', mapping, msgid_plural='testings', default_plural="defaults", number=2) self.assertEqual(message, 'testing') self.assertEqual(message.domain, 'domain') self.assertEqual(message.default, 'default') self.assertEqual(message.mapping, mapping) self.assertEqual(message.msgid_plural, 'testings') self.assertEqual(message.default_plural, 'defaults') self.assertEqual(message.number, 2) with self.assertRaises(TypeError): message.mapping['key'] = 'new value' if self._TEST_READONLY: self.assertTrue(message._readonly) def test_mapping_is_readonly(self): mapping = {'key': 'value'} message = self._makeOne('testing', 'domain', mapping=mapping) with self.assertRaises(TypeError): message.mapping['key'] = 'new value' def test_values_without_defaults(self): mapping = {'key': 'value'} message = self._makeOne( 'testing', 'domain', mapping=mapping, msgid_plural='testings', number=2) self.assertEqual(message, 'testing') self.assertEqual(message.domain, 'domain') self.assertEqual(message.default, None) self.assertEqual(message.mapping, mapping) self.assertEqual(message.msgid_plural, 'testings') self.assertEqual(message.default_plural, None) self.assertEqual(message.number, 2) if self._TEST_READONLY: self.assertTrue(message._readonly) def test_values_with_float_for_number(self): mapping = {'key': 'value'} message = self._makeOne( 'testing', 'domain', 'default', mapping, msgid_plural='testings', default_plural="defaults", number=2.2) self.assertEqual(message, 'testing') self.assertEqual(message.domain, 'domain') self.assertEqual(message.default, 'default') self.assertEqual(message.mapping, mapping) self.assertEqual(message.msgid_plural, 'testings') self.assertEqual(message.default_plural, 'defaults') self.assertEqual(message.number, 2.2) if self._TEST_READONLY: self.assertTrue(message._readonly) def test_values_with_zero(self): mapping = {'key': 'value'} message = self._makeOne( 'testing', 'domain', 'default', mapping, msgid_plural='testings', default_plural="defaults", number=0) self.assertEqual(message, 'testing') self.assertEqual(message.domain, 'domain') self.assertEqual(message.default, 'default') self.assertEqual(message.mapping, mapping) self.assertEqual(message.msgid_plural, 'testings') self.assertEqual(message.default_plural, 'defaults') self.assertEqual(message.number, 0) if self._TEST_READONLY: self.assertTrue(message._readonly) def test_copy(self): mapping = {'key': 'value'} source = self._makeOne( 'testing', 'domain', 'default', mapping, msgid_plural='testings', default_plural="defaults", number=0) message = self._makeOne(source) self.assertEqual(message, 'testing') self.assertEqual(message.domain, 'domain') self.assertEqual(message.default, 'default') self.assertEqual(message.mapping, mapping) self.assertEqual(message.msgid_plural, 'testings') self.assertEqual(message.default_plural, 'defaults') self.assertEqual(message.number, 0) # Besides just being equal, they maintain their identity for attr in ( 'domain', 'default', 'mapping', 'msgid_plural', 'default_plural', 'number', ): self.assertIs(getattr(source, attr), getattr(message, attr)) if self._TEST_READONLY: self.assertTrue(message._readonly) def test_copy_with_overrides(self): mapping = {'key': 'value'} source = self._makeOne( 'testing', 'domain', default='other', mapping=mapping, msgid_plural='workings', default_plural='others', number=3) message = self._makeOne( source, mapping=None, msgid_plural='override', number=0) self.assertEqual(message, 'testing') self.assertEqual(message.domain, 'domain') self.assertEqual(message.default, 'other') self.assertEqual(message.mapping, None) self.assertEqual(message.msgid_plural, 'override') self.assertEqual(message.default_plural, 'others') self.assertEqual(message.number, 0) if self._TEST_READONLY: self.assertTrue(message._readonly) def test_copy_no_default(self): # https://github.com/zopefoundation/zope.i18nmessageid/issues/14 pref_msg = self._makeOne("${name} Preferences") self.assertIsNone(pref_msg.default) copy = self._makeOne(pref_msg, mapping={'name': 'name'}) self.assertIsNone(copy.default) def test_copy_no_overrides(self): # https://github.com/zopefoundation/zope.i18nmessageid/issues/14 pref_msg = self._makeOne("${name} Preferences") copy = self._makeOne(pref_msg) for attr in ( 'domain', 'default', 'mapping', 'msgid_plural', 'default_plural', 'number', ): self.assertIsNone(getattr(pref_msg, attr)) self.assertIsNone(getattr(copy, attr)) def test_domain_immutable(self): message = self._makeOne('testing') with self.assertRaises((TypeError, AttributeError)): message.domain = 'domain' def test_default_immutable(self): message = self._makeOne('testing') with self.assertRaises((TypeError, AttributeError)): message.default = 'default' def test_mapping_immutable(self): mapping = {'key': 'value'} message = self._makeOne('testing') with self.assertRaises((TypeError, AttributeError)): message.mapping = mapping def test_msgid_plural_immutable(self): message = self._makeOne('testing') with self.assertRaises((TypeError, AttributeError)): message.msgid_plural = 'bar' def test_default_plural_immutable(self): message = self._makeOne('testing') with self.assertRaises((TypeError, AttributeError)): message.default_plural = 'bar' def test_number_immutable(self): message = self._makeOne('testing') with self.assertRaises((TypeError, AttributeError)): message.number = 23 def test_unknown_immutable(self): message = self._makeOne('testing') with self.assertRaises((TypeError, AttributeError)): message.unknown = 'unknown' def test___reduce___wo_values(self): message = self._makeOne('testing') klass, state = message.__reduce__() self.assertIs(klass, self._getTargetClass()) self.assertIsNone(message.mapping) self.assertEqual( state, ('testing', None, None, None, None, None, None) ) def test___reduce__(self): mapping = {'key': 'value'} source = self._makeOne('testing') message = self._makeOne( source, 'domain', 'default', mapping, msgid_plural='testings', default_plural="defaults", number=2) klass, state = message.__reduce__() self.assertIs(klass, self._getTargetClass()) self.assertEqual( state, ('testing', 'domain', 'default', {'key': 'value'}, 'testings', 'defaults', 2)) def test_non_unicode_default(self): message = self._makeOne('str', default=123) self.assertEqual(message.default, 123) def test_non_numeric_number(self): with self.assertRaises((TypeError, AttributeError)): self._makeOne('str', default=123, number="one") @unittest.skipIf(messageid.Message is messageid.pyMessage, "Duplicate tests") class MessageTests(PyMessageTests): _TEST_READONLY = False def _getTargetClass(self): return messageid.Message def test_base_type_is_immutable(self): klass = self._getTargetClass() with self.assertRaises(TypeError): klass.foo = "Foo" @unittest.skipIf('java' in sys.platform or hasattr(sys, 'pypy_version_info'), "We don't expect the C implementation here") class OptimizationTests(unittest.TestCase): def test_optimizations_available(self): self.assertIsNot(messageid.Message, messageid.pyMessage) class MessageFactoryTests(unittest.TestCase): def _getTargetClass(self): return messageid.MessageFactory def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) def test___call___defaults(self): factory = self._makeOne('domain') message = factory('testing') self.assertIsInstance(message, messageid.Message) self.assertEqual(message, 'testing') self.assertEqual(message.domain, 'domain') self.assertEqual(message.default, None) self.assertEqual(message.mapping, None) self.assertEqual(message.msgid_plural, None) self.assertEqual(message.default_plural, None) self.assertEqual(message.number, None) def test___call___explicit(self): mapping = {'key': 'value'} factory = self._makeOne('domain') message = factory( 'testing', 'default', mapping, msgid_plural='testings', default_plural="defaults", number=2) self.assertIsInstance(message, messageid.Message) self.assertEqual(message, 'testing') self.assertEqual(message.domain, 'domain') self.assertEqual(message.default, 'default') self.assertEqual(message.mapping, mapping) self.assertEqual(message.msgid_plural, 'testings') self.assertEqual(message.default_plural, 'defaults') self.assertEqual(message.number, 2) def test_suite(): return unittest.TestSuite(( unittest.defaultTestLoader.loadTestsFromName(__name__), )) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1726565643.6052842 zope_i18nmessageid-7.0/src/zope.i18nmessageid.egg-info/0000755000076500000240000000000014672246414021650 5ustar00jensstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726565643.0 zope_i18nmessageid-7.0/src/zope.i18nmessageid.egg-info/PKG-INFO0000644000076500000240000002217014672246413022746 0ustar00jensstaffMetadata-Version: 2.1 Name: zope.i18nmessageid Version: 7.0 Summary: Message Identifiers for internationalization Home-page: https://github.com/zopefoundation/zope.i18nmessageid Author: Zope Foundation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Keywords: zope i18n message factory Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope :: 3 Requires-Python: >=3.8 License-File: LICENSE.txt Requires-Dist: setuptools Provides-Extra: testing Requires-Dist: zope.testrunner; extra == "testing" Requires-Dist: coverage; extra == "testing" Provides-Extra: test Requires-Dist: zope.testrunner; extra == "test" Requires-Dist: coverage; extra == "test" Provides-Extra: docs Requires-Dist: Sphinx; extra == "docs" Requires-Dist: sphinx_rtd_theme; extra == "docs" ``zope.i18nmessageid`` ====================== .. image:: https://img.shields.io/pypi/v/zope.i18nmessageid.svg :target: https://pypi.python.org/pypi/zope.i18nmessageid/ :alt: Latest Version .. image:: https://github.com/zopefoundation/zope.i18nmessageid/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.i18nmessageid/actions/workflows/tests.yml .. image:: https://readthedocs.org/projects/zopei18nmessageid/badge/?version=latest :target: http://zopei18nmessageid.readthedocs.org/en/latest/ :alt: Documentation Status To translate any text, we must be able to discover the source domain of the text. A source domain is an identifier that identifies a project that produces program source strings. Source strings occur as literals in python programs, text in templates, and some text in XML data. The project implies a source language and an application context. We can think of a source domain as a collection of messages and associated translation strings. We often need to create unicode strings that will be displayed by separate views. The view cannot translate the string without knowing its source domain. A string or unicode literal carries no domain information, therefore we use messages. Messages are unicode strings which carry a translation source domain and possibly a default translation. They are created by a message factory. The message factory is created by calling ``MessageFactory`` with the source domain. This package provides facilities for *declaring* such messages within program source text; translation of the messages is the responsiblitiy of the 'zope.i18n' package. Please see http://zopei18nmessageid.readthedocs.org/en/latest/ for the documentation. ========= Changes ========= 7.0 (2024-09-17) ================ - Drop support for Python 3.7. - Build Windows wheels on GHA. - Add support for Python 3.13. - Enable multi-phase module initialization (PEP 489) for all supported Python versions. See this "how-to" doc for rationale and steps: https://docs.python.org/3.13/howto/isolating-extensions.html - Make the ``hookable`` extension type heap-allocated for Python >= 3.9. Likewise, see the doc above for rationale and steps. For Python < 3.9, the ``hookable`` extension type continues to be allocated statically, even though the module itself is allocated dynamically. 6.1.0 (2023-10-05) ================== - Add support for Python 3.12. 6.0.1 (2023-03-24) ================== - Drop dependency on ``six``. 6.0.0 (2023-03-23) ================== - Drop support for Python 2.7, 3.5, 3.6. - Add preliminary support for Python 3.12a5. 5.1.1 (2022-11-17) ================== - Add support for building arm64 wheels on macOS. 5.1.0 (2022-11-06) ================== - Added support for Python 3.9, 3.10 and 3.11. 5.0.1 (2020-03-10) ================== - Remove deprecated use of setuptools features. See `issue 22 `_. 5.0.0 (2019-11-12) ================== - Drop support for Python 3.4. - Add support for Python 3.8. 4.3.1 (2018-10-19) ================== - Fix a regression copying Message objects in the Python implementation. See `issue 14 `_. 4.3.0 (2018-10-18) ================== - Add attributes to support pluralization on a Message and update the MessageFactory accordingly. 4.2.0 (2018-10-05) ================== - Fix the possibility of a rare crash in the C extension when deallocating items. See `issue 7 `_. - Drop support for Python 3.3. - Add support for Python 3.7. 4.1.0 (2017-05-02) ================== - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5 and 3.6. - Fix the C extension not being used in Python 3. See `issue 4 `_. - Make the Python implementation of Message accept any object for the ``default`` argument, just as the C extension does. This should be a unicode or byte string. See `issue 5 `_. 4.0.3 (2014-03-19) ================== - Add support for Python 3.4. - Update ``boostrap.py`` to version 2.2. 4.0.2 (2012-12-31) ================== - Flesh out PyPI Trove classifiers. 4.0.1 (2012-11-21) ================== - Add support for Python 3.3. 4.0.0 (2012-05-16) ================== - Automate generation of Sphinx HTML docs and running doctest snippets via tox. - Remove use of '2to3' and associated fixers when installing under Py3k. The code is now in a "compatible subset" which supports Python 2.6, 2.7, and 3.2, including PyPy 1.8 (the version compatible with the 2.7 language spec). - Bring unit test coverage to 100%. - Move doctest examples into Sphinx documentation. - Drop explicit support for Python 2.4 / 2.5 / 3.1. - Add explicit support for PyPy. - Add 'setup.py dev' alias (runs ``setup.py develop`` plus installs ``nose`` and ``coverage``). - Add 'setup.py docs' alias (installs ``Sphinx`` and dependencies). 3.6.1 (2011-07-20) ================== - Correct metadata in this file for release date. 3.6.0 (2011-07-20) ================== - Python 3 support. - Suppress compiling C extensions on PyPy or Jython. - Add a tox.ini (see http://tox.readthedocs.org/en/latest/) for easier automated testing. 3.5.3 (2010-08-10) ================== - Make compilation of C extension optional again; 3.5.1 broke this inasmuch as this package become unusable on non-CPython platforms. Making the compilation of the C extension optional again implied removing ``setup.py`` code added in 3.5.1 which made the C extension a setuptools "Feature" and readding code from 3.5.0 which overrides the distutils ``build_ext`` command. - Move pickle equality tests into a unittest.TestCase test to make it easier to condition the tests on whether the C extension has been compiled. This also makes the tests pass on Jython. 3.5.2 (2010-04-30) ================== - Remove use of 'zope.testing.doctestunit' in favor of stdlib's 'doctest. 3.5.1 (2010-04-10) ================== - LP #257657 / 489529: Fix memory leak in C extension. - Fix the compilation of the C extension with python 2.6: refactored it as a setuptools Feature. 3.5.0 (2009-06-27) ================== - Make compilation of C extension optional. - Add support to bootstrap on Jython. - Change package's mailing list address from zope3-dev at zope.org to zope-dev at zope.org, because zope3-dev is now retired. - Reformat change log to common formatting style. - Update package description and docs a little. - Remove old .cfg files for zpkg. 3.4.3 (2007-09-26) ================== - Make PyPI the home URL. 3.4.2 (2007-09-25) ================== - Move the ``ZopeMessageFactory`` from ``zope.app.i18n`` to this package. 3.4.0 (2007-07-19) ================== - Remove incorrect dependency. - Create final release to reflect package status. 3.2.0 (2006-01-05) ================== - Corresponds to the verison of the zope.i18nmessageid package shipped as part of the Zope 3.2.0 release. - Implement 'zope.i18nmessageid.message' as a C extension. - Deprecate 'zope.i18nmessageid.messageid' APIs ('MessageID', 'MessageIDFactory') in favor of replacements in 'zope.i18nmessageid.message' ('Message', 'MessageFactory'). Deprecated items are scheduled for removal in Zope 3.3. 3.0.0 (2004-11-07) ================== - Corresponds to the verison of the zope.i18nmessageid package shipped as part of the Zope X3.0.0 release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726565643.0 zope_i18nmessageid-7.0/src/zope.i18nmessageid.egg-info/SOURCES.txt0000644000076500000240000000200114672246413023524 0ustar00jensstaff.manylinux-install.sh .manylinux.sh .pre-commit-config.yaml .readthedocs.yaml CHANGES.rst CONTRIBUTING.md COPYRIGHT.txt LICENSE.txt MANIFEST.in README.rst buildout.cfg pyproject.toml setup.cfg setup.py tox.ini docs/Makefile docs/api.rst docs/conf.py docs/hacking.rst docs/index.rst docs/make.bat docs/narr.rst docs/requirements.txt docs/_build/doctest/output.txt docs/_build/html/_sources/api.rst.txt docs/_build/html/_sources/hacking.rst.txt docs/_build/html/_sources/index.rst.txt docs/_build/html/_sources/narr.rst.txt src/zope/__init__.py src/zope.i18nmessageid.egg-info/PKG-INFO src/zope.i18nmessageid.egg-info/SOURCES.txt src/zope.i18nmessageid.egg-info/dependency_links.txt src/zope.i18nmessageid.egg-info/namespace_packages.txt src/zope.i18nmessageid.egg-info/not-zip-safe src/zope.i18nmessageid.egg-info/requires.txt src/zope.i18nmessageid.egg-info/top_level.txt src/zope/i18nmessageid/__init__.py src/zope/i18nmessageid/_zope_i18nmessageid_message.c src/zope/i18nmessageid/message.py src/zope/i18nmessageid/tests.py././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726565643.0 zope_i18nmessageid-7.0/src/zope.i18nmessageid.egg-info/dependency_links.txt0000644000076500000240000000000114672246413025715 0ustar00jensstaff ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726565643.0 zope_i18nmessageid-7.0/src/zope.i18nmessageid.egg-info/namespace_packages.txt0000644000076500000240000000000514672246413026175 0ustar00jensstaffzope ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1667487878.0 zope_i18nmessageid-7.0/src/zope.i18nmessageid.egg-info/not-zip-safe0000644000076500000240000000000114330754206024070 0ustar00jensstaff ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726565643.0 zope_i18nmessageid-7.0/src/zope.i18nmessageid.egg-info/requires.txt0000644000076500000240000000016014672246413024244 0ustar00jensstaffsetuptools [docs] Sphinx sphinx_rtd_theme [test] zope.testrunner coverage [testing] zope.testrunner coverage ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726565643.0 zope_i18nmessageid-7.0/src/zope.i18nmessageid.egg-info/top_level.txt0000644000076500000240000000000514672246413024374 0ustar00jensstaffzope ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1726558791.0 zope_i18nmessageid-7.0/tox.ini0000644000076500000240000000347714672231107015271 0ustar00jensstaff# Generated from: # https://github.com/zopefoundation/meta/tree/master/config/c-code [tox] minversion = 4.0 envlist = lint py38,py38-pure py39,py39-pure py310,py310-pure py311,py311-pure py312,py312-pure py313,py313-pure pypy3 docs coverage [testenv] deps = setuptools <74 setenv = pure: PURE_PYTHON=1 !pure-!pypy3: PURE_PYTHON=0 commands = zope-testrunner --test-path=src {posargs:-vc} sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest extras = test docs [testenv:setuptools-latest] basepython = python3 deps = git+https://github.com/pypa/setuptools.git\#egg=setuptools [testenv:coverage] basepython = python3 allowlist_externals = mkdir deps = coverage[toml] setenv = PURE_PYTHON=1 commands = mkdir -p {toxinidir}/parts/htmlcov coverage run -m zope.testrunner --test-path=src {posargs:-vc} coverage html coverage report [testenv:release-check] description = ensure that the distribution is ready to release basepython = python3 skip_install = true deps = setuptools <74 twine build check-manifest check-python-versions >= 0.20.0 wheel commands_pre = commands = check-manifest check-python-versions --only setup.py,tox.ini,.github/workflows/tests.yml python -m build --sdist --no-isolation twine check dist/* [testenv:lint] description = This env runs all linters configured in .pre-commit-config.yaml basepython = python3 skip_install = true deps = pre-commit commands_pre = commands = pre-commit run --all-files --show-diff-on-failure [testenv:docs] basepython = python3 skip_install = false commands_pre = commands = sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest