-
Notifications
You must be signed in to change notification settings - Fork 104
feat: Add widget for listing pages that need translation #7249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LemurVladimir
wants to merge
10
commits into
Liquipedia:main
Choose a base branch
from
LemurVladimir:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5072810
[feat] Listing articles in need of translation
LemurVladimir 12ea977
Change condition type from 'trans' to 'translation'
LemurVladimir 69ba257
Add TranslationNeededList.lua as a substitution to TranslationList.lua
LemurVladimir c261d60
Delete TranslationList.lua as deprecated
LemurVladimir 0410eae
Merge branch 'main' into main
LemurVladimir 56150d5
Add assertion to ensure limit is a number
LemurVladimir 34ea45a
Merge branch 'main' into main
LemurVladimir 5813caa
Rework limit definition per suggestions.
LemurVladimir 5ba5a47
Add MathUtil import to definitions
LemurVladimir 4a0d105
Fix limit assertion to use self.props.limit
LemurVladimir File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| -- @Liquipedia | ||
| -- page=Module:Widget/TranslationNeededList | ||
| -- | ||
| -- Please see https://github.com/Liquipedia/Lua-Modules to contribute | ||
| -- | ||
|
|
||
| local Lua = require('Module:Lua') | ||
|
|
||
| local Array = Lua.import('Module:Array') | ||
| local Class = Lua.import('Module:Class') | ||
| local Variables = Lua.import('Module:Variables') | ||
| local MathUtil = Lua.import('Module:MathUtil') | ||
|
|
||
| local Link = Lua.import('Module:Widget/Basic/Link') | ||
| local HtmlWidget = Lua.import('Module:Widget/Html/All') | ||
| local Widget = Lua.import('Module:Widget') | ||
|
|
||
| ---@class TranslationNeededList: Widget | ||
| ---@operator call(table): TranslationNeededList | ||
| local TranslationNeededList = Class.new(Widget) | ||
| TranslationNeededList.defaultProps = { | ||
| limit = 3, | ||
| } | ||
|
|
||
| ---@return Widget[] | ||
| function TranslationNeededList:render() | ||
| local limit = assert(MathUtil.toInteger(self.props.limit), "Limit must be a number") | ||
|
|
||
| local translations = TranslationNeededList._getTranslations() | ||
| Variables.varDefine('total_number_of_translations', #translations) | ||
|
|
||
| translations = Array.sub(Array.randomize(translations), 1, limit) | ||
|
|
||
| return HtmlWidget.Ul{children = Array.map(translations, function(translation) | ||
| return HtmlWidget.Li{ | ||
| children = { | ||
| Link{link = translation.pagename, children = {translation.name}}, | ||
| } | ||
| } | ||
| end)} | ||
| end | ||
|
|
||
| ---Fetches "Translations" datapoints | ||
| ---@private | ||
| ---@return datapoint[] | ||
| function TranslationNeededList._getTranslations() | ||
| return mw.ext.LiquipediaDB.lpdb('datapoint', { | ||
| limit = 5000, | ||
| conditions = '[[type::translation]]' | ||
| }) | ||
| end | ||
|
|
||
| return TranslationNeededList | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the use case of this variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be used to display the number of articles that are in need of translation via the Module:Widget/MainPage/WantToHelp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module:Widget/MainPage/WantToHelpuses a different wiki varso i doubt this will work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the proposed var to the local version of that widget, line 160.
If needed I will add it to the repo version of that module but that would require additional code to exclude that block from the non-english (basically all but dota2gameru) wikis.