Page MenuHomePhabricator

Add {{#translation}} as parser function in the Translate extension
Closed, ResolvedPublic

Description

Author: pr4tiklahoti

Description:
{{translate}} needs to be added as a magic word for it to be used by Special:PagePreparation, a tool for preparing the page for translation.


Version: unspecified
Severity: normal

Details

Reference
bz68385

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 3:39 AM
bzimport set Reference to bz68385.
bzimport created this task.Jul 22 2014, 5:10 PM

Cc the creator of [[mw:Template:Translation]], Happy-melon, and some others, in case they want to specify some requirements for such a magic word.

Change 148759 had a related patch set uploaded by BPositive:
'translation' added as magic word in Translate extension

https://gerrit.wikimedia.org/r/148759

I want the magic word to start with # sign.

Niklas veto'ed any {{translation}} magic word for fear of incompatibility with existing templates, so it's useless to discuss about it. For now making a non-standard magic word prefixed by # is easiest.

As compatibility with existing wikitext is no longer an aim, should we also change the syntax from [[Category:A{{translation}}|B]] to {{#translation:Category:A|B}} (in a followup patch)?

The {{#translation}} parser function could also be used to transclude translatable templates in the future: is this in scope for Translate, Niklas? If the answer is yes, BPositive, please file a separate bug for that.

Change 148759 merged by jenkins-bot:
'#translation' added as magic word in Translate extension

https://gerrit.wikimedia.org/r/148759

(In reply to Nemo from comment #4)

As compatibility with existing wikitext is no longer an aim, should we also
change the syntax from [[Category:A{{translation}}|B]] to
{{#translation:Category:A|B}} (in a followup patch)?

Not a very good idea. In my opinion, '#translation' should not be generate wikilinks, only pagename in plain text.

Instead [[Category:A{{translation}}|B]] should be approximately next code: [[{{#translation:Category:A}}|B]]. By common way, pipe ("|") is traditionally used as delimanation simbol for parser functions; it may still be needed in this case.

Niklas, maybe update this feature, to make it work not only for currrent page, as {{#translation:}} (current state) - but also for specified target page, as {{#translation:pagename}} or {{#translation:namespace:pagename}} ?

This will be useful for eliminate widely used templates {{ifTranslation}}/{{ifNotTranslation}}, {{TNT}}/{{TNTN}} and {{Ll}}.

(In addition to comment #7)

Taret result for my proposal:

  1. if current page is translation, and {{#translation:}} is returned "/code", then {{#translation:pagename}} should be return "pagename/code" (if this page is exist) or "pagename" otherwise;
  1. if current page is _not_ a translation, and {{#translation:}} is returned empty result, {{#translation:pagename}} should be return "pagename"

(In addition to comment #7 and comment #8)

maybe this should be separate magic word, as '#tlink' or '#tl'?

(In reply to Paul Kaganer from comment #8)

  1. if current page is translation, and {{#translation:}} is returned

"/code", then {{#translation:pagename}} should be return "pagename/code" (if
this page is exist) or "pagename" otherwise;

  1. if current page is _not_ a translation, and {{#translation:}} is returned

empty result, {{#translation:pagename}} should be return "pagename"

This sounds reasonable to me, and hopefully not too hard to implement (especially if reusing some Special:MyLanguage code to find the appropriate target subpage). Are you able to submit a patch (I don't think Pratik will have time during GSoC).

(In reply to Nemo from comment #10)

Are you able to submit a patch (I don't think Pratik will
have time during GSoC).

No, I do not have such skills. Let's wait for someone who can do it :(

1.24 was branched, let's have a closed bug against 1.24 for bugzilla searchers.

(In reply to Nemo from comment #10)

(In reply to Paul Kaganer from comment #8)

  1. if current page is translation, and {{#translation:}} is returned

"/code", then {{#translation:pagename}} should be return "pagename/code" (if
this page is exist) or "pagename" otherwise;

  1. if current page is _not_ a translation, and {{#translation:}} is returned

empty result, {{#translation:pagename}} should be return "pagename"

This sounds reasonable to me, and hopefully not too hard to implement
(especially if reusing some Special:MyLanguage code to find the appropriate
target subpage). Are you able to submit a patch (I don't think Pratik will
have time during GSoC).

Kaganer, can you file these as a separate bug?

Kaganer, can you file these as a separate bug?

Nemo, see bug 71114

Nemo_bis added a subscriber: Base.Jul 26 2015, 9:15 AM

Base noted that the feature had not been documented. I've corrected the manual where it said that there is no support for this feature: https://www.mediawiki.org/w/index.php?title=Help:Extension:Translate/Page_translation_administration&diff=prev&oldid=1779724