Jump to content
MediaWiki

Module:Caller title

From mediawiki.org
Module documentation

This module simply returns the title of the page calling this module. It’s intended for templates translated using the Translate extension. It has two entry points, both can be called with {{#invoke:Caller title|entry point name}}:

title
Get the full title of the template.
lang
Get the language code (subpage name). In fact, it doesn’t check if the subpage name is a valid language code, so if called from X/y/z, it’ll happily return z. The template using this functionality should ensure it’s only used on language subpages (or be okay with garbage output). An additional |base= parameter can be given with the full title of the translation base page, so that page language is used on that page (as there is no language code subpage there).
The above documentation is transcluded from Module:Caller title/doc. (edit | history)
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.

 localp={}

 functionp.title(frame)
 returnframe:getParent():getTitle()
 end

 functionp.lang(frame)
 localbase=frame.args.base
 localtitle=p.title(frame)
 ifbase~=titlethen
 localparts=mw.text.split(p.title(frame),'/',true)
 returnparts[#parts]
 else
 -- we’re on the base page of the translation (directly, it’s not translated from somewhere),
 -- so we have no subpage language code, but we use PAGELANGUAGE
 returnframe:preprocess('{{PAGELANGUAGE}}')
 end
 end

 returnp

AltStyle によって変換されたページ (->オリジナル) /