Page MenuHomePhabricator

i18n.twtranslate does not use fallback_prompt if an unknown package is given
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

>>> import pywikibot
>>> from pywikibot import i18n
>>> i18n.twtranslate('en', 'unknown_package', fallback_prompt='foo')


>>> i18n.twtranslate('en', 'unknown_package', fallback_prompt='foo')

What happens?:

For 'en'

Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    i18n.twtranslate('en', 'unknown_package', fallback_prompt='foo')
  File "D:\pwb\GIT\core\pywikibot\i18n.py", line 749, in twtranslate
    raise pywikibot.exceptions.TranslationError(fill(
pywikibot.exceptions.TranslationError: No English translation has been defined for TranslateWiki key
"unknown_package". It can happen due to lack of i18n submodule or
files or an outdated submodule. See
https://www.mediawiki.org/wiki/Manual:Pywikibot/i18n

For 'es':

Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    i18n.twtranslate('es', 'unknown_package', fallback_prompt='foo')
  File "D:\pwb\GIT\core\pywikibot\i18n.py", line 749, in twtranslate
    raise pywikibot.exceptions.TranslationError(fill(
pywikibot.exceptions.TranslationError: No English translation has been defined for TranslateWiki key
"unknown_package". It can happen due to lack of i18n submodule or
files or an outdated submodule. See
https://www.mediawiki.org/wiki/Manual:Pywikibot/i18n

What should have happened instead?:
The fallback_prompt should be returned:

'foo'

Software version (skip for WMF-hosted wikis like Wikipedia):
Pywikibot < 8 if i18n files are updated after 26th September 2022; maybe also Pywikibot 8 if i18n files are older than 28th December 2021.

Other:
See also https://translatewiki.net/wiki/Thread:Support/Pywikibot:Cosmetic_changes-append/en

Related Objects

Event Timeline

Xqt triaged this task as High priority.Jan 7 2023, 2:25 PM

Change 876308 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/i18n@master] [i18n] Revert "Remove 'cosmetic_changes-append' translations from Pywikibot"

https://gerrit.wikimedia.org/r/876308

Change 876308 merged by jenkins-bot:

[pywikibot/i18n@master] [i18n] Revert "Remove 'cosmetic_changes-append' translations from Pywikibot"

https://gerrit.wikimedia.org/r/876308

Change 876312 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [doc] Add deprecation of 'cosmetic_changes-append' to ROADMAP.rst

https://gerrit.wikimedia.org/r/876312

Change 876312 merged by Xqt:

[pywikibot/core@master] [doc] Add deprecation of 'cosmetic_changes-append' to ROADMAP.rst

https://gerrit.wikimedia.org/r/876312

Change #1181244 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] i18n: Refactor twtranslate to unify fallback_prompt handling

https://gerrit.wikimedia.org/r/1181244

Change #1181244 merged by jenkins-bot:

[pywikibot/core@master] i18n: Refactor twtranslate to unify fallback_prompt handling

https://gerrit.wikimedia.org/r/1181244

Xqt claimed this task.

Hello @Xqt - Just ran across this issue today (cf. P82568) while using archivebot.py (which has been running there for some time). I'm using pywikibot master branch with Python3.13 on Toolforge.