Template:Multilingual link/Syntax helper

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

Template documentation


This is Syntax helper of the template {{multilingual link}}. If you know nothing about the template {{multilingual link}}, read about it firstly.

Description of the Syntax helper[edit]

The wikitext to call the template {{multilingual link}} can be long, writing such text is a tedious task. This Perl script creates such wikitext for you. For example, if you type ./syntaxhelper.perl en:Saint Petersburg State Agrarian University or ./syntaxhelper.perl Q1628690, the script returns the wikitext
{{multilingual link
|be=Санкт-Пецярбургскі дзяржаўны аграрны ўніверсітэт
|en=Saint Petersburg State Agrarian University
|eo=Sankt-Peterburga Ŝtata Agrikultura Universitato
|et=Peterburi Riiklik Agraarülikool
|fr=Université agraire d'État de Saint-Pétersbourg
|ru=Санкт-Петербургский государственный аграрный университет
}}

and you just need to copy and past that wikitext.

Code of the Syntax helper[edit]

Do not copy the code from here. Download it as described below.

Installation of the Syntax helper[edit]

System requirements[edit]

The Syntax helper script is written and successfully tested under Debian. The script is also successfully tested under CentOS, NetBSD, OpenBSD and Ubuntu. Theorethically, the script should work also under other operating systems (including non-Unix and not Unix-like), but it is not tested.

The script ultimately needs Perl and curl. (If Perl itself is inavailable for your operating system, you can install ActivePerl).

The Syntax helper is a script for a terminal (aka console). Do not try to upload the Syntax helper to a web server as a CGI script; it would not not work in such way.

Preparations[edit]

Unix and Unix-like operating systems[edit]

Perl[edit]

Type which perl and if the reply is /usr/bin/perl, go to the next section (curl).

If the reply is empty, it means that Perl is not installed. Install perl: type as root apt-get install perl, or yum install perl, or similarly, depending on your operating system (obviously, you have to know how to install software in your operating system). Type which perl.

If the reply to which perl is not empty, but not /usr/bin/perl (/usr/local/bin/perl, /usr/pkg/bin/perl or another string), type ls -l /usr/bin/perl; if the reply is not empty, it is okay. If the reply to ls -l /usr/bin/perl is empty, type as root:

  • under GNU/Linux: ln -Ts $(which perl) /usr/bin/perl
  • under *BSD: ln -s $(which perl) /usr/bin/perl

and after it the reply to ls -l /usr/bin/perl will be not empty; so, go to the next section (curl).

curl[edit]

Type which curl. If the reply is empty, install curl. If the reply is not empty, preparations are finished.

Microsoft Windows[edit]

There is no certainty that the Syntax helper will work under Microsoft Windows, but you can try.

Check if ActivePerl and curl are installed. If not, install them. Get sure that the file extension .perl is associated with ActivePerl.

Downloading the Syntax helper[edit]

Type in a terminal:
curl https://commons.wikimedia.org/w/index.php?title=Template:Multilingual_link/Syntax_helper/code\&oldid=847024748\&action=raw -m 15 -o syntaxhelper.perl && chmod +x syntaxhelper.perl
(you can highlight the above line and copy it to a terminal).

Usage[edit]

Use the Syntax helper in the terminal emulator inside graphical interface, because it permits to copy text from terminal.

Calling the Syntax helper[edit]

Type ./syntaxhelper.perl <parameter>. Instead of <parameter> use any of the options:

  • number of Wikidata item, with or without Q;
  • URL of Wikidata page;
  • URL of Wikipedia page.
  • language and name of Wikipedia article, colon separated;
  • wikilink (many variations).

The following strings have absolutely the same effect:

  • 12345
  • Q12345
  • q12345
  • https://www.wikidata.org/wiki/Q12345
  • https://www.wikidata.org/wiki/Special:EntityPage/Q12345
  • https://en.wikipedia.org/wiki/Count_von_Count
  • https://en.wikipedia.org/w/index.php?title=Count_von_Count
  • https://de.wikipedia.org/wiki/Graf_Zahl
  • https://de.wikipedia.org/w/index.php?title=Graf_Zahl
  • "{{w|Count von Count}}"
  • "{{w|1=Count von Count}}"
  • "{{en|{{w|Count von Count}}}}"
  • "{{en|1={{w|Count von Count}}}}"
  • "{{en|1={{w|1=Count von Count}}}}"
  • w:Count von Count
  • w:en:Count von Count
  • en:Count von Count
  • "[[w:Count von Count]]"
  • "[[:w:Count von Count]]"
  • "[[w:en:Count von Count]]"
  • "[[:w:en:Count von Count]]"
  • "[[en:Count von Count]]"
  • "[[:en:Count von Count]]"
  • "[[w:Count von Count|foo bar]]"
  • [[w:en:Count von Count|foo bar]]
  • "[[en:Count von Count|foo bar]]"
  • "{{en|[[w:Count von Count]]}}"
  • "{{en|[[w:en:Count von Count]]}}"
  • "{{en|[[en:Count von Count]]}}"
  • "{{en|1=[[w:Count von Count]]}}"
  • "{{en|1=[[w:en:Count von Count]]}}"
  • "{{en|1=[[en:Count von Count]]}}"
  • w:de:Graf Zahl
  • de:Graf Zahl
  • "[[w:de:Graf Zahl]]"
  • "[[de:Graf Zahl]]"
  • "{{de|[[w:de:Graf Zahl]]}}"
  • "{{de|[[de:Graf Zahl]]}}"
  • "{{de|1=[[w:de:Graf Zahl]]}}"
  • "{{de|1=[[de:Graf Zahl]]}}"

et caetera. You can use any one ot them (just one in one moment).

Note, that some Wikipedia articles have over two hundred language versions and so the output can be very long. It is better to see the output in the programme less. For example, at 25 January 2024, the article en:Earth has 299 language versions and so the output of ./syntaxhelper.perl en:Earth contains 301 lines; so, it is recommended to type not ./syntaxhelper.perl en:Earth but ./syntaxhelper.perl en:Earth | less.

Special characters in the input[edit]

Spaces are not a problem. For example, ./syntaxhelper.perl en:Carriage return works fine. Use of non-latin alphabets is not a problem, too.

If the parameter contains any of the characters: { [ ( | ' ) ] } than you need to do any of the two things:

  • prefix every such character with the \ sign,
  • or enclose the entire parameter in quotes

(NB: do just one, not both). Few examples:

  • ./syntaxhelper.perl it:Angelo d\'Arrigo or ./syntaxhelper.perl "it:Angelo d'Arrigo"
  • ./syntaxhelper.perl eo:Gantopupo \(Interreto\) | less or ./syntaxhelper.perl "eo:Gantopupo (Interreto)" | less
  • ./syntaxhelper.perl \{\{ru\|\[\[ru:Возврат каретки\|возврат каретки\]\]\}\} | less or ./syntaxhelper.perl "{{ru|[[ru:Возврат каретки|возврат каретки]]}}" | less

If inside the parameter is a quote sign ("), prefix it with \ sign (in both cases if the entire parameter is enclosed in quotes and if it is not).

Treating the output[edit]

If the entire output fits inside one screen, highlight the output, copy it ( Shift+Ctrl+C) and past it to the editing textarea (Ctrl+V). If the output is longer than one screen, than highlight, copy and past the top part of the output, scroll down at one screen, highlight, copy and past the next part, et caetera; copy and past the entire output in such a way.

See over the wikitext generated by the Syntax helper. Very probably, some language versions will be provided with titles; possibly, you will want to edit some of the titles. Especially important: when it is needed, the Syntax helper adds the parameter default but does not fill it. You have to fill that parameter with ISO code of one of the languages available in the generated wikitext. For example, if the generated wikitext is
{{multilingual link
|bg=Флатер
|de=Flattern (Luftfahrt)|title de=Flattern
|eo=Flirta oscilado (aviado)|title eo=Flirta oscilado
|fr=Flottement
|hu=Flatter (repülés)|title hu=Flatter
|ja=フラッター現象
|ru=Флаттер (авиация)|title ru=Флаттер
|uk=Флатер (авіація)|title uk=Флатер
|default=
}}

than you have to fill the parameter default with one of the eight available codes (bg, de, eo, fr, hu, ja, ru, uk) by your choice; if you will choose eo, the result will be
{{multilingual link
|bg=Флатер
|de=Flattern (Luftfahrt)|title de=Flattern
|eo=Flirta oscilado (aviado)|title eo=Flirta oscilado
|fr=Flottement
|hu=Flatter (repülés)|title hu=Flatter
|ja=フラッター現象
|ru=Флаттер (авиация)|title ru=Флаттер
|uk=Флатер (авіація)|title uk=Флатер
|default=eo
}}

When the all is done, click the button Publish changes.

Userbox[edit]

Syntax
helper
This user works with
the Syntax helper
of the template {{multilingual link}}

The Syntax helper needs your moral support. You can place this userbox on your user page with the code {{User of Syntax helper}}. This userbox on your user page is your vote for the usefulness of the Syntax helper.