jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/500712 )
Change subject: Revert "[feat] Allow i18n.translate fallback to wikibase item" ......................................................................
Revert "[feat] Allow i18n.translate fallback to wikibase item"
This reverts commit 2529e6a592fe36f79c88f222674542c4ffa2b55c
made by mistake. btw all travis tests are failing with that patch
Change-Id: I746b54f42dafc3e03b2662655ef12bddc9cf4af2 --- M pywikibot/i18n.py M tests/i18n_tests.py 2 files changed, 9 insertions(+), 33 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py index bff1416..4000a51 100644 --- a/pywikibot/i18n.py +++ b/pywikibot/i18n.py @@ -43,8 +43,7 @@ from pywikibot.exceptions import Error from pywikibot.plural import plural_rules from pywikibot.tools import ( - deprecated, deprecated_args, issue_deprecation_warning, StringTypes, - UnicodeType) + deprecated, deprecated_args, issue_deprecation_warning, StringTypes)
PLURAL_PATTERN = r'{{PLURAL:(?:%()?([^)]*?)(?:)d)?|(.*?)}}'
@@ -584,9 +583,8 @@ @param parameters: For passing (plural) parameters @type parameters: dict, string, unicode, int @param fallback: Try an alternate language code. If it's iterable it'll - also try those entries and choose the first match. If it's wikibase - item, it'll try to load local page title from here. - @type fallback: bool, iterable or str + also try those entries and choose the first match. + @type fallback: boolean or iterable @raise IndexError: If the language supports and requires more plurals than defined for the given translation template. """ @@ -612,7 +610,7 @@ codes = [code] if fallback is True: codes += _altlang(code) + ['_default', 'en'] - elif fallback is not False and not isinstance(fallback, UnicodeType): + elif fallback is not False: codes += list(fallback) for code in codes: if code in xdict: @@ -620,17 +618,11 @@ break else: if fallback is not True: - if isinstance(fallback, UnicodeType): - r_page = pywikibot.Site(code, family).page_from_repository( - fallback) - trans = r_page.title() - else: - # this shouldn't simply return "any one" code - # but when fallback was True before 65518573d2b0, - # it did just that. When False it did just return - # None. It's now also returning None in the new - # iterable mode. - return + # this shouldn't simply return "any one" code but when fallback + # was True before 65518573d2b0, it did just that. When False it + # did just return None. It's now also returning None in the new + # iterable mode. + return code = list(xdict.keys())[0] trans = xdict[code] if trans is None: diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py index 6d5396f..3b700fe 100644 --- a/tests/i18n_tests.py +++ b/tests/i18n_tests.py @@ -87,22 +87,6 @@ 'test-no-english JA')
-class TestTranslateNonDry(TestCase): - - """Test translate method.""" - - family = 'wikipedia' - code = 'cs' - - msg_localized = {'en': 'Universe', 'de': 'Universum'} - - def testWikibaseFallback(self): - """Test Wikibase item fallback.""" - self.assertEqual(i18n.translate(self.code, self.msg_localized, - fallback='Q1'), - 'Vesmír') - - class UserInterfaceLangTestCase(TestCase):
"""Base class for tests using config.userinterface_lang."""