Skip to content

Conversation

@jhsoby
Copy link
Member

@jhsoby jhsoby commented Apr 9, 2025

Use localization on-wiki (via a page in the Data namespace on Commons) for all localizable strings, in conjunction with the new UKB module. With this change, the module will be used both for localization of on-wiki templates and texts, in addition to all localizable text used in the bot and output by the bot.

As part of this rework, I have also removed a lot of commented-out WIP code or code used for testing/debugging, and fixed some instances of hard-coded Norwegian things (like the {{Kolonner}} template).

Warning

Do not merge until the new UKB module is in place on all wikis that have contests!

jhsoby added 11 commits April 6, 2025 16:49
Add i18n function that will output a substing of Module:UKB
with the getMessage function, instead of the current gettext
setup.
Replace the _() function with the new i18n() function in all
of the main files, except for the "{{Kolonner}}" template,
which I'll have to figure out something else for.
Remove code that has been commented out for various reasons;
most (all?) of this is several years old, and I doubt even
Dan Michael will remember what the purpose of it is/was.
Turns out the approach I first tried, with substing the module,
had a major flaw: Expansion limits. After relatively few substitutions,
all it would result in was Scribunto/Lua errors instead.

So this approach instead uses a new function from that module that
outputs all the i18n stuff we have in JSON, and then parses that JSON
and makes some substitutions as necessary.

I've chosen to make it `subst:` all magic words except for {{formatnum:}},
so that the end users shouldn't actually see {{PLURAL:}} etc.
Insert the UKB module with its getMessage() function if the message
key doesn't exist. This will let the module track uses of
non-existing messages, so that can be fixed via the bot's code
or fixed by adding the message to the Data file on Commons.
Remove the hard-coding of the {{kolonner}} template; replace it
with a potential config line, or if there is no config, an
empty div element with a special class (so that the functionality
of {{kolonner}} can be added to a UKBot-specific TemplateStyles
page).

This partially fixes #23.
No longer used for anything.
@jhsoby jhsoby requested a review from zache-fi April 9, 2025 12:19
@jhsoby jhsoby requested a review from DiFronzo April 9, 2025 13:43
@DiFronzo DiFronzo requested a review from Copilot April 9, 2025 19:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 40 out of 43 changed files in this pull request and generated 1 comment.

Files not reviewed (3)
  • MANIFEST.in: Language not supported
  • Makefile: Language not supported
  • locale/messages.pot: Language not supported
Comments suppressed due to low confidence (1)

ukbot/contest.py:664

  • [nitpick] The log message is unclear; consider rewording it to something like 'Sending receipt to %s' to improve readability.
logger.info('Sending %s a deliver_receipt_to_leaders', page.name)

Clarify message and fix typo discovered by Copilot, change bot's
contact email in user agent per @DiFronzo.
jhsoby and others added 9 commits July 21, 2025 16:49
Clarify message and fix typo discovered by Copilot, change bot's
contact email in user agent per @DiFronzo.
Exchange setup.py for the more modern approach, pyproject.toml, update
requirements.txt based on current requirements, and add bot version to
ukbot.py output.

This fixes #59.
It confirms that standard prefixes like 'en' and 'de' are properly
registered, while also validating the behavior with edge cases such as
an empty string (''), None, capitalized forms like 'UPPERcase', and
prefixes with leading/trailing whitespace like ' en '. The tests also
verify that the class remains working when unknown or invalid prefixes
(like 'zz', 'not_in_map', or the integer 42) are passed and they are not
added to the interwikimap.

<!--
This PR fixes the Issue
-->

- [x] 🍕 Feature
- [x] ✅ Test

Fixes #79

- [x] 👍 yes

- [ ] 📜 README.md
- [ ] 📖 own file under the docs folder
- [x] 🙅 no documentation needed

<!--
Write about changing templates or modules on-wiki in order to accomodate
changes in this PR
-->
…ct (#56)

First draft to issue templates, contributing guidelines, and code of
conduct.
Exchange setup.py for the more modern approach, pyproject.toml, update
requirements.txt based on current requirements, and add bot version to
ukbot.py output.

This fixes #59.
#88)

…3" in jobs.yaml

## Description

There was a custom Elokuun kuvitustalkoot config in 2023, probably
because of incorrect competition settings, and it was worked around by
using a different competition ID. However, since it only worked in 2023,
I have now reverted the jobs.yaml back to the multiyear config.

NOTE: This is also updated now directly to production as the competition
is already started.
Note: I did the change already directly to production to test it so it
needs to be reverted from ukbot/rules/image.py before pulling it.
DiFronzo and others added 2 commits November 21, 2025 15:45
…warnings for missing categories and unrecognized wikis (#67)

This PR adds enhanced error handling in contest filters, logging
non-fatal warnings for missing categories and unrecognized wikis.

It has been tested, but there may still be edge cases I haven’t
considered.

It will show in console like this:
![Screenshot 2025-05-25 at 16 36
47](https://github.com/user-attachments/assets/4f5310d5-3b61-4b74-a692-428b0e7babfa)
On
wiki[[1](https://no.wikipedia.org/w/index.php?title=Bruker:Premeditated/Sandkasse5&oldid=25156842)]:
![Screenshot 2025-05-25 at 16 38
26](https://github.com/user-attachments/assets/d31482eb-8ce0-464b-a4e2-f919ed04d93d)

- [ ] 🍕 Feature
- [X] 🐛 Bug Fix
- [ ] 📝 Documentation Update
- [ ] 🎨 Style
- [x] 🧑‍💻 Code Refactor
- [ ] 🔥 Performance Improvements
- [ ] ✅ Test
- [ ] 🤖 Build
- [ ] 🔁 CI
- [ ] 📦 Chore
- [ ] ⏩ Revert

Fixes #62

- [X] 👍 yes
- [ ] 🙅 no, because they aren't needed
- [ ] 🙋 no, because I need help

- [ ] 📜 README.md
- [ ] 📖 own file under the docs folder
- [X] 🙅 no documentation needed

perform?
No

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants