Skip to content

Commit

Permalink
Remove *.mo from repository + update doctests (#59)
Browse files Browse the repository at this point in the history
* Remove *.mo files from repository.
* Remove `u` prefix from strings.
  • Loading branch information
Michael Howitz committed Aug 28, 2023
1 parent 7739b6f commit b4f5481
Show file tree
Hide file tree
Showing 28 changed files with 202 additions and 218 deletions.
25 changes: 11 additions & 14 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ with-macos = false

[tox]
use-flake8 = true
testenv-setenv = [
"zope_i18n_compile_mo_files=True",
]

[coverage]
fail-under = 99
Expand All @@ -32,20 +35,14 @@ additional-rules = [
"recursive-include src *.zcml",
]

[check-manifest]
ignore-bad-ideas = [
"src/zope/i18n/tests/de-default.mo",
"src/zope/i18n/tests/en-alt.mo",
"src/zope/i18n/tests/en-default.mo",
"src/zope/i18n/tests/locale/de/LC_MESSAGES/zope-i18n.mo",
"src/zope/i18n/tests/locale/en/LC_MESSAGES/zope-i18n.mo",
"src/zope/i18n/tests/locale2/en/LC_MESSAGES/zope-i18n.mo",
"src/zope/i18n/tests/locale3/en/LC_MESSAGES/zope-i18n.mo",
"src/zope/i18n/tests/locale3/en/LC_MESSAGES/zope-i18n2.mo",
"src/zope/i18n/tests/pl-default.mo",
"src/zope/i18n/tests/sr-default.mo",
"src/zope/i18n/tests/sr@Cyrl-default.mo",
"src/zope/i18n/tests/sr@Latn-default.mo",
[zest-releaser]
options = [
"prereleaser.before = zest.pocompile.available",
]

[git]
ignore = [
"*.mo",
]

[zest-releaser]
Expand Down
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
CHANGES
=========

5.1 (unreleased)
5.1 (2023-08-28)
================

- Include ``*.mo`` files in release.
- Include ``*.mo`` files in release but remove them from repository.


5.0 (2023-03-27)
Expand Down
13 changes: 0 additions & 13 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@ ignore =
.meta.toml
docs/_build/html/_sources/*
docs/_build/doctest/*
ignore-bad-ideas =
src/zope/i18n/tests/de-default.mo
src/zope/i18n/tests/en-alt.mo
src/zope/i18n/tests/en-default.mo
src/zope/i18n/tests/locale/de/LC_MESSAGES/zope-i18n.mo
src/zope/i18n/tests/locale/en/LC_MESSAGES/zope-i18n.mo
src/zope/i18n/tests/locale2/en/LC_MESSAGES/zope-i18n.mo
src/zope/i18n/tests/locale3/en/LC_MESSAGES/zope-i18n.mo
src/zope/i18n/tests/locale3/en/LC_MESSAGES/zope-i18n2.mo
src/zope/i18n/tests/pl-default.mo
src/zope/i18n/tests/sr-default.mo
src/zope/i18n/tests/sr@Cyrl-default.mo
src/zope/i18n/tests/sr@Latn-default.mo

[isort]
force_single_line = True
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def read(*rnames):

setup(
name='zope.i18n',
version='5.1.dev0',
version='5.1',
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.dev',
description='Zope Internationalization Support',
Expand Down
4 changes: 2 additions & 2 deletions src/zope/i18n/gettextmessagecatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ def ungettext(self, singular, plural, n):

def plural_formatting(func):
"""This decorator interpolates the possible formatting marker.
This interpolation marker is usally present for plurals.
This interpolation marker is usually present for plurals.
Example: `There are %d apples` or `They have %s pies.`
Please note that the interpolation can be done, alternatively,
using the mapping. This is only present as a conveniance.
using the mapping. This is only present as a convenience.
"""
@wraps(func)
def pformat(catalog, singular, plural, n, *args, **kwargs):
Expand Down
46 changes: 23 additions & 23 deletions src/zope/i18n/locales/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ class LocaleDisplayNames(AttributeInheritance):
>>> locale = LocaleInheritanceStub(nextLocale=root)
>>> locale.displayNames = LocaleDisplayNames()
>>> locale.displayNames.keys = ['fu', 'bahr']
>>> locale.displayNames.keys = ['f', 'bahr']
Here you can see the inheritance in action::
>>> locale.displayNames.languages
['en', 'de']
>>> locale.displayNames.keys
['fu', 'bahr']
['f', 'bahr']
"""


Expand Down Expand Up @@ -297,13 +297,13 @@ class LocaleCalendar(AttributeInheritance):
>>> locale.calendar.months = InheritingDictionary(
... {2: (u"Februar", u"Feb"), 3: (u"Maerz", u"Mrz")})
>>> locale.calendar.getMonthNames()[:4]
[u'January', u'Februar', u'Maerz', None]
['January', 'Februar', 'Maerz', None]
>>> locale.calendar.getMonthTypeFromName(u"January")
1
>>> locale.calendar.getMonthTypeFromName(u"Februar")
2
>>> locale.calendar.getMonthAbbreviations()[:4]
[u'Jan', u'Feb', u'Mrz', None]
['Jan', 'Feb', 'Mrz', None]
>>> locale.calendar.getMonthTypeFromAbbreviation(u"Jan")
1
>>> locale.calendar.getMonthTypeFromAbbreviation(u"Mrz")
Expand All @@ -314,31 +314,31 @@ class LocaleCalendar(AttributeInheritance):
>>> locale.calendar.days = InheritingDictionary(
... {2: (u"Dienstag", u"Die"), 3: (u"Mittwoch", u"Mit")})
>>> locale.calendar.getDayNames()[:4]
[u'Monday', u'Dienstag', u'Mittwoch', None]
['Monday', 'Dienstag', 'Mittwoch', None]
>>> locale.calendar.getDayTypeFromName(u"Monday")
1
>>> locale.calendar.getDayTypeFromName(u"Dienstag")
2
>>> locale.calendar.getDayAbbreviations()[:4]
[u'Mon', u'Die', u'Mit', None]
['Mon', 'Die', 'Mit', None]
>>> locale.calendar.getDayTypeFromAbbreviation(u"Mon")
1
>>> locale.calendar.getDayTypeFromAbbreviation(u"Die")
2
>>> root.calendar.week = {'firstDay': 1}
>>> locale.calendar.getFirstWeekDayName()
u'Monday'
'Monday'
Let's test the direct attribute access as well.
>>> root.am = u"AM"
>>> root.pm = u"PM"
>>> locale.pm = u"nachm."
>>> locale.pm
u'nachm.'
'nachm.'
>>> locale.am
u'AM'
'AM'
Note that ``isWeekend`` is not implemented:
Expand Down Expand Up @@ -444,11 +444,11 @@ class LocaleDates(AttributeInheritance):
>>> formatter = dates.getFormatter('date')
>>> formatter.format(date(2004, 2, 4))
u'04.02.2004'
'04.02.2004'
>>> formatter = dates.getFormatter('date', length='full')
>>> formatter.format(date(2004, 2, 4))
u'Mittwoch, 4. Februar 2004'
'Mittwoch, 4. Februar 2004'
Let's also test the time formatter::
Expand All @@ -467,11 +467,11 @@ class LocaleDates(AttributeInheritance):
>>> formatter = dates.getFormatter('time')
>>> formatter.format(time(12, 15, 00))
u'12:15:00'
'12:15:00'
>>> formatter = dates.getFormatter('time', length='full')
>>> formatter.format(time(12, 15, 00))
u'12:15 Uhr +000'
'12:15 Uhr +000'
The datetime formatter is a bit special, since it is constructed from
the other two::
Expand All @@ -484,11 +484,11 @@ class LocaleDates(AttributeInheritance):
>>> formatter = dates.getFormatter('dateTime')
>>> formatter.format(datetime(2004, 2, 4, 12, 15, 00))
u'04.02.2004 12:15:00'
'04.02.2004 12:15:00'
>>> formatter = dates.getFormatter('dateTime', length='full')
>>> formatter.format(datetime(2004, 2, 4, 12, 15, 00))
u'Mittwoch, 4. Februar 2004 12:15 Uhr +000'
'Mittwoch, 4. Februar 2004 12:15 Uhr +000'
Finally, we'll test some invalid input::
Expand Down Expand Up @@ -588,11 +588,11 @@ class LocaleNumbers(AttributeInheritance):
>>> numbers.decimalFormats = {None: length}
>>> formatter = numbers.getFormatter('decimal')
>>> formatter.format(3.4)
u'3,4'
'3,4'
>>> formatter.format(-3.4567)
u'-3,457'
'-3,457'
>>> formatter.format(3210.4)
u'3.210,4'
'3.210,4'
Setting up and accessing scientific formats with named format lengths::
Expand All @@ -609,10 +609,10 @@ class LocaleNumbers(AttributeInheritance):
>>> numbers.defaultScientificFormat = 'long'
>>> formatter = numbers.getFormatter('scientific')
>>> formatter.format(1234.5678)
u'1,234568E+03'
'1,234568E+03'
>>> formatter = numbers.getFormatter('scientific', 'medium')
>>> formatter.format(1234.5678)
u'1,2346E+03'
'1,2346E+03'
Setting up and accessing percent formats with named format lengths
and format names::
Expand All @@ -627,17 +627,17 @@ class LocaleNumbers(AttributeInheritance):
>>> numbers.defaultPercentFormat = 'long'
>>> formatter = numbers.getFormatter('percent')
>>> formatter.format(123.45678)
u'123,457%'
'123,457%'
>>> formatter = numbers.getFormatter('percent', name='bar')
>>> formatter.format(123.45678)
u'123%'
'123%'
...using a default name::
>>> numbers.percentFormats['long'].default = 'bar'
>>> formatter = numbers.getFormatter('percent')
>>> formatter.format(123.45678)
u'123%'
'123%'
"""

Expand Down
6 changes: 3 additions & 3 deletions src/zope/i18n/locales/fallbackcollator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ strings in a slightly friendly way:

>>> sorted([u"Sam", u"sally", u"Abe", u"alice", u"Terry", u"tim"],
... key=collator.key)
[u'Abe', u'alice', u'sally', u'Sam', u'Terry', u'tim']
['Abe', 'alice', 'sally', 'Sam', 'Terry', 'tim']


The collator has a very simple algorithm. It normalizes strings and
Expand All @@ -42,10 +42,10 @@ string and the normalized string. We can see this by calling the key
method, which converts unicode strings to collation keys:

>>> collator.key(u"Sam")
(u'sam', u'Sam')
('sam', 'Sam')

>>> collator.key(u"\xc6\xf8a\u030a")
(u'\xe6\xf8\xe5', u'\xc6\xf8\xe5')
('æøå', 'Æøå')

There is also a cmp function for comparing strings:

Expand Down
7 changes: 3 additions & 4 deletions src/zope/i18n/locales/tests/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from zope.i18n.locales.inheritance import AttributeInheritance
from zope.i18n.locales.inheritance import NoParentException
from zope.i18n.testing import unicode_checker


class LocaleInheritanceStub(AttributeInheritance):
Expand All @@ -34,7 +33,7 @@ def getInheritedSelf(self):

def test_suite():
return unittest.TestSuite((
DocTestSuite('zope.i18n.locales', checker=unicode_checker),
DocTestSuite('zope.i18n.locales.inheritance', checker=unicode_checker),
DocTestSuite('zope.i18n.locales.xmlfactory', checker=unicode_checker),
DocTestSuite('zope.i18n.locales'),
DocTestSuite('zope.i18n.locales.inheritance'),
DocTestSuite('zope.i18n.locales.xmlfactory'),
))
8 changes: 1 addition & 7 deletions src/zope/i18n/locales/tests/test_fallbackcollator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
##############################################################################

import doctest
import unittest

from zope.i18n.testing import unicode_checker


def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite('../fallbackcollator.txt',
checker=unicode_checker),
))
return doctest.DocFileSuite('../fallbackcollator.txt')

0 comments on commit b4f5481

Please sign in to comment.