Commons talk:Message templates/todo-big

From Wikimedia Commons, the free media repository
Jump to: navigation, search

Some discussion at: User talk:Kylu/template.bas

Source code:

'clear the screen. Not really needed, but otherwise you might
'mistake this for a productive language or, at the least,
'something cool like perl or python instead of BASIC.

'Define the array to hold our list of language codes
'and another to hold our templates.
'If 255 of each isn't enough, we need a smaller wiki.
        DIM lang$(255), template$(255)

'Quote character, basic strings
        ' "
        q$ = CHR$(34)   '       "

        '  ! align="center" style="background:#ccccf"
        header$ = "! align=" + q$ + "center" + q$ + " style=" + q$ + "background:#ccccff" + q$ + " | "

        ' | align="center" |
        langheader$ = "| align=" + q$ + "center" + q$ + " | "

'Read data statements

'We're keeping the DATA statements here, though this is more for
'convenience than anything. In BASIC, I could have this at the
'beginning or the end, or spaced between statements and make
'a complete and total mess of it all.

        'Define the list of languages, ending with the keyword "end".
        DATA af,als,am,ang,ar,ast,av,ba,be,bg,br,bs,ca,cs,cy,da,de,el,en
        DATA eo,es,et,eu,fa,fi,fo,fr,gl,he,hi,hr,hu,ia,id,io,it,ja,kn,ko
        DATA kr,la,lb,lt,mg,mk,ms,nl,nn,no,oc,pl,pt,ro,ru,sk,sl,sq,sr,sv
        DATA ta,te,tg,th,tl,tr,tt,uk,vi,wuu,zh,zh-hans,zh-yue
        'I keep "lang" on the same line as "end" since it's the language
        'index. I suppose you could call it a bug that there's no
        'category commons-lang, but quite honestly it's not worth making
        'a special case out of it.
        DATA lang,end

        'Define our templates, ending with the keyword "end".
        DATA Speedywhat,copyvionote,End of copyvios,image source
        DATA test,test2,attackpage,attackimage,Welcome
        DATA Please link images,Please tag images,No tag message
        DATA Please name images,Please describe images
        DATA dont remove delete,dont remove nsd or nld
        DATA dont remove speedy,Do not overwrite
        DATA dont recreate,dont remove warnings,blocked
        DATA blocked User,imposter,sockpuppet,indefblockeduser
        DATA be civil,be civil final,Provide better quality
        DATA idw,Offtopic,Project scope
        DATA end

'First thing we do, read the list of languages
        numlangs = numlangs + 1
        READ lang$(numlangs)
        IF LCASE$(lang$(numlangs)) = "end" THEN
                numlangs = numlangs - 1
                GOTO rtemplates
        END IF
        GOTO rlangs

'Now we read the list of templates.
        numtemplates = numtemplates + 1
        READ template$(numtemplates)
        IF LCASE$(template$(numtemplates)) = "end" THEN
                numtemplates = numtemplates - 1
                GOTO maketemplate
        END IF
        GOTO rtemplates
'Yes, I very well could've used a while loop, but then again,
'why while away my time? :)

'This is where we make the template and print it to the file
'There's a few steps...
'maketemplate is the top of the routine, which we're referencing just
'to make sure that if we change the order of things later, the call
'point stays the same.

        'delete the old version of the template output file
        SHELL "if exist template.out erase template.out"
        'and make a new one, referencing it as file handle #1
        OPEN "template.out" FOR OUTPUT AS #1

        'Print the title
        PRINT #1, "=Templates requiring translation="
        'Top of the matrix...
        PRINT #1, "{| class=" + q$ + "toccolours" + q$ + " style=" + q$ + "margin: 0 1em 0 1em;" + q$
        PRINT #1, header$ + "[[Commons:Message templates|Template]]"

        '...and print out the line across the top showing the
        'language names, linked to the language category.
        FOR i = 1 TO numlangs
                PRINT #1, header$ + "[[:Category:Commons-" + LCASE$(lang$(i)) + "|" + UCASE$(lang$(i)) + "]]"
        NEXT i
        PRINT #1, "|-"

        'This one's pretty simple, just a pair of nested for/next loops
        'to make the matrix itself. It'll start the line with
        '|{{tl|templatename}} and then add a new template/language combo
        'each time.

        'Since BASIC is a crappy interpreted language, I put my remarks
        'here instead of inside the loop, by the way, because some
        'retarded interpreters actually //parse the remarks// each time
        'they come across them. Weird, eh?

        'The LOCATE and PRINT (without the #) statements are just a little
        'status indicator. Not really needed, but on some ancient
        'computers (like, er, mine) this actually takes a couple seconds
        'to do, so it's nice to see how long we have left. Or show if
        'the program crashed for some reason.

        'I'm all experty programmer like that.

        FOR i = 1 TO numtemplates
                PRINT #1, "|{{tl|" + template$(i) + "}}"
                FOR j = 1 TO numlangs
                        LOCATE 1, 1
                        PRINT "Template: "; template$(i), "Language: "; UCASE$(lang$(j))
                        PRINT #1, langheader$ + "[[Template:" + template$(i) + "/" + LCASE$(lang$(j)) + "|" + UCASE$(lang$(j)) + "]]"
                NEXT j
                PRINT #1, "|-"
        NEXT i

        'Stick the close-table on the end...
        PRINT #1, "|}"
        CLOSE #1
        'And we're done!
        PRINT "That's all, folks!"
  • Environment: Microsoft QuickBasic Extended (QBX 7.0). Should work fine with Microsoft QBASIC.
If you need it, it's available in a self-extracting archive from Microsoft at: or
FreeDOS runs QBASIC just fine.
  • OS: Works with anything from DOS 4.0 through Windows XP just fine. No pretty graphics though.
  • By: ~Kylu (u|t) 04:04, 22 November 2006 (UTC) (Yes, I'm actually admitting I wrote this.)
Hi Kyulu, could you add mg (Malagasy) please? Thanks in advance.
More complicated : add a specific style to each colomn, compute for each language the percentage of templates already translated and update the column styles with the result represented on a red to green scale :)
-- AlNo (talk) 10:10, 22 November 2006 (UTC)
Replied on my talkpage, where I saw the request first. :) ~Kylu (u|t) 18:48, 22 November 2006 (UTC)
Seen. Thanks a lot!
Just a suggestion about the code, in templateheader, do not link to a Commons-lang category:
        'Print the title
        PRINT #1, "=Templates requiring translation="
        'Top of the matrix...
        PRINT #1, "{| class=" + q$ + "toccolours" + q$ + " style=" + q$ + "margin: 0 1em 0 1em;" + q$
        PRINT #1, header$ + "[[Commons:Message templates|Template]]"

        '...and print out the line across the top showing the
        'language names, linked to the language category,
        'except for the "lang" column.
        FOR i = 1 TO numlangs
            IF LCASE$(lang$(i)) = "lang" THEN
                PRINT #1, header$ + UCASE$(lang$(i))
                PRINT #1, header$ + "[[:Category:Commons-" + LCASE$(lang$(i)) + "|" + UCASE$(lang$(i)) + "]]"
            END IF
        NEXT i
        PRINT #1, "|-"

(not tested!)
-- AlNo (talk) 09:16, 23 November 2006 (UTC)
I'd pondered it, but other than "end" (which doesn't get processed, of course) I dislike the idea of making special-cases like that. It's easy to go from small, efficient code to bulky, ugly, unmaintainable code that way. That's why I wrote that section the way I did. :( ~Kylu (u|t) 00:09, 24 November 2006 (UTC)


langs = [
templates = [
    'Speedywhat','copyvionote','Unfree','End of copyvios','image source','image permission',
    'Please link images','Please tag images','No tag message','Please name images',
    'Please describe images','dont remove delete','dont remove nsd or nld',
    'dont remove speedy','Do not overwrite','dont recreate','dont remove warnings','blocked',
    'blocked User','indefblockeduser','imposter','sockpuppet','Inappropriate username',
    'be civil','be civil final','Provide better quality',
    'Cdw','idw','Off topic','Project scope','No scaled down dupes'
header     = '! align="center" style="background:#ccccff" | '
langheader = '| align="center" | '

with open('template.txt','w') as f:
    f.write('=Templates requiring translation=\n')
    f.write('{| class="tocolours" style="margin: 0 1em 0 1em;"\n')
    f.write(header+'[[Commons:Message templates|Template]]\n')
    for l in langs:
    for t in templates:
        for l in langs:

For people who don't want to run dosbox and/or ancient dos software. Ionek (talk) 19:16, 11 September 2013 (UTC)