Page MenuHomePhabricator

Import error for i18n module while using i18n.twhas_key() method
Closed, ResolvedPublic

Description

using Python Shell i18n.twhas_key() causes an exception:

>>> import pwb, pywikibot as py
>>> from pywikibot import i18n
>>> ms = 'redirect-broken-redirect-template'
>>> b = i18n.twhas_key('de', ms)

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    b = i18n.twhas_key('de', ms)
  File "pywikibot\i18n.py", line 500, in twhas_key
    transdict = getattr(__import__("i18n", fromlist=[package]), package).msg
ImportError: No module named i18n

This is because the module is imported from "i18n" instead from "scripts.i18n".
We have to use messages_package_name instead of hardcoded "i18n" here.

Event Timeline

Xqt closed this task as Resolved.
Xqt claimed this task.
Xqt raised the priority of this task from to Medium.
Xqt updated the task description. (Show Details)
Xqt subscribed.