summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--babel.cfg1
-rw-r--r--doc/requirements.txt6
-rwxr-xr-xdoc/source/conf.py9
-rw-r--r--doc/source/index.rst13
-rw-r--r--lower-constraints.txt11
-rw-r--r--oslo_i18n/_gettextutils.py16
-rw-r--r--oslo_i18n/_message.py35
-rw-r--r--oslo_i18n/tests/test_gettextutils.py11
-rw-r--r--oslo_i18n/tests/test_message.py28
-rw-r--r--oslo_i18n/tests/test_translate.py2
-rw-r--r--releasenotes/source/conf.py10
-rw-r--r--releasenotes/source/locale/en_GB/LC_MESSAGES/releasenotes.po23
-rw-r--r--setup.cfg14
13 files changed, 70 insertions, 109 deletions
diff --git a/babel.cfg b/babel.cfg
deleted file mode 100644
index efceab8..0000000
--- a/babel.cfg
+++ /dev/null
@@ -1 +0,0 @@
-[python: **.py]
diff --git a/doc/requirements.txt b/doc/requirements.txt
index 970a9d3..3980781 100644
--- a/doc/requirements.txt
+++ b/doc/requirements.txt
@@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-sphinx>=1.8.0,!=2.1.0 # BSD
-openstackdocstheme>=1.18.1 # Apache-2.0
-reno>=2.5.0 # Apache-2.0
+sphinx>=2.0.0,!=2.1.0 # BSD
+openstackdocstheme>=2.2.1 # Apache-2.0
+reno>=3.1.0 # Apache-2.0
sphinxcontrib-apidoc>=0.2.0 # BSD
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 02673cc..f107e39 100755
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -23,10 +23,9 @@ extensions = [
]
# openstackdocstheme options
-repository_name = 'openstack/oslo.i18n'
-bug_project = 'oslo.i18n'
-bug_tag = ''
-html_last_updated_fmt = '%Y-%m-%d %H:%M'
+openstackdocs_repo_name = 'openstack/oslo.i18n'
+openstackdocs_bug_project = 'oslo.i18n'
+openstackdocs_bug_tag = ''
# The master toctree document.
master_doc = 'index'
@@ -43,7 +42,7 @@ add_function_parentheses = True
add_module_names = True
# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
+pygments_style = 'native'
# -- Options for HTML output --------------------------------------------------
diff --git a/doc/source/index.rst b/doc/source/index.rst
index e52d8a1..99a6744 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -6,6 +6,9 @@ The oslo.i18n library contain utilities for working with
internationalization (i18n) features, especially translation for text
strings in an application or library.
+Contents
+========
+
.. toctree::
:maxdepth: 2
@@ -13,7 +16,15 @@ strings in an application or library.
reference/index
contributor/index
-.. rubric:: Indices and tables
+Release Notes
+=============
+
+Read also the `oslo.i18n Release Notes
+<https://docs.openstack.org/releasenotes/oslo.i18n/>`_.
+
+
+Indices and tables
+==================
* :ref:`modindex`
* :ref:`search`
diff --git a/lower-constraints.txt b/lower-constraints.txt
index b3bca92..29580e8 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -7,39 +7,34 @@ docutils==0.11
dulwich==0.15.0
extras==1.0.0
fixtures==3.0.0
-flake8==2.5.5
gitdb==0.6.4
GitPython==1.0.1
-hacking==0.12.0
imagesize==0.7.1
iso8601==0.1.11
Jinja2==2.10
keystoneauth1==3.4.0
linecache2==1.0.0
MarkupSafe==1.0
-mccabe==0.2.1
mox3==0.20.0
netaddr==0.7.18
-openstackdocstheme==1.18.1
+openstackdocstheme==2.2.1
os-client-config==1.28.0
oslo.config==5.2.0
oslotest==3.2.0
pbr==2.0.0
-pep8==1.5.7
-pyflakes==0.8.1
Pygments==2.2.0
python-mimeparse==1.6.0
python-subunit==1.0.0
pytz==2013.6
PyYAML==3.12
-reno==2.5.0
+reno==3.1.0
requests==2.14.2
requestsexceptions==1.2.0
rfc3986==0.3.1
six==1.10.0
smmap==0.9.0
snowballstemmer==1.2.1
-Sphinx==1.8.0
+Sphinx==2.0.0
sphinxcontrib-websupport==1.0.1
stestr==2.0.0
stevedore==1.20.0
diff --git a/oslo_i18n/_gettextutils.py b/oslo_i18n/_gettextutils.py
index bc6946f..9872a9c 100644
--- a/oslo_i18n/_gettextutils.py
+++ b/oslo_i18n/_gettextutils.py
@@ -50,6 +50,19 @@ def install(domain):
_AVAILABLE_LANGUAGES = {}
+# Copied from Babel so anyone using aliases that were previously provided by
+# the Babel implementation of get_available_languages continues to work. These
+# are not recommended for use in new code.
+_BABEL_ALIASES = {
+ 'ar': 'ar_SY', 'bg': 'bg_BG', 'bs': 'bs_BA', 'ca': 'ca_ES', 'cs': 'cs_CZ',
+ 'da': 'da_DK', 'de': 'de_DE', 'el': 'el_GR', 'en': 'en_US', 'es': 'es_ES',
+ 'et': 'et_EE', 'fa': 'fa_IR', 'fi': 'fi_FI', 'fr': 'fr_FR', 'gl': 'gl_ES',
+ 'he': 'he_IL', 'hu': 'hu_HU', 'id': 'id_ID', 'is': 'is_IS', 'it': 'it_IT',
+ 'ja': 'ja_JP', 'km': 'km_KH', 'ko': 'ko_KR', 'lt': 'lt_LT', 'lv': 'lv_LV',
+ 'mk': 'mk_MK', 'nl': 'nl_NL', 'nn': 'nn_NO', 'no': 'nb_NO', 'pl': 'pl_PL',
+ 'pt': 'pt_PT', 'ro': 'ro_RO', 'ru': 'ru_RU', 'sk': 'sk_SK', 'sl': 'sl_SI',
+ 'sv': 'sv_SE', 'th': 'th_TH', 'tr': 'tr_TR', 'uk': 'uk_UA'
+}
def get_available_languages(domain):
@@ -72,6 +85,9 @@ def get_available_languages(domain):
language_list.extend(
language for language in locale_identifiers if find(language)
)
+ language_list.extend(
+ alias for alias, _ in _BABEL_ALIASES.items() if find(alias)
+ )
_AVAILABLE_LANGUAGES[domain] = language_list
return copy.copy(language_list)
diff --git a/oslo_i18n/_message.py b/oslo_i18n/_message.py
index ce31970..09ed69c 100644
--- a/oslo_i18n/_message.py
+++ b/oslo_i18n/_message.py
@@ -68,41 +68,6 @@ class Message(six.text_type):
msg.has_plural_form = has_plural_form
return msg
- def translate(self, desired_locale=None):
- """DEPRECATED: Use ``translation`` instead
-
- This is a compatibility shim to allow callers a chance to move away
- from using this function, which shadows a built-in function from our
- parent class.
- """
- # We did a bad thing here. We shadowed the unicode built-in translate,
- # which means there are circumstances where this function may be called
- # with a desired_locale that is a non-string sequence or mapping type.
- # This will not only result in incorrect behavior, it also fails
- # because things like lists are not hashable, and we use the value in
- # desired_locale as part of a dict key. If we see a non-string
- # desired_locale, we know that the caller did not intend to call this
- # form of translate and we should instead pass that along to the
- # unicode implementation of translate.
- #
- # Unfortunately this doesn't entirely solve the problem as it would be
- # possible for a caller to use a string as the mapping type and in that
- # case we can't tell which version of translate they intended to call.
- # That doesn't seem to be a common thing to do though. str.maketrans
- # returns a dict, and that is probably the way most callers will create
- # their mapping.
- if (desired_locale is not None and
- not isinstance(desired_locale, six.string_types)):
- return super(Message, self).translate(desired_locale)
- warnings.warn('Message.translate called with a string argument. '
- 'If your intent was to translate the message into '
- 'another language, please call Message.translation '
- 'instead. If your intent was to call "translate" as '
- 'defined by the str/unicode type, please use a dict or '
- 'list mapping instead. String mappings will not work '
- 'until this compatibility shim is removed.')
- return self.translation(desired_locale)
-
def translation(self, desired_locale=None):
"""Translate this message to the desired locale.
diff --git a/oslo_i18n/tests/test_gettextutils.py b/oslo_i18n/tests/test_gettextutils.py
index 49f95e1..4e0999b 100644
--- a/oslo_i18n/tests/test_gettextutils.py
+++ b/oslo_i18n/tests/test_gettextutils.py
@@ -78,7 +78,8 @@ class GettextTest(test_base.BaseTestCase):
def _mock_gettext_find(domain, localedir=None, languages=None, all=0):
languages = languages or []
if domain == 'domain_1':
- if any(x in ['en_GB', 'es_ES', 'fil_PH'] for x in languages):
+ if any(x in ['en_GB', 'es_ES', 'fil_PH', 'it']
+ for x in languages):
return 'translation-file'
elif domain == 'domain_2':
if any(x in ['fr_FR', 'zh_HK'] for x in languages):
@@ -101,12 +102,14 @@ class GettextTest(test_base.BaseTestCase):
self.assertEqual('en_US', domain_1_languages[0])
self.assertEqual('en_US', domain_2_languages[0])
- self.assertEqual(4, len(domain_1_languages), domain_1_languages)
+ self.assertEqual(5, len(domain_1_languages), domain_1_languages)
self.assertEqual(
- {'en_US', 'fil_PH', 'en_GB', 'es_ES'}, set(domain_1_languages),
+ {'en_US', 'fil_PH', 'en_GB', 'es_ES', 'it'},
+ set(domain_1_languages),
)
self.assertEqual(3, len(domain_2_languages), domain_2_languages)
- self.assertEqual({'en_US', 'fr_FR', 'zh_HK'}, set(domain_2_languages))
+ self.assertEqual({'en_US', 'fr_FR', 'zh_HK'},
+ set(domain_2_languages))
self.assertEqual(2, len(_gettextutils._AVAILABLE_LANGUAGES))
# Now test an unknown domain, only en_US should be included
diff --git a/oslo_i18n/tests/test_message.py b/oslo_i18n/tests/test_message.py
index 9e5fa04..882be8b 100644
--- a/oslo_i18n/tests/test_message.py
+++ b/oslo_i18n/tests/test_message.py
@@ -14,8 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from __future__ import unicode_literals
-
import logging
from unittest import mock
import warnings
@@ -616,32 +614,6 @@ class MessageTestCase(test_base.BaseTestCase):
self.assertEqual(zh_translation, msg.translation('zh'))
self.assertEqual(fr_translation, msg.translation('fr'))
- # TODO(bnemec): Remove these three tests when the translate compatibility
- # shim is removed.
- def test_translate_with_dict(self):
- msg = _message.Message('abc')
- # This dict is what you get back from str.maketrans('abc', 'xyz')
- # We can't actually call that here because it doesn't exist on py2
- # and the string.maketrans that does behaves differently.
- self.assertEqual('xyz', msg.translate({97: 120, 98: 121, 99: 122}))
-
- def test_translate_with_list(self):
- msg = _message.Message('abc')
- table = [six.unichr(x) for x in range(128)]
- table[ord('a')] = 'b'
- table[ord('b')] = 'c'
- table[ord('c')] = 'd'
- self.assertEqual('bcd', msg.translate(table))
-
- @mock.patch('warnings.warn')
- def test_translate_warning(self, mock_warn):
- msg = _message.Message('a message')
- msg.translate('es')
- self.assertTrue(mock_warn.called, 'No warning found')
- # Make sure it was our warning
- self.assertIn('Message.translate called with a string argument.',
- mock_warn.call_args[0][0])
-
class TranslateMsgidTest(test_base.BaseTestCase):
diff --git a/oslo_i18n/tests/test_translate.py b/oslo_i18n/tests/test_translate.py
index 589df2e..54ea011 100644
--- a/oslo_i18n/tests/test_translate.py
+++ b/oslo_i18n/tests/test_translate.py
@@ -14,8 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from __future__ import unicode_literals
-
from unittest import mock
from oslotest import base as test_base
diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py
index 3cfce5d..d5c4cb8 100644
--- a/releasenotes/source/conf.py
+++ b/releasenotes/source/conf.py
@@ -40,10 +40,10 @@ extensions = [
]
# openstackdocstheme options
-repository_name = 'openstack/oslo.i18n'
-bug_project = 'oslo.i18n'
-bug_tag = ''
-html_last_updated_fmt = '%Y-%m-%d %H:%M'
+openstackdocs_repo_name = 'openstack/oslo.i18n'
+openstackdocs_bug_project = 'oslo.i18n'
+openstackdocs_bug_tag = ''
+openstackdocs_auto_name = False
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -98,7 +98,7 @@ exclude_patterns = []
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
+pygments_style = 'native'
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
diff --git a/releasenotes/source/locale/en_GB/LC_MESSAGES/releasenotes.po b/releasenotes/source/locale/en_GB/LC_MESSAGES/releasenotes.po
index 594dd92..005960b 100644
--- a/releasenotes/source/locale/en_GB/LC_MESSAGES/releasenotes.po
+++ b/releasenotes/source/locale/en_GB/LC_MESSAGES/releasenotes.po
@@ -1,15 +1,16 @@
# Andi Chandler <andi@gowling.com>, 2017. #zanata
# Andi Chandler <andi@gowling.com>, 2018. #zanata
# Andi Chandler <andi@gowling.com>, 2019. #zanata
+# Andi Chandler <andi@gowling.com>, 2020. #zanata
msgid ""
msgstr ""
-"Project-Id-Version: oslo.i18n\n"
+"Project-Id-Version: oslo.i18n Release Notes\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-11-06 04:11+0000\n"
+"POT-Creation-Date: 2020-05-26 13:59+0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"PO-Revision-Date: 2019-12-21 02:55+0000\n"
+"PO-Revision-Date: 2020-05-04 09:30+0000\n"
"Last-Translator: Andi Chandler <andi@gowling.com>\n"
"Language-Team: English (United Kingdom)\n"
"Language: en_GB\n"
@@ -19,6 +20,9 @@ msgstr ""
msgid "3.11.0"
msgstr "3.11.0"
+msgid "4.0.0"
+msgstr "4.0.0"
+
msgid "Introduce reno for deployer release notes."
msgstr "Introduce reno for deployer release notes."
@@ -40,11 +44,24 @@ msgstr "Rocky Series Release Notes"
msgid "Stein Series Release Notes"
msgstr "Stein Series Release Notes"
+msgid ""
+"Support for Python 2.7 has been dropped. The minimum version of Python now "
+"supported is Python 3.6."
+msgstr ""
+"Support for Python 2.7 has been dropped. The minimum version of Python now "
+"supported is Python 3.6."
+
msgid "Train Series Release Notes"
msgstr "Train Series Release Notes"
msgid "Unreleased Release Notes"
msgstr "Unreleased Release Notes"
+msgid "Upgrade Notes"
+msgstr "Upgrade Notes"
+
+msgid "Ussuri Series Release Notes"
+msgstr "Ussuri Series Release Notes"
+
msgid "oslo.i18n Release Notes"
msgstr "oslo.i18n Release Notes"
diff --git a/setup.cfg b/setup.cfg
index a0fce34..04e9dfe 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -25,17 +25,3 @@ classifier =
[files]
packages =
oslo_i18n
-
-[compile_catalog]
-directory = oslo_i18n/locale
-domain = oslo_i18n
-
-[update_catalog]
-domain = oslo_i18n
-output_dir = oslo_i18n/locale
-input_file = oslo_i18n/locale/oslo_i18n.pot
-
-[extract_messages]
-keywords = _ gettext ngettext l_ lazy_gettext _C:1c,2 _P:1,2
-mapping_file = babel.cfg
-output_file = oslo_i18n/locale/oslo_i18n.pot