Template talk:Multilingual description

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

Purpose ?[edit]

What's the purpose of this template? --Slomox (talk) 13:14, 30 April 2009 (UTC)

See meta:Meta:Language select. Multichill (talk) 13:43, 30 April 2009 (UTC)
Is it planned to create something similar on Commons? And wouldn't it be possible to implement that with the existing language templates too? --Slomox (talk) 13:51, 30 April 2009 (UTC)
I do not see the advantage over using {{en}},{{de}}, etc. Those templates set the lang property for the contained text. Language switching should then be done either by the browser, by a global java script, or a preference setting. This template clutters the description pages, makes our syntax more heterogeneous (thus confusing editors), and offers no apparent benefit. --Dschwen (talk) 14:16, 14 May 2010 (UTC)
How about trying this version MediaWiki:Multilingual_description.js over the old version MediaWiki:Common.js/LangSelect.js coming from meta almost unchanged? Esby (talk) 14:45, 14 May 2010 (UTC)
As far as I can see from reading the source, that script is designed to work with {{en}},{{de}}, etc. as well. So again, what is the added value of the mld template? --Dschwen (talk) 15:17, 14 May 2010 (UTC). P.S.: or were you proposing to deprecate mld, through the use of the new javascript? Sorry, I'm not sure I quite understood you there :-). --Dschwen (talk) 15:19, 14 May 2010 (UTC)
Basically for now, {{en}} templates will need to be put into a multilingual div for having the new version of the script working. There might also be some changes needed on some templates too, to add alternate classnames.
The initial script (that every users is using) used to not work with the {{en}} and {{fr}} templates. There were also various bugs making that we could not simply adds the mld headers to each section of a file description. The script would work on the first instance of {{en}} but would not work if another one was encountered, hence one of the reason for having an mld template. Others reasons follows:
This also allows to show all language when there is no translation available for a given field, thus not forcing the display of all other localized parts.
Imo, it's better to handle translation that should correspond to a same concept than rather using {{en}} & {{fr}} likes, it is also better than autotranslate, since it's destined to be used on any file description and as you don't have to monitor subpages for possible vandalism.
Finally, once the user just understands he can fill the description with his language code, editing it might be no problem for him. Besides, it's the basic syntax that templates use. I'd assume that coding a ajax tool to fill the language code and appropriate description would be easier to code and maintain while relying on a single mld template than with the whole list of templates like {{en}} {{fr}} {{ar}} {{az}} etc.
Esby (talk) 15:54, 14 May 2010 (UTC)
Ok, I think Iḿ starting to understand what this is about. The isolated {{en}},{{fr}} etc. templates have no explicit structure that ties all translations of the same text into one group. This is needed to figure out if a fallback is needed. MLD provides that by wrapping all translations in one big div. I think this is not a major problem. We can take a heuristic approach here: all translation strings that have the same HTML parent node can pretty safely be assumed as belonging to a group. Let me work on a new JavaScript for language selection. The current solutions are not satisfactory. The language selection UI currently sucks, and it should only appear once per page (if it should appear at all! Intelligent language detection is necessary.) --Dschwen (talk) 01:06, 17 May 2010 (UTC)
 importScript("MediaWiki:Multilingual description.js") 
in your mono/vector/*.jss ? Esby (talk) 04:28, 17 May 2010 (UTC)
(indent reset) I see one issue with the version in use: I thought that hiding the langlabel when one is set was a good idea, but this makes difficult to differenciate when no language descriptor is used. Any idea? Colorating to yellow the non localized text maybe? Esby (talk) 23:15, 24 May 2010 (UTC)


Could the buttons be translated too ? Sémhur (talk) 11:32, 17 July 2009 (UTC)

The strings are defined in MediaWiki:Common.js/LangSelect.js. But there seems to be no localisation method, so the code needs to be changed. --Slomox (talk) 12:01, 17 July 2009 (UTC)

Adding support to the Information Template...[edit]

User talk:Jean-Frédéric suggested here to modify {{Information}} to add the following 'magic code':

<div class="multilingual">

There is one issue still, linguistic code using linguistic templates like {{en}} or {{fr}} does not behave as wanted when the inline parameter is used as no language selection is performed when the inline parameter is used.
I had asked Edward Z. Yang about it (since he was the one to create the script on meta), his answer was this one, now I don't know enough jss & (dom) html to correct the javascript.
Any idea how to fix LangSelect.js to correct it?
Esby (talk) 11:47, 19 July 2009 (UTC)

Sorting order changed without consensus[edit]

In these edits the sort order was changed. The default sorting order here at Commons is by language code so I don't like this change because this sort order is not logical. Multichill (talk) 14:32, 7 October 2009 (UTC)

They are ordered for the display purpose as it is easier to read for most users (non-editors). This does not change the way the parameters are passed, and that should still be preferably sorted by code. Note that the code is not visible in the display, that uses the native language name, and so it is perfectly logical to order them by native language name, exactly as they are displayed. In addition, it makes sense to group the RTL languages together so that they align properly (the code order is really not good).
Note that the multilingual extensions are all using a native language name order on display (the code order is internal only for passing the coded parameters, to avoid duplicate entries and allowing to find them easily when editing pages, and for the interwiki links, for the same reason). Please separate the editing preferences from the page display preferences (for non-editors, considering accessibility rules as more important for them) as they are separate localization targets. verdy_p (talk) 11:11, 30 October 2009 (UTC)
Note also that I added a lot of missing languages (that were actually used in pages, but were be displayed as they should). verdy_p (talk) 11:13, 30 October 2009 (UTC)

Generating the form only once, at top of page[edit]

Currently, the javascript generates the language selection form multiple times, for each multilingual division. In addition, it attempts to place the form anywhere ni the page, even if this is not the best place for it.

Could I ask that the javascript generates the same (and functionally strictly equivalent) language selection form only once within the page:

  • preferably at top of page (or near the page title, if it can also be localized).
  • but it could also be at the first occurence of the multilingual division ?

It would allow placing mutilingual divisions within the description of each image in a <gallery> (currently this form displays correctly there, but this is really bad design to have this form under ALL images of the gallery).

See for example the galleries in United Kingdom.

It should also be possible to translate the page sections without having to annotate their title (because adding translations to them just breaks the page anchors in the MediaWiki Summary). The Mld template would then be used first under each section.

Another solution should be developed to generate multilingual summaries, and still have editable sections). verdy_p (talk) 11:22, 30 October 2009 (UTC)

I managed to get the will back to hack my test javascript. Now It loads the language selector above content, but below image on file description pages.
If some people want to test it: just add
to your monobook.js
Esby (talk) 00:00, 10 February 2010 (UTC)
Quickly tested it : it is very nice, seems to work.
However, it does not work with Image Annotations, such as in File:Berliner kongress.jpg (though I kind of expected that).
Jean-Fred (talk) 00:20, 12 February 2010 (UTC)
Images annotations seem bugged. I don't know the cause for now. Sometimes it works, sometimes it does not, it seems linked with refreshing the page.
You can also see that the german note in the description is not hidden, this is for two reasons:
  • there is no {{mld/start}} nor {{mld/end}} block to tell the plugin to do its job.
  • there needs to be at least one section with your language for the hiding to work. this is the cases for the mld note that only contains french.
Esby (talk) 09:15, 12 February 2010 (UTC)

I found the cause of the bug, but I can't fix it for now. I just have no idea on how to fix it. MediaWiki_talk:Gadget-ImageAnnotator.js#image_annotation_related_issue Esby (talk) 23:27, 12 February 2010 (UTC)

I did some coding: The new version of the script will disable itself on image annotation. The language label (english:..., french:...) will hide themselves when you are displaying only one language. Maybe I could add some background color to show when the languages are localized or not. I'll update MediaWiki:Multilingual description.js once the new version of the script has been tested on several browser. Esby (talk) 13:24, 23 April 2010 (UTC)
tests performed with user:esby/testls2.js on User:Esby/test:
  • Ubuntu 9.10 - 64 bits
    • Firefox 3.5.9. ✓ OK Esby (talk) 13:24, 23 April 2010 (UTC)
    • Chromium 5.0.382.0 (44898). ✓ OK Esby (talk) 13:24, 23 April 2010 (UTC)
    • Midori 0.1.9 ✓ OK Esby (talk) 13:24, 23 April 2010 (UTC)
  • Windows XP
    • Internet Explorer 8.0.6001.18702 ✓ OK Esby (talk) 12:45, 12 May 2010 (UTC)

I've put the new version here, feel free to report any issue related to it. Esby (talk) 14:47, 14 May 2010 (UTC)


How to move the template and related to another project? In particular, where to get the js it is associated?

For the javascript part, you can copy MediaWiki:Multilingual_description.js to your wiki and load it via your monobook/vector.js. Depending the usage (wiki using commons as a media base or not) there might be a few issues with the description coming from commons. Esby (talk) 08:17, 2 June 2010 (UTC)

Merge/move the javascript back in one place[edit]

Currently for everybody the old version of the javascript is loaded in the central MediaWiki:Common.js, importing ('MediaWiki:Common.js/LangSelect.js'). Since a while now the new javascript is developed at MediaWiki:Multilingual_description.js.

We could update the old one with the new code, but then everbody who had importScript() the new one will have it double. So, in order to prevent any unnneeded loading, I propose to move MediaWiki:Multilingual_description.js to MediaWiki:Common.js/LangSelect.js (deleting the latter first in order to be able to do the rename), and then blanking the redirect at MediaWiki:Multilingual_description.js with /* Emptyness */. This way everybody (both users without the manual importScript, who currently get the old version. And those who manually imported the new version, who currently get both (since the old one in Common.js applies to them also). will from now on only load the new one. Those who still have the new one manually imported in their vector.js or monobook.js will simply load an empty file addionally (still better then loading two entire files).

This'll update everybody and speed up by not double loading. If I missed anything in the above that could cause a problem (I think not), please let know so down below. If nothing heard, I'll execute the move Monday. –Krinkletalk 14:10, 26 June 2010 (UTC)

Well, technically, I'd rather keep the two versions, while updating the old one. Speed wise, it is not an issue. I havn't seen any issue related to it. That would allow to work and debug the script while not affecting all users. You could see the script everyone uses as the stable version while the one manually loaded as the unstable one. Esby (talk) 16:20, 26 June 2010 (UTC)
Alrighty, a seperate debug/development versions sounds good. –Krinkletalk 12:32, 12 August 2010 (UTC)
✓  Done - the public script is stored at MediaWiki:Multilingual description.js/public. The one the beta-testers and script writers can include is MediaWiki:Multilingual description.js. An example to override it in the custom user script:
ls_enable=false; // blocks the one in Common.js from loading
addOnloadHook(function(){ ls_enable=true; importScript('MediaWiki:Multilingual description.js); });
Krinkletalk 10:21, 15 August 2010 (UTC)


When we select a language, all the texts in the page using the template are translated but templates stay in the original language. That doesn't seem very logical. Can I add something like ?uselang=selected language so that the templates are translated in the same time ?--Zolo (talk) 12:34, 14 August 2010 (UTC)

Got no opinion on the subject. If you feel it might improves the situation feel free to try on a test script. Esby (talk) 20:05, 22 August 2010 (UTC)
I hadn't realised that I don't know how to do it. I've tried but didn't manage. I'm convinced that something like a merger between {{langSwitch}}, {{autotranslate}} and {{mld}} would make many things simpler.--Zolo (talk) 10:15, 2 September 2010 (UTC)
The templates that use {{Autotranslate}} are not dynamic. They are based on the {{LangSwitch}} principle, in that they only show 1 language on the output page (the one that matches the users preference and/or &uselang=-parameter). Then a script shows language-links along the bottom of the template and when clicked upon it replaces the template with a translation.
{{mld}} on the contrary shows all languages on the page, and then the script checks the current uselang and hides the others when possible. So they dont have to be merged, they both work at the same time. The central thing here is the uselang (wether it being the url-parameter or the usersetting). So if you set your language to uk-Ukrainian in Special:Preferences then you see the Ukrainian descriptions and the Ukrainian templates. –Krinkletalk 07:52, 26 September 2010 (UTC)
Yes I see. Maybe a full merger would not be a good idea, but it would be nice if it was made easier to choose another language, especially for non logged-in users that get English by default.
There are many templates related to artworks that use langSwitch without any mld. For instance "oil on canvas" will display in the user's default language. In this kind of cases, users without an account don't have any language choice (maybe in some cases langSwitch should just be replaced by mld)--Zolo (talk) 09:33, 26 September 2010 (UTC)

Further development[edit]

I am going to work on a derivated version of the current script, to solve or enhance the following point:

  • allow to detect a classname to always shows some associated captions, what ever are the settings. This would allow to load the script on the wikipedias, in order to hide the unwanted localized content of commons while showing the possibly localized content of the wikis.
  • allow to suggest the user to enter a translation when none exists in his/her default language.
  • allow to suggest the user to enter a translation when none exists in a list of given language code he/she previously set in his/her (mono/vector)*.js

The 'enter a translation feature' would mean to provide a link to edit the corresponding page / section. Esby (talk) 20:12, 22 August 2010 (UTC)

See Category_talk:Plaques#Multilingual_category_description and {{Mldcat}} for further suggestions. --Foroa (talk) 09:03, 26 September 2010 (UTC)

AnonymousI18n, fallback, user preferences[edit]

Hi all, I'll get right into it: I propose to slowly replace this template with {{LangSwitch}}. Not redirecting, since there are valid cases in which {{mld}} is still wanted.

"(..) still wanted. ?", you ask ? What changed ?

Well, there's a few points in no particular order:

  • {{mld}} outputs all languages to the browser. More load, and in most cases, unneeded translations. And in case of javascript failure the list can be quite consuming and overwhelming on the better translated pages.
  • {{LangSwitch}} only returns the wanted language. No more, no less, no "flash of unprocessed mld-lists" before the javascript for it is done processing the user's cookie and hiding the other languages.
  • The MLD-javascript is not capable of fallbacks. Which means that the user will see English unless there is a translation into their exact language (or it will show all translations)

Since a few weeks MediaWiki:AnonymousI18N.js has been developed which is an attempt to centralize language settings for anonymous users by using cookies and ?useleang. This means that anonymous users can get translated content from

.. which they currently either can't get into their own language or it requires extra steps which they probably won't and shouldn't have to take.

For that reason I think it's a good step to only use {{mld}} where the intend is to "show all languages" and not where the intend is to "manage translations and display the one langauge the user wants" (which is essentially a description of {{LangSwitch}}). Especially now that LangSwitch no longer is just for logged-in users.

When people agree we shouldn't forget to unload MediaWiki:Multilingual description.js from the global site script in MediaWiki:Common.js. –Krinkletalk 13:56, 4 January 2011 (UTC)

I honestly don't like langswitch as you are forced to look on the code to check for vandalisms in other language than you are currently browsing. Esby (talk) 14:28, 4 January 2011 (UTC)
I would clearly support harmonization of language templates.
LangSwitch is simpler and visually more pleasing that mld (no flash, no bold language names). Beside necessary linebreak between language in mld make it virtually impossible to use in some templates. If the MediaWiki:AnonymousI18N.js allows anonymous users to easily and intuitively choose the language they want to display, I think it would be much better.
I guess that with the new i18N script, the only advantage of mld will be the "all languages" option. To me this option is useful because:
  • as mentioned by Esby, it makes it simpler to check for single language vandalism (is it that common ?)
  • sometimes, users provide a rather detailed description in their own language plus a shorter description in other languages they do not master that well. In this case, it may be interesting to have all languages displayed.
I still think that the proposed solution's benefits would outweigh these downsides. Maybe we could add an "all languages" button for {{langSwitch}} ? but it may get us back to the same javascript problems. --Zolo (talk) 22:46, 4 January 2011 (UTC)
I'd like to comment back on the argument that were exposed:
  • The problem about 'cookie processing', an anonymous version could be set to use directly either the navigator preferred language, either the useLang parameter. This would not stop the flash effect, but I don't believe it is really problematic.
  • The lack of 'fallback', the more I think about it, the more I feel this is a non argument. Langswitch is supposed to be better because it has a fallback parameter? What is the point exactly of fallbacking to chinese, when you have only russian, japanese and chinese versions present and you can't read any of those? The fallback setting should be a user setting / preference and definitely not a template parameter. Now if we decide that we must have all translation available in english, then we can allow ourselves to fallback to it. Also, the script behind {{tl[mld}} has a fallback code that displays all the available language, if the matched one is not found. The only problem I see is when you need to indicate on which language source something was translated.
Esby (talk) 10:28, 13 January 2011 (UTC)
The very next version of AnonymousI18N will have an option to show all languages. This is not a bug or an inability, simply something I forgot to implement when writing it. You can either show all languages once or keep it as your setting instead of one particular language
@Esby: I wasn't referring to that kind of fallback. I was referring to {{LangSwitch}}'s fallback mechanism. If you look at it's code you see that it uses several layers of fallback languages. For example if someone has the "Informal dutch" (nl-informal) preference they will see "Dutch" if nl-informal is not provided. Or if a Dutch Low Saxon speaker is browsing a page with only English and Low Saxon, the absence of Dutch Low Saxon will cause the second fallback layer to serve "Low Saxon". Which is still better than "English". Likewise if someone has their langauge setting to a particilar variant of Chinese (zh) but none are available it will server standard Chinese as fallback. Check the template code for more examples like these.
So, if I understand correctly from the discussion so far all that is left is the implemtation of the 'all language' option, and we're ready ? –Krinkletalk 14:10, 13 January 2011 (UTC)
Well, on this subject, are there licence like template that uses lang-select based template, imo, if such option of showing those languages were to be implemented, it should not affect the highly used templates. (meaning, there could be a check for displaying all language based on the namespace the template being called.)
On another subject, the script behind mld now triggers even on {{en}} (supposed there are more than 5 languages in a page which means files descriptions don't have to be edited to reduce the tower of Babel effect.
Esby (talk) 12:21, 14 January 2011 (UTC)

Some corrections and changes[edit]

{{editprotected}} Kurdish (ku) is written with Latin script, Sorani dialect (ckb) uses Arabic script though. Please also add arz, glk, ps and ug to "(RTL) Arabic", and ba and ky to "Cyrillic" section, and move war from "Indic" to "Latin" and ks from "Indic" to "(RTL) Arabic". --Z 12:39, 28 April 2012 (UTC)

✓  Done all except I've left ku under Arabic, because ku-latn is listed under Latin. Rd232 (talk) 15:26, 24 June 2012 (UTC)

Missing language code[edit]

Latvian (lv) is missing from here. I don't know if any other too. 12:46, 15 November 2013 (UTC)

language added. Esby (talk) 15:53, 15 November 2013 (UTC)
It hasn't been added correctly. See, for example, Baseball. Instead of showing Latviešu (Latvian, lv), followed by Lietuvių (Lithuanian, lt), it shows the Lithuanian twice — both the word "Lietuvių" and the translation "Beisbolas". I'd fix it, but all the relevant templates are frozen or protected. — Quicksilver@ 05:19, 25 April 2014 (UTC)
Hey Quicksilver, please {{edit request}} edits to protected templates. Thanks in advance and thanks for making us aware of the mistake. -- Rillke(q?) 07:25, 26 April 2014 (UTC)
Pictogram voting keep.svg Fixed: Special:Diff/122296519. That was a trivial fix to Module:Multilingual description/sort. -- Rillke(q?) 07:25, 26 April 2014 (UTC)

Machine-readable standard markup for i18n templates[edit]

I started a discussion about standardizing the markup generated by i18n templates so that it can be made machine-readable: Commons talk:Machine-readable data#Machine-readable markup for languages/language names; please share your opinion! --Tgr (WMF) (talk) 11:16, 11 November 2014 (UTC)


I have some issues with this template at File:Ansamblul „Cetate” -vedere aeriana.JPG. I can't see anything in the description, even the {{Monument istoric}} which is outside the template. Going back to {{ro}} etc. Makes the description visible. My preferences are set to Romanian language.--Strainu (talk) 12:08, 26 September 2016 (UTC)

Please state:
  • the nagivator you used,
  • the os you are using.
  • how to reproduce it. (because I don't see anything abnormal in the corresponding files).
Esby (talk) 07:35, 29 September 2016 (UTC)
Any OS, any navigator, but I think it's related to one of my gadgets (probably User:MarkTraceur/editDescriptions.js), since on another account it does not reproduce. I'll investigate further and report the bug at the respective script's talk page. Thanks.--Strainu (talk) 15:27, 30 September 2016 (UTC)
I can reproduce it. I get following errors (on Ubuntu):
on Chrome[ium] (53): HierarchyRequestError: Failed to execute 'appendChild' on 'Node': The new child element contains the parent.
on Firefox (49): HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy
On load it can be shown all languages are visible which than disappear. Lang select is also not visible.
User: Perhelion 21:37, 6 November 2016 (UTC)
Incompatibility with User:MarkTraceurs/editDescriptions.js, which is anyway beta only (and he has declared to have no time to further develop). User: Perhelion 21:53, 6 November 2016 (UTC)