SystemPageLink

Description

This macro adds link to system page (page which included in i18n "all_pages" list).

Download & Release Notes

Download

Release Version

Moin Version

Release Notes

SystemPageLink-1.9.0-1.py

1

1.9.0

First release.

Usage

<<SystemPageLink(pagename, [description, [lang, [anchor, [params]]]])>>

<<SystemPageLink(pagename, [description="description string"], [lang="iso 639-1 lang code"], [anchor="anchor name"], [params="url query params"])>>

Parameter name

Description

pagename

name of system page linked to. Should be in i18n "all_pages" list, otherwise error returned.

description

description string, used as link text.

lang

Language which should be used. Value should be iso 639-1 language code, or "page" for page language, "user" for user language, "default" for default wiki instance language. If no language provided, macro tries to find existing page with name translated to language in next order: page language, user default language, instance default language, English (used even page doesn't exist).

anchor

Anchor on page link should point to. By default no anchor pointed.

params

URL query params. No params added by default.

Example

<<SystemPageLink(HelpOnEditing)>>
<<SystemPageLink(HelpOnParsers, "parsers help")>>
<<SystemPageLink(HelpOnParsers, "помощь по парсерам", "ru")>>
<<SystemPageLink(HelpOnParsers, "help on parsers in your language", "user")>>
<<SystemPageLink(HelpOnProcessingInstructions, "format instruction", "en", "format")>>
<<SystemPageLink(RecentChanges, "RC in german for last 90 days", "de", "", "max_days=90")>>

<<SystemPageLink(pagename=HelpOnEditing)>>
<<SystemPageLink(HelpOnParsers, description="parsers help")>>
<<SystemPageLink(HelpOnParsers, lang="ru")>>
<<SystemPageLink(HelpOnProcessingInstructions, anchor="format", lang="de")>>
<<SystemPageLink(RecentChanges, params="max_days=90")>>

2009 EugeneSyromyatnikov

License

GNU GPL

Bugs

Discussion

RenatoSilva - Hi Eugene. What's the possibility of using the master wiki pos as source for translation, rather than MoinMoin/i18n/*.po? Also, how about opening a feature request for adding your macro to master wiki? I think it would be really useful there :)

Merge with code base?

Advantages

Disadvantages

IRC conversation

   1 <RenatoSilva> someone *please* add http://moinmo.in/MacroMarket/SystemPageLink to Moin code base
   2 <RenatoSilva> when you change page title translation, you not just need to update the references in the po file (see http://moinmo.in/MoinMoinBugs/ShouldAlwaysTranslateSystemPageTitles), but much more annoying, you need to update *every* system page containing links for the page
   3 <ThomasWaldmann> RenatoSilva: that's the usual procedure if you rename a page
   4 <RenatoSilva> regular pages, not system pages
   5 <RenatoSilva> system pages are special
   6 <ThomasWaldmann> every page :)
   7 <RenatoSilva> no, system pages are *translatable* by default
   8 <ThomasWaldmann> I am not sure we should specialcase that.
   9 <ThomasWaldmann> We have link markup, using a macro for that reinvents the wheel (except for the translation part).
  10 <RenatoSilva> ThomasWaldmann: current behavior is annoying for translators: if you rename a page title or actually create a translation page, you need to update every gettext message and *all* system pages
  11 <RenatoSilva> ThomasWaldmann: link markup? how would it do the same job of that macro?
  12 <ThomasWaldmann> as I said: that is nothing special, you need to update all links for any page you rename
  13 <ThomasWaldmann> not only for sys pages
  14 <TheSheep> how often do you rename pages?
  15 <ThomasWaldmann> RenatoSilva: the problem is rather that this link macro must do all that link markup can do sooner or later.
  16 <RenatoSilva> ThomasWaldmann: [[<<GetText(SystemPageName)>>]] doesn't work
  17 <ThomasWaldmann> sure it doesn't
  18 <RenatoSilva> ThomasWaldmann: even if worked, would not work still because we need [[<<GetText(SystemPageName, lang=that page's lang)>>]]
  19 <ThomasWaldmann> so how about avoiding renames by choosing good names from the start? :)
  20 <RenatoSilva> Maybe SystemPageLink could be extended to any page
  21 <RenatoSilva> in fact I don't see much sense in such restriction
  22 <RenatoSilva> ThomasWaldmann: tell this to all contributors, and ensure they all will follow you
  23 <RenatoSilva> ThomasWaldmann: I am renaming the pages for fixing the mess
  24 <RenatoSilva> ThomasWaldmann: such as: I need to translate CategoryCategory, but CategoriaCategoria is locked by another language
  25 <RenatoSilva> that's why I requested http://moinmo.in/FeatureRequests/MultiLanguagePages btw
  26 <ThomasWaldmann> so do you expect that you create another mess that you need to cleanup later again or why do you want to use that macro?
  27 <dreimark_> looks like an idea for a rewrite for moin 2.0
  28 <RenatoSilva> ThomasWaldmann: btw, there's also http://moinmo.in/FeatureRequests/UpdateReferencesWhenRenamingPages if you really wanna talk about page renaming
  29 <ThomasWaldmann> i don't
  30 <RenatoSilva>  so you want to keep the mess? :P
  31 <ThomasWaldmann> maybe you could fix the mess like everybody else does?
  32 <RenatoSilva> of course
  33 <RenatoSilva> but why don't you like the idea if someone write a patch
  34 <RenatoSilva> I would write myself if I had time
  35 <ThomasWaldmann> you didn't answer "so do you expect that you create another mess that you need to cleanup later again or why do you want to use that macro?"
  36 <RenatoSilva> and the way I described there, I believe it woud work amazingly
  37 <ThomasWaldmann> because the macro is not at all places you maybe wish it would be
  38 <ThomasWaldmann> thus, you would have to edit all places linking to sys pages, which is more work than just editing the few ones you rename
  39 <RenatoSilva> ThomasWaldmann: I want that macro because when I write UmaPáginaDeSistema in some system page, actually I mean "the translation for SomeSystemPage", NOT really "UmaPáginaDeSistema"
  40 <RenatoSilva> ThomasWaldmann: you must have in mind that there are a LOT of system pages (in pt-br for example) which are currently untranslated
  41 <RenatoSilva> ThomasWaldmann: if I would start translating them all, I would have a LOT of work on updating the page links
  42 <ThomasWaldmann> yeah, I see the point for freshly written stuff. but still, it is duplicating (or tries to) link markup functionality.
  43 <RenatoSilva> ThomasWaldmann: however I agree it may cause problems (the macro call won't be recognized as a raw link etc)
  44 <RenatoSilva> link markup functionality doesn't include what this macro would do
  45 <ThomasWaldmann> no, but the other way
  46 <ThomasWaldmann> and less powerful and inconsistent, because it is a macro
  47 <ThomasWaldmann> e.g. link markup [[foo#bar]], but <<SystemPageLink(foo, anchor="bar")
  48 <ThomasWaldmann> e.g. link markup [[foo|bar|class=baz]], but <<SystemPageLink(foo, bar, FAIL)>>
  49 <RenatoSilva> how about the following: if you pass a system page to [[, it tries to get the translation first
  50 <RenatoSilva> so [[WikiName]] in a pt-br page will be rendered as WikiNomes
  51 <ThomasWaldmann> no
  52 <RenatoSilva> why
  53 <ThomasWaldmann> that's black magic
  54 <RenatoSilva> hahahaha
  55 <ThomasWaldmann> one could do it when asked for
  56 <ThomasWaldmann> but, you need a method then fitting into the current param scheme somehow
  57 <RenatoSilva> I don't get you
  58 <ThomasWaldmann> there are 2 sorts of link params right now
  59 <ThomasWaldmann> 1. link tag attrs (class, target, ...)
  60 <ThomasWaldmann> 2. query string args
  61 <ThomasWaldmann> there is no "I have special wishes for processing" sort
  62 <ThomasWaldmann> at least IIRC
  63 <ThomasWaldmann> hmm, i have weird idea :)
  64 <ThomasWaldmann> [[EnglishName||&lang=pt-br]]
  65 <RenatoSilva> my intention is to change [[ to just modify the page name while rendering
  66 <TheSheep> ThomasWaldmann: why &?
  67 <ThomasWaldmann> that will link to EnglishName, but give &lang=pt-br in qs
  68 <dreimark_> ThomasWaldmann: param syntax
  69 <TheSheep> ThomasWaldmann: how about ?action=localize ?
  70 <dreimark_> TheSheep: ^^
  71 <ThomasWaldmann> but what shall moin do when receiving such a request? translate, then redirect?
  72 <TheSheep> dreimark_: I know, but shouldn't it be handled by parser, not dispatcher?
  73 <RenatoSilva> [[EnglishName||&lang=pt-br]] is redundant, as it will be used only in pt-br pages, mostly, and would be repeated for each link in the page
  74 <TheSheep> ThomasWaldmann: yeah
  75 <ThomasWaldmann> when used heavily, that would mean all non-english syspages would use 2 requests
  76 <TheSheep> ThomasWaldmann: it could also just translate and leave the url as is
  77 <ThomasWaldmann> worse
  78 <RenatoSilva> TheSheep: disagree
  79 <dreimark_> that is an other option
  80 <dreimark_> bbl
  81 <TheSheep> or it could be handled by the parser, generating the correct link right away
  82 <RenatoSilva> I believe the <a> msut be translated
  83 <TheSheep> RenatoSilva: why?
  84 <RenatoSilva> and maybe other parts of Moin should be aware that such link in translated/able, so that it tries to translate it everywhere
  85 <ThomasWaldmann> RenatoSilva: you don't want that your pt-br page links to en page, just because user agent has en first?
  86 <RenatoSilva> TheSheep: you would read a sytem page saying "veja RecentChanges", but users have no idea what RecentChanges means, even if the link would redirect to the translation
  87 <ThomasWaldmann> right, it doesn't get translated if based on action-like behaviour(i mean the rendering)
  88 <RenatoSilva> ThomasWaldmann: the link would be translated to the page's #language, translating to any other lang (or not translating at all) is non-sense
  89 <TheSheep> ok, but if you change the text that is actually displayed, you may destroy the sentence
  90 <ThomasWaldmann> ok, so it means that we need some special sort of param
  91 <RenatoSilva> ThomasWaldmann: a russian user can be reading a portuguese page, that's not a reason to the links be in russian in the portuguese page
  92 <TheSheep> if someone renames the page, for example changing the order of words, it would lead to a completely uncomprehensible sentence in many languages, and to sentence with different meaning in others
  93 <ThomasWaldmann> and the language needs to be explicitely given, otherwise you rely on that there is one single language what might be not true
  94 <RenatoSilva> it is true as long as you don't implement multi-lang pages :)
  95 <ThomasWaldmann> (and if you don't give the language, how shall link parser know that you want special treatment? it would just create a normal link otherwise)
  96 <RenatoSilva> ThomasWaldmann: it would know because the link is for a system page
  97 <ThomasWaldmann> anyway, it looks like this is rather for moin2+ :)
  98 <TheSheep> you would need 'OldSystemPagesGroup' for that ;)
  99 <RenatoSilva> ThomasWaldmann: it just needs a search in i18n.strings
 100 <RenatoSilva> TheSheep: destroy the sentence? I don't understand
 101 <ThomasWaldmann> note: one problem of the 1.5 link markup was that it was complex, buggy and doing magic stuff
 102 <ThomasWaldmann> i don't want to have that back :)
 103 <RenatoSilva> ThomasWaldmann: man I believe we don't need to change the [[ syntax, we just need some action behind the scenes
 104 <TheSheep> RenatoSilva: you cannot just swap out parts of sentences in different languages and expect them to still make sense, even if those parts have the same meaning when read alone
 105 <ThomasWaldmann> btw, maybe someone can c&p this discussion to the relavant wiki pages, so we don't need to repeat it :)
 106 <RenatoSilva> ThomasWaldmann: look: [[RegularPage]] -> ok, the same behavior, nothing changes, [[SystemPage]] --> translate <a> everywhere, for example search fo the translated name would return this entry (ok a bit weird)
 107 <TheSheep> RenatoSilva: suppose you rename FindPage to PageSearching, and there is a sentence that says "You can FindPage by entering some text in the forms there." <-- a quick example, not very plausible, but you get the idea
 108 <RenatoSilva> TheSheep: ok I get the idea, but I would avoid this kind of sentence
 109 <RenatoSilva> TheSheep: and I wonder if any en page has such a thing
 110 <TheSheep> I think it's normal to incorporate page names into sentences like that in wikis, especially the older ones.
 111 <TheSheep> like c2 and meatball
 112 <ThomasWaldmann> yeah, show me RecentChanges :)
 113 <RenatoSilva> this sentence woud not have problems with renaming
 114  * ThomasWaldmann has to do some work
 115 <RenatoSilva> TheSheep: well, I would avoid such procedure because it is by nature dangerous as you said
 116 <TheSheep> that's why moin doesn't have a 'rename all links when renaming a page' option

I have only one real argument for using his macro — when native language translation is incomplete (page names translated, but pages itself are not translated or not installed), and fallback language (usually English) is completely installed, so normal links in underlay/system will be broken, but other places which using gettext for getting pagename (for example, in themes) usually will work because they are already have similar fallback code. -- EugeneSyromyatnikov 2010-01-19 18:13:20

MoinMoin: MacroMarket/SystemPageLink (last edited 2010-01-25 19:21:26 by RenatoSilva)