summaryrefslogtreecommitdiff
path: root/oslo_i18n
Commit message (Collapse)AuthorAgeFilesLines
* Imported Translations from ZanataHEADmasterOpenStack Proposal Bot2023-05-061-0/+18
| | | | | | | For more information about this automatic import see: https://docs.openstack.org/i18n/latest/reviewing-translation-import.html Change-Id: I536264140a77d0b41cd13c25b48a0d073952cf57
* Remove unnecessary unicode prefixessongwenping2022-04-194-5/+5
| | | | Change-Id: Ia75cc0c9fd5117b22b54fe872b28a4164faedf9a
* Remove all usage of six libraryhaixin2020-11-2610-70/+20
| | | | | | Replace six with Python 3 style code. Change-Id: I3d2b0f7a78d4914913a3af3b68388392bf30b982
* Remove six.PY3wangzihao2020-09-234-23/+10
| | | | | | | The Python 2.7 Support has been dropped since Ussuri. So remove hacking rules for compatibility between python 2 and 3. Change-Id: Ibed92787d66227fec0cf48c78de8a24f9b39cc52
* Stop to use the __future__ module.Hervé Beraud2020-06-022-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | The __future__ module [1] was used in this context to ensure compatibility between python 2 and python 3. We previously dropped the support of python 2.7 [2] and now we only support python 3 so we don't need to continue to use this module and the imports listed below. Imports commonly used and their related PEPs: - `division` is related to PEP 238 [3] - `print_function` is related to PEP 3105 [4] - `unicode_literals` is related to PEP 3112 [5] - `with_statement` is related to PEP 343 [6] - `absolute_import` is related to PEP 328 [7] [1] https://docs.python.org/3/library/__future__.html [2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html [3] https://www.python.org/dev/peps/pep-0238 [4] https://www.python.org/dev/peps/pep-3105 [5] https://www.python.org/dev/peps/pep-3112 [6] https://www.python.org/dev/peps/pep-0343 [7] https://www.python.org/dev/peps/pep-0328 Change-Id: If01e22f2c01fdde9fc3569c243e805207b9cad88
* Remove a couple more shim testsBen Nemec2020-05-271-17/+0
| | | | | | | | Since we removed the translate function from Message, we no longer need tests for it. I missed removing these in I9ba75874f64c4d7118c7679015c2e0eab5a69e4a so let's do that now. Change-Id: Idfefcfe81521f6f5a9f0c197bd7998ffa31a4470
* Merge "Remove Message.translate"Zuul2020-05-272-44/+0
|\
| * Remove Message.translateBen Nemec2020-05-262-44/+0
| | | | | | | | | | | | | | | | | | | | This was deprecated in the Train cycle so we should be safe to remove it in Victoria. I don't expect this to affect any users of the library because the documented way to do a translation is to call the _translate.translate function, so although this is technically a public API change I don't believe anyone was actually using it. Change-Id: I9ba75874f64c4d7118c7679015c2e0eab5a69e4a
* | Add Babel aliases to get_available_languagesBen Nemec2020-05-222-4/+23
|/ | | | | | | | | | | | | | | | | | | | | | | | This pulls in the alias mapping from Babel[0] that previously made some two character locale names available. It simply appends each alias that is found by gettext.find to the list of available languages. This change in behavior was initially reported as a result of a breaking Glance unit test. After looking a bit closer at the test in question, it appears they mock out gettext.find to assume the existence of that locale. Whether it would actually exist in a real world deployment I have no idea. However, I don't think it hurts anything to include these aliases in the list checked by get_available_languages so this should be fine. Note that I did no mapping of the aliases in our override of gettext.find. There was no aliasing going on there for these two letter locales before either, so if they were found before they will be found now. The same is true if they were not found before, so this maintains the previous behavior. Change-Id: Ie57ed2ca0228634ed9a3def99bf606ce1832a195 0: https://github.com/python-babel/babel/blob/e7e4265d9a037ac38bba99f8513fb9e48a1081ba/babel/core.py#L80 Closes-Bug: 1877386
* Drop use of babelStephen Finucane2020-04-162-66/+26
| | | | | | | | | | | We were simply using this to get a list of language codes. Turns out Python provides a way to do this already via the 'locale' module, which provides all of the locales we care about [1]. Use this. [1] https://github.com/python/cpython/blob/3.5/Lib/locale.py Change-Id: Id6dce33fdbe3fc537dfe28d5cc604985b3347405 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
* Use unittest.mock instead of third party mockussuri-em4.0.1Sean McGinnis2020-03-317-10/+11
| | | | | | | | Now that we no longer support py27, we can use the standard library unittest.mock module instead of the third party mock lib. Change-Id: I597461bc2ce6a480ea18950ded606ef7db717f2d Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* [ussuri][goal] Drop python 2.7 support and testingHervé Beraud2020-02-061-39/+0
| | | | | | | | | | | | | | | OpenStack is dropping the py2.7 support in Ussuri cycle. Complete discussion & schedule can be found in - http://lists.openstack.org/pipermail/openstack-discuss/2019-October/010142.html - https://etherpad.openstack.org/p/drop-python2-support Ussuri Communtiy-wide goal: https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html Change-Id: I340a7909c49e7d2a8c82c668cbdaf9ced7196f67 Sem-Ver: api-break
* Deprecate Message.translate in favor of Message.translationBen Nemec2019-08-293-52/+77
| | | | | | | | | | | | | | | It shadows the unicode function of the same name, and there's no way to entirely disambiguate the two based on the parameter passed in. This change deprecates Message.translate and makes it a wrapper around the new function, Message.translation. Note that we never documented calling Message.translate directly. The documented way to get the translated form of a Message is to call the _translate.translate function in this project, so chances are that this public API change will have little actual impact on users. Change-Id: I0c617937f5af7467d1454f72acd0474ae2ce0293 Closes-Bug: 1841796
* Allow Message.translate to handle unhashable inputsBen Nemec2019-08-282-0/+35
| | | | | | | | | | | | | | | | | | | | | We made a mistake with the API of the Message class and shadowed the built-in function 'translate' from the unicode class that it inherits from. This means that our translate may be called with things like dicts and lists that are not hashable, which is problematic because we use that value as a dict key. Unhashable types are not allowed as dict keys so this fails. While ideally we would address this shadowing by renaming our version of translate, it is part of the public API of the library and thus we can't just change it arbitrarily. As a partial fix, this change adds a type check on the input parameter, and if it finds a type other than a string it calls the superclass's implementation of translate instead. This should handle most common uses of the stdlib translate, but since technically it is possible to use a string as input to that as well it doesn't fully address the problem. Change-Id: Ie68cba6af19d11de8968ee80ac10107f488acb92 Partial-Bug: 1841796
* Override getttext.find to cache result3.23.0Thomas Herve2018-11-212-0/+36
| | | | | | | | This monkey patches gettext to cache the results of gettext.find. This allows to drastically reduces system calls made over time for checking the existence of mo files, which don't move. Change-Id: I1464f131b90123aab67ef45ae2a2685a3ba111ef
* Remove unused codeChuck Short2018-08-211-4/+0
| | | | | | | | self.stubs and self.mox were left over from oslotest changes, so remove them. Change-Id: I00871c45672fadee9e93722543612b0bd9d76aea Signed-off-by: Chuck Short <chucks@redhat.com>
* Remove moxstubout usageCharles Short2018-05-191-5/+9
| | | | | | | | In newer versions of oslotest moxstubout is deprecated, so get out in front of the curve and replace it with mock. Change-Id: Ib7526bc5f7fc21cda9288e085216997519322010 Signed-off-by: Charles Short <zulcss@gmail.com>
* set default python to python3Doug Hellmann2018-04-161-1/+1
| | | | | | | | | | | | Set the default python to python3 except for the py27 environment. We have to set that explicitly to override the new default. As part of updating the pep8 job to run python 3 we need to remove the use of the python 2 builtin unicode(). We can use six.text_type() to produce the same result until we drop python 2 support. Change-Id: I43c03aeb73bb8a246115400bcbd9a0a68708abd9 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
* Imported Translations from ZanataOpenStack Proposal Bot2018-03-014-24/+24
| | | | | | | For more information about this automatic import see: https://docs.openstack.org/i18n/latest/reviewing-translation-import.html Change-Id: Ia748a2799ea85e33ffab786a2f4f6447d4bdca19
* Fix wrong response with language zh-TW.WangBinbin2017-02-201-3/+15
| | | | | | | When request OpenStack service with zh-TW, the response is zh-CN. Change-Id: I00601dec28adbef05e9ab0ebb6d291d0eee8becb Closes-Bug: #1665255
* Replace six.iteritems() with .items()Luong Anh Tuan2016-11-232-3/+2
| | | | | | | | | | | | We should avoid using six.iteritems/keys achieve iterators. We can use dict.items/keys instead, as it will return iterators in PY3 as well. And dict.items/keys will more readable. In py2, the performance about list should be negligible, see https://wiki.openstack.org/wiki/Python3 and http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html Change-Id: I8cdac1b75918094b9b3acbc65d53d231e86eca19
* Fix parameters of assertEqual are misplacedyanheven2016-07-232-16/+16
| | | | | | | | | | | | Many assertEqual sentences don't follow assertEqual(expected, actual), These misplaces have 2 impacts: 1, giving confusing messages when some tests failed. 2, mislead other developers, new test modules may follow these wrong pattern. This patch fix all of them. Change-Id: I33b5b59fda524d88386072d2058c4770a948db6f Closes-Bug: #1604213
* Imported Translations from Zanata3.7.0OpenStack Proposal Bot2016-06-0411-66/+43
| | | | | | | For more information about this automatic import see: https://wiki.openstack.org/wiki/Translations/Infrastructure Change-Id: I78d7939fc32332b6b704eec43c5b2ae1c945af30
* Better isolate tests and fixtures from environmentJoshua Harlow2016-03-242-5/+8
| | | | | | | | Remove a duplicate monkey patch as well as ensure that the environment the test is running in does not influence the test results (especially in regard to locale settings). Change-Id: I2451240148bb329e0ff9aa01f279bde9711e599f
* Imported Translations from Zanata3.4.0OpenStack Proposal Bot2016-02-211-0/+18
| | | | | | | For more information about this automatic import see: https://wiki.openstack.org/wiki/Translations/Infrastructure Change-Id: I58f5c1932ade80a7c39ed91db3160a2d7170168a
* Update translation setup3.3.0Akihiro Motoki2016-01-3112-8/+259
| | | | | | | | | | | | | | | | Follow new infra setup for translations, see spec http://specs.openstack.org/openstack-infra/infra-specs/specs/translation_setup.html for full details. This basically renames oslo.i18n/locale/oslo.i18n.pot to oslo_i18n/locale/oslo_i18n.pot. For this we need to update setup.cfg. Update also domain name in _i18n.py. Update unit test to adapt to domain name change. Change-Id: Ie016591a38dc0a83aadde501f882ee7849fa0c4f
* add versionadded designations to newer functionsDoug Hellmann2015-12-281-0/+4
| | | | | | | The base patch for this one adds a note to the guidelines. This patch adds similar information to the API reference. Change-Id: I6e21db2dd571aab3d33a97d93d989f986517d802
* Remove Python 2.6 workround for loggingChangBo Guo(gcb)2015-11-272-16/+0
| | | | | | | | You can find why we add it in [1], we don't support Python 2.6 any more, so we can remove the workaround now. [1] https://review.openstack.org/#/c/56093/8/openstack/common/gettextutils.py Change-Id: I5b67e3fcadbdd38f6e92e79f6549af5bafec29e4
* Drop python 2.6 supportChangBo Guo(gcb)2015-11-232-4/+2
| | | | Change-Id: Ibd2c83ad19ff9890a9baef7926a1d32fea156ecc
* Enhance the formatting error robustness patchBalazs Gibizer2015-09-292-23/+67
| | | | | | | | | This patch fixes the issues raised in the previous robustness patch I5c711b4654b5b2e591bcf365401ff35f7224fe82 Closes-bug: #1339337 Change-Id: I627c550e7bc05e56bbdffccf9bc88b88adf87aaf
* Trap formatting errorsBalazs Gibizer2015-08-242-14/+114
| | | | | | | | | | | | Trap errors when trying to use translated messages as format strings so translations don't break applications. Log the error, with the format string (without interpolated values) and the original message so a bug report can include it to make fixing the translation easier. Co-Authored-By: Doug Hellmann <doug@doughellmann.com> Change-Id: I5c711b4654b5b2e591bcf365401ff35f7224fe82 Closes-bug: #1339337
* Clean up _translate_msgid logic a bitDoug Hellmann2015-08-012-17/+80
| | | | | | | | Streamline the logic in _translate_msgid to a series of cascading if/elif statements to avoid having several different return points. Add some test coverage for situations not handled by existing test code. Change-Id: I9e0343757f515116c07f7f3fe1eab078046555e0
* Merge "Only define CONTEXT_SEPARATOR once"2.2.0Jenkins2015-07-242-2/+2
|\
| * Only define CONTEXT_SEPARATOR onceDoug Hellmann2015-07-022-2/+2
| | | | | | | | | | | | | | Replace 2 of 3 definitions of CONTEXT_SEPARATOR with a reference to the variable in _message.py. Change-Id: I37020ca7cf26b523d3739b5613ea5d9be9051e0a
* | Fix mock use for 1.1.0Doug Hellmann2015-07-121-1/+1
|/ | | | | | Use the correct method name to check the calls to the mock. Change-Id: Ibd7ab3f0a7f47682592b29cb238f78dae6337ba7
* Support contextual and plural form of gettext functionsPeng Wu2015-07-013-6/+195
| | | | | | | | | | | | | | This draft patch is created for more-gettext-support blueprint review. Refer URL: https://blueprints.launchpad.net/oslo.i18n/+spec/more-gettext-support https://review.openstack.org/#q,topic:bp/more-gettext-support,n,z Implements: blueprint more-gettext-support Depends-on: I258eac447ecc7b71fb02952077cf3ef3ecfe12bb Change-Id: Ic16d902ddfe94cfb5cfabe1c4f612ff001a8fa53
* Remove oslo namespace packageDoug Hellmann2015-06-042-11/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Blueprint remove-namespace-packages Depends-on: I5bd1cdc35d2ecaf98a0802fff589d8c37aaa8028 for openstack/django_openstack_auth Depends-on: I5da7ca7a8a909eb12a4417e7d5f5b6bd33da4de8 for openstack/horizon Depends-on: Ib17a74ada3122ce45c52fdd7dcf8d27fafbb1d70 for openstack/openstack-doc-tools Depends-on: I1f539cf9f5d6f48e10cac381c13eeb5fa314abd4 for openstack/python-ceilometerclient Depends-on: Ic21066211a071591854280a93a53bb2255cb8ad3 for openstack/python-ironicclient Depends-on: I387a7a1a817058a4daca313fe6df60612cb84864 for openstack/python-keystoneclient Depends-on: I32767615b2d678b6ce545722b6b9d1704cb1ffb4 for openstack/python-keystoneclient-saml2 Depends-on: Id26264ad0b002ab21e60431a2fd39fcecf76c490 for openstack/python-magnumclient Depends-on: Ib86c36f81f6fdbee64d88dd0b1d126bcc16649ac for openstack/python-manilaclient Depends-on: If5e8257085b5fd0a26a34705505fc0077adbabb2 for openstack/python-novaclient Depends-on: I37ce99d8c9a2ba5b97a12a0c2666f6340dbc7f42 for openstack/python-saharaclient Depends-on: I2a8caa859830b3416bfe54e4261dd3415ac5a76a for openstack/python-troveclient Depends-on: I324a3bd0c468a3e84f633497ad5c0d59c5ccc455 for openstack/python-tuskarclient Depends-on: Id54b2381f00d9905c4bb07821f54c5aaaa48d970 for openstack/python-zaqarclient Depends-on: I9d3e80d94795060d375aae30ce249513aae3fd97 for openstack/trove Change-Id: I1b100a426f84b91f9c5a9a857f420e36c209cbb4
* Add test fixture to prefix lazily translated messages1.4.0James Carey2015-01-282-0/+126
| | | | | | | | | | | | | | | | | This fixture enables testing of lazy translation by faking out translations by providing a translation that is the message id prefixed with the domain and language used in the translation. It supports the definition of new fake languages so that a different language can be specified without having to create the associated message catalogs. For example, this will be used to test that a fake language requested using the Accept-Language header is used to translate the message instead of the default language. That is, that the message was enabled for lazy translation and was not translated until just before it was returned to the user. Change-Id: If6dd28815d11c07ce9430ed07e61bfbc23695707 Partially-Implements: blueprint i18n-enablement-juno
* Clear global cache in test_get_available_languages1.3.1James Carey2015-01-191-0/+3
| | | | | | | | | | | | The test_get_available_languages test assumes that get_available_languages() has not been called prior to the test. That is, it assumes that the global variable _gettextutils._AVAILABLE_LANGUAGES does not already have a domain's languages cached in it. This causes problems if another test case uses get_available_languages(). In order to properly isolate this test case, it is updated to clear the cache prior to testing. Change-Id: Ie04d7d98b51f4cc3cc9f0eda69425349e0801d6f
* Add a fixture to let tests manage the lazy flag1.3.0Doug Hellmann2015-01-062-2/+62
| | | | | | | | We do not want to expose the stored lazy flag, but we do want to allow applications to force it to a certain state and then restore it to its original test for testing. This new fixture provides a way to do that. Change-Id: Ica05fd8fc7e687da69d61ea84bf1ceae65db93ce
* Correct the translation domain for loading messages1.2.0Doug Hellmann2014-12-221-1/+1
| | | | Change-Id: If7fa8fd1915378bda3fc6e361049c2d90cdec8af
* Move out of the oslo namespace packageDoug Hellmann2014-12-1823-0/+1890
Move the public API out of oslo.i18n to oslo_i18n. Retain the ability to import from the old namespace package for backwards compatibility for this release cycle. bp/drop-namespace-packages Change-Id: I800f121c271d8e69f6e776c4aef509bbb8008170