Topic on Talk:Global templates/Proposed specification

Parameters translation for wikitext templates

4
ערן (talkcontribs)

First, thank you for raising this important topic. I think having shared place for community developed modules (and gadgets) can help to small project and languages, and allow better sharing of good practices across wikis.

For Modules I understand more or less how we can have shared repo between wikis as it is written in Lua (though I wish Cscott will someday make it happen for JS too). However I'm not sure I understand how it can work for wikitext templates:

  • Labels translation - How can wikitext declare translatable label? (e.g "Birth place: {{{birthplace}}}") The page mentioned some wikis use Wikidata - but I think it does so only with Modules as we don't have #label magic word for wikibase. Another option is to use messages system which would be "{{MediaWiki:Infobox-Person-BirthPlace}}: {{{birthplace}}}" - but maybe translatewiki/MW messages aren't easily enough accessible to all editors.
  • Parameters translation - To make {{{birthplace}}} translatable to other language, so invocation would look like {{template|localname for bithplace=val}}, would require major change to parser to support for wikitext templates. For Lua modules it may require only a change in Scribuntu (so frame.args[LOCALPARAM] will be alias of frame.args[PARAM]).
Amire80 (talkcontribs)

Thank you for this relevant and constructive question.

Let's consider a simple template: a template that shows a username with links to user page, talk page, and contributions. I envision something that it will look more or less like this:

  • The template's central and English title will be: "User link".
  • The template's Hebrew title will be "קישור משתמש", and the template's French title will be "Lien utilisateur".
  • The template's own source will be:
<bdi>[[User:{{{username}}}|{{{username}}}]]</bdi> | [[User talk:{{{username}}}|{{int:User link/talk}}]] | [[Special:Contributions/{{{username}}}|{{int:User link/contributions}}]]
  • The template will have the following data file associated with it:
{
  "title": {
    "en": "User link",
    "fr": "Lien utilisateur",
    "he": "קישור משתמש"
  },
  "description": {
    "en": "This template shows a username with links to talk page and contributions.",
    "fr": "Ce modèle montre un nom d'utilisateur avec des liens vers une page de discussion et des contributions.",
    "he": "התבנית הזאת מציגה שם משתמש עם קישור לדף השיחה ולתרומות."
  },
  "params": {
    "username": {
      "description": {
        "en": "The user name.",
        "fr": "Le nom d'utilisateur.",
        "he": "שם המשתמש."
      },
      "type": "username",
      "suggested": true,
      "translations": {
        "en": "username",
        "fr": "nom d'utilisateur",
        "he": "שם משתמש"
      }
    }
  },
  "messages": {
    "talk": {
      "en": "Talk",
      "fr": "Discussion",
      "he": "שיחה"
    },
    "contributions": {
      "en": "Contributions",
      "fr": "Contributions",
      "he": "תרומות"
    }
  }
}
  • The actual transclusion in the English Wikipedia will look like this:
    • English Wikipedia, English Wikisource, etc.:
      • {{User link|username=Amire80}}
    • French Wikipedia, French Wikisource, etc.:
      • Option 1: {{Lien utilisateur|nom d'utilisateur=Amire80}}
      • Option 2: {{User link|username=Amire80}}
    • Hebrew Wikipedia, Hebrew Wikisource, etc.:
      • Option 1: {{קישור משתמש|שם משתמש=Amire80}}
      • Option 2: {{User link|username=Amire80}}

Here's the actual response to your question and heart of this long comment: In the French Wikipedia the software will be able to translate the parameter name "nom d'utilisateur" to the internal parameter name "username", and in the actual template code only the internal name is used.

Comments:

  • {{int:User link/talk}} is supposed to insert something like a translatable message. The format is just a guess. "User link/talk" is the full key: "User link" comes from the template name and "talk" is the message. It can be something different eventually.
  • The configuration JSON above is also just a guess. It can look differently. It was inspired by TemplateData and by Yurik's format at Multilingual Templates and Modules, with some simplifications. How will it actually look like eventually is up to the people who will decide about the architecture. Maybe it will be fully combined with TemplateData and maybe it will be separate. Maybe it won't be JSON at all, but some data structure in a database. In any case, most of the time it shouldn't be edited manually, but through a web-based interface for creation or localization.
  • I'd love all parameters to have full names, but I guess that for people who like editing in wiki syntax there should also be nameless, numbered parameters, so that simple templates like this one could be used as {{User link|Amire80}}. And then I guess the JSON will look like this, so that three options could be used: {{User link|Amire80}}, {{User link|1=Amire80}}, {{User link|username=Amire80}}:
{
  "params": {
    "1": {
      "description": {
        "en": "The user name.",
        "fr": "Le nom d'utilisateur.",
        "he": "שם המשתמש."
      },
      "type": "username",
      "suggested": true,
      "translations": {
        "en": "username",
        "fr": "nom d'utilisateur",
        "he": "שם משתמש"
      }
    }
  }
}

All of the above is just a comment on a talk page! I wrote it very quickly and it's possible that I made silly mistakes.

Amire80 (talkcontribs)

This is so funny and embarrassing! Apparently, TemplateData already supports translating template and parameter descriptions in raw JSON. For an example, see Template:Phabricator.

ערן (talkcontribs)

Yes, and seems like VE use this label in the Template dialog and use the user interface language.

Rethinking about "int: " - this is based on user interface, but probably the correct language is the content language. Not sure if parser have something similar for int: but for content language

Reply to "Parameters translation for wikitext templates"