jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
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(-)

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."""

To view, visit change 500712. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I746b54f42dafc3e03b2662655ef12bddc9cf4af2
Gerrit-Change-Number: 500712
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki@gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus@gmx.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999@gmail.com>
Gerrit-Reviewer: jenkins-bot (75)