Template talk:LangSwitch

From Wikimedia Commons, the free media repository
Jump to: navigation, search
Info non-talk.svg Template:LangSwitch has been protected indefinitely because it is a highly-used or visible template. Use {{Edit request}} on this page to request an edit.
Please test any changes in the template's /sandbox or /testcases subpages, or in a user subpage, and consider discussing changes at the talk page before implementing them.

feature request[edit]

I would like to add Category:Internationalization templates using LangSwitch to this template to make it easier to locate templates using it that might need translations.

<includeonly>{{ #ifeq:{{NAMESPACE}}|Template|[[Category:Internationalization templates using LangSwitch|{{PAGENAME}}]] }}</includeonly>

--Jarekt (talk) 14:15, 21 August 2009 (UTC)

 Not done, as much as I like this idea, this won't work, as some templates are transcluded on template pages ({{In category}} for example) and this would add all transclusions of {{In category}} to the cat as well. --The Evil IP address (talk) 16:18, 21 August 2009 (UTC)
you are right. Is there any way to just get the first transclusions? --Jarekt (talk) 18:54, 21 August 2009 (UTC)

Flag-like symbols[edit]

The template seems to introduce flag-like symbols to designate languages. It is a prettification, but it does not really help users; languages are not directly related to state borders. Better to remove. /Pieter Kuiper (talk) 09:48, 7 January 2010 (UTC)

I do not believe this template adds any symbols or text - it is just specialized switch statement. However other templates using this one might be doing it. Could you give some examples? --Jarekt (talk) 16:54, 7 January 2010 (UTC)
I created LangSwitch and I invested hundreds of edits in removing flags as language indicators from Commons galleries too. I certainly wouldn't use flags to indicate languages anywhere ;-) Whenever you see flags used this way, please remove them. --Slomox (talk) 17:24, 7 January 2010 (UTC)
Sorry, I was wrong. I had seen them in File:West Bank Barrier cartoon by Latuff.png, but on closer reading, the flags are added by {{LanguageSelector}}, and they can be switched off. I will take the issue there. /Pieter Kuiper (talk) 17:32, 7 January 2010 (UTC)

default parameter[edit]

I would like to add an optional "default" parameter in case default is not English. I was thinking about changing last 2 lines to:


Does anybody see any problems with that solution? --Jarekt (talk) 18:54, 3 June 2010 (UTC)

The solution is fine, but at the moment I don't see for what purpose we would need a default. Could you give some examples where this is needed? --Slomox (talk) 19:01, 3 June 2010 (UTC)
I run into this problem few times before, but at the moment I was thinking about creating {{dash}}, to comply with request at Template talk:Creator/layout to fix up the "dash". The template would produce long dash for English and short dash for everybody else. I could write it using {{#switch ...}}, but {{LangSwitch}} seemed like a better option. --Jarekt (talk) 19:07, 3 June 2010 (UTC)
But if anything else around the dash defaults to English, the dash should also default to English. If {{Creator}} is completely unlocalized for e.g. Kapampangan, everything will appear in English. Except for the dash. That would be a bit inconsistent. --Slomox (talk) 19:43, 3 June 2010 (UTC)
May be a cleaner option would be to modify all Template:Creator/lang templates to add a dash parameter to be passed to the Template:Creator/layout. --Jarekt (talk) 19:53, 3 June 2010 (UTC)
Just, if an example can be useful : here we get "commissioned by John, duke of Burgundy, with John duke of Burgundy in any language that has not been langswitched. But John wasn't English, a French or Dutch title would seems more logical for a Spanish user.--Zolo (talk) 22:02, 11 July 2010 (UTC)

If it is not too complex to implement, I think it could be convenient to be able to choose a default language different from English. For example, if you use Catalan in File:Brooklyn_Museum_-_"Pauvre_Giulay...."_-_Honoré_Daumier.jpg, you will get: depicted person (well "Persones retratades") Franz Joseph I of Austria. It looks a bit silly to have an English name for an Austrian Emperor, so it would be nice to have something like Franz Joseph I by default. Granted these are rather trifling things and it could be fixed by, say, a "Franz Joseph I" multilingual template. But since this kind of cases occur quite often, it could be nice to have a choice for the default language.--Zolo (talk) 10:14, 5 October 2010 (UTC)

I think replacing the "en" at the beginning (the last thing in the series of #if:s) with {{{default|en}}} or, as Slomox likes to do, {{#if:{{{default|}}}|{{{default}}}|en}} would be the best way (so empty == undefined). Rocket000 (talk) 18:20, 5 October 2010 (UTC)

I saw that a default parameter has been created. Is it intenetional that English takes precedence over it ? I mean: when my preferences are set to French and I write {{langSwitch|en=english|default=default}} I get "english".--Zolo (talk) 08:14, 20 October 2010 (UTC)
That is some strange behavior of {{GetFallback}} / {{GetFallback2}}. I will look into it. --Jarekt (talk) 15:32, 20 October 2010 (UTC)

Multiple languages[edit]

Sometimes, the object on the image has a title/name in one language, it would seem good to have both the original language and the user's language. For example, it seems simpler to state that we want French on the first line rather than adding French for each language in :
{{LangSwitch |de='''''La Liberté guidant le peuple'''''</br>''Die Freiheit führt das Volk''.
|en='''''La Liberté guidant le peuple'''''</br>''Liberty Leading the People''.
|es='''''La Liberté guidant le peuple'''''</br>''La libertad guiando al pueblo''.
|fr='''''La Liberté guidant le peuple'''''.
|ru='''''La Liberté guidant le peuple'''''</br>''Свобода, ведущая народ''.
|vi='''''La Liberté guidant le peuple'''''</br>''[[:vi:Nữ thần Tự do dẫn dắt nhân dân|Nữ thần Tự do dẫn dắt nhân dân]]'' }} ([1])

As I understand it, it can't be done with the current template, is there a way to do that ?--Zolo (talk) 08:18, 11 July 2010 (UTC)

You can try using {{mld}} for that kind of purpose. Esby (talk) 12:12, 11 July 2010 (UTC)
Actually I don't want a box like in mld, I just want the same thing as what is on File:Eugène_Delacroix_-_La_liberté_guidant_le_peuple-2.jpg, but I just wish it required a bit less of text
What's wrong with writing it outside the template?:
La Liberté guidant le peuple
Liberty Leading the People.
--Slomox (talk) 21:25, 11 July 2010 (UTC)
That means we should put fr=(blank or spaces) but when we do that, it acts as if there was nothing in French, so, when the default language is French, we get the only title below, and that looks a bit strange. Not a very serious problem, admittedly, but if we can fix that, that would probably be better.--Zolo (talk) 21:54, 11 July 2010 (UTC)
How do you want it to behave? --Slomox (talk) 22:11, 11 July 2010 (UTC)
I'd like not to have the title in English when I use commons in French.--Zolo (talk) 08:03, 12 July 2010 (UTC)
User:Esby/test5 ? Esby (talk) 09:36, 12 July 2010 (UTC)
That seems good, thanks, I'll put it without the , I think that it looks a bit better and that it is the way it's usually done by museums.--Zolo (talk) 10:52, 12 July 2010 (UTC)
The fr tag is here for accessibility, it purpose is here to indicate how the automatic reader should pronounce the word, depending the language... Esby (talk) 10:59, 12 July 2010 (UTC)
Okay. Since it is meant for non-French speaker, is there a way we can indicate French in English, französisch in German and so on rather than "français"?
Ah maybe I can put something like ({{language|fr}})--Zolo (talk) 11:17, 12 July 2010 (UTC)
I guess the best solution would be : User:Zolo/test, but it requires quite a lot of writing. If it's not too long to create a template that can do this thing, I think it would be the best solution, but I don't know how to do it.--Zolo (talk) 11:42, 12 July 2010 (UTC)

By the way, I really don't think this template should be used for substantial text describing the content of an individual image, since it makes it very difficult to scan down and check that translations are correct, etc. Why not just plain {{fr|1=''La Liberté guidant le peuple''}} {{de|1=''Die Freiheit führt das Volk''.}} {{en|1=''Liberty Leading the People''}} etc. etc.? All the other solutions go to a lot of work to produce results that some people will find annoying... AnonMoos (talk) 07:57, 6 April 2011 (UTC)

For a substantial text, maybe not but a title is not very long. For Liberty leading the people, we could have 25 languages just by using interwikis, if you add a test in 10 languages in the description parameter, and all languages are displayed this will look quite ugly. Sometimes a javascript displays only the user's language but this hides the original language which is precisely what I wanted to avoid here. I have created a {{title}}, it is easier to use than multiple langSwitch, so maybe it can help in such cases.--Zolo (talk) 10:08, 6 April 2011 (UTC)

I usually do this with the title-template.
{{title|1=La Liberté guidant le peuple|lang=fr|de=Die Freiheit führt das Volk|en=Liberty Leading the People}}
will give:
French: La Liberté guidant le peuple
Liberty Leading the People
It shows the original language and the users selected language. No others though. DutchHoratius (talk) 10:08, 1 June 2012 (UTC)

Category:LangSwitch template without English version[edit]

I added a maintenance category Category:LangSwitch template without English version, to catch one form of misuse of this template. Seems like innocent edits like: this break perfectly fine templates. --Jarekt (talk) 18:03, 5 October 2010 (UTC)

Good idea. I recently noticed that too and was thinking of creating a new specialized langSwitch, but didn't want to create yet another autotrans thing. Rocket000 (talk) 18:15, 5 October 2010 (UTC)
What exactly is wrong with such use of the template? I've been using it on category pages, where a category is mentioned by its English name, to provide translations in other languages to be displayed in case uselang is equal to that language. Why did it stop working with {{See also}}? --AVRS (talk) 19:39, 8 October 2010 (UTC)
When a user views a template that lacks a translation in the language of their interface (and in the possible fallback languages), it falls back to English. If there is no English translation, it doesn't display anything even if many other translations exist. What's wrong with {{see also}}? That doesn't use this template, btw. Rocket000 (talk) 07:56, 9 October 2010 (UTC)
I mean use like this:
{{See also|Category:Water|:Category:Water {{LangSwitch|eo=(Akvo)}}}}, which gives:
--AVRS (talk) 15:44, 9 October 2010 (UTC)
Ah, I see what you're doing. Since there's no en version, this template is now inserting a category inside the link you are trying to make. It looks like this:
[[:Category:Water|Category:Water [[Category:LangSwitch template without English version]]]]
Which breaks the link. To solve this we can add a way of suppressing the category completely such as adding a {{{category}}} or {{{nocat}}} parameter. Rocket000 (talk) 03:37, 10 October 2010 (UTC)
Actually, I suggest removing it. It breaks a lot of stuff. Rocket000 (talk) 03:42, 10 October 2010 (UTC)
Well it has some usefulness, now it should probably be rewritten. Esby (talk) 06:11, 10 October 2010 (UTC)
Ok, and I forgot Jarekt's edit summary saying this is to be a permanent category. I guess we have to go the category parameter way. Which method would you prefer? I personally like the simple override {{{category|...}}} so all you do is |category= but setting empty values isn't the clearest way. Maybe {{#if:{{{nocat|}}}||...}}? Rocket000 (talk) 10:15, 10 October 2010 (UTC)
I intended it as a permanent category but if it breaks things than we can disable it and try again latter. I still think we should add #default option which could be other than {{{eng}}} and may be allow wider range of defaults if English is not provided. What I do not like about present version is no text in any language if English is not present. Also at the moment I excluded files, too phase it in more gradually but they should be included as well. --Jarekt (talk) 18:03, 10 October 2010 (UTC)

Any reason to use both




? If I understood correctly, if the "en" is present, it will be used in the first case, and never in the #default case.

Proposed new version of the template[edit]

Current version of the template does not use "default" option in a correct way, see Template_talk:LangSwitch#default_parameter, and there do not seem to be any easy fixes to this issue other than modifying {{GetFallback}} / {{GetFallback2}}. As a result I rewrote the template without use of {{GetFallback}} templates, making it in the process much shorter and (hopefully) easier to read and maintain. The new version can be found at {{LangSwitch/test}}. I also wrote for testing purposes User:Jarekt/e which tests various options of old and new versions. --Jarekt (talk) 15:46, 22 October 2010 (UTC)

{{LangSwitch|en=fail|default=yep}}: fail (except your interface is set to English).
Did my edits work? Looks good. Have to check other languages. --Slomox (talk) 21:57, 22 October 2010 (UTC)
Works. --Slomox (talk) 21:59, 22 October 2010 (UTC)


Was just re-thinking this template: Is the code at User:Slomox/test18 a brilliant simplification of the template or a moronic brain-wreck?

{{User:Slomox/test18|default=default}}: User:Slomox/test18
{{User:Slomox/test18|en=en}}: User:Slomox/test18
{{User:Slomox/test18|de=de}}: User:Slomox/test18
{{User:Slomox/test18|es=es}}: User:Slomox/test18
{{User:Slomox/test18|en=en|default=default}}: User:Slomox/test18
{{User:Slomox/test18|de=de|en=en|default=default}}: User:Slomox/test18
{{User:Slomox/test18|blp=blp|lang=blp}}: User:Slomox/test18
{{LangSwitch|blp=blp|lang=blp}}: LangSwitch Error: no default --Slomox (talk) 22:09, 22 October 2010 (UTC)
I like this one - it is so much more compact. I added it to [[User:Jarekt/e]] test set and it seems to work exactly as current {{LangSwitch}}. The only difference with what I was trying to do in {{LangSwitch/test}} is the treatment of empty fields like "fr=" in {{LangSwitch/test|en=English|fr=|lang=fr}} gives "Template:LangSwitch/test" instead of "English". --Jarekt (talk) 03:04, 23 October 2010 (UTC)
Also is there any reason for not replacing each one of 6 "{{#if: {{{lang|}}} |{{{lang}}}|{{int:Lang}}}}" with "{{{lang|{{int:Lang}}}}}". It is shorter and more clear. --Jarekt (talk) 03:07, 23 October 2010 (UTC)
The two constructions work differently in the case that the parameter "lang" is set, but set to the empty string. If I call "{{LangSwitch|lang=}}" then "{{#if: {{{lang|}}} |{{{lang}}}|{{int:Lang}}}}" will return the value of int:Lang, while "{{{lang|{{int:Lang}}}}}" will return the empty string "". --Slomox (talk) 10:43, 23 October 2010 (UTC)
And the reason why returning the empty string is a bad thing™ is that you may want to use something like "{{LangSwitch|lang={{{lang|}}}}}". If {{{lang|}}} is empty that will lead to "{{LangSwitch|lang=}}" and int:Lang is never called. --Slomox (talk) 11:16, 23 October 2010 (UTC)
The code looks good - but I am not extremely competent to decide. Also, it is probably good that the language list is automatically upadted through getfallback. But I like {{LangSwitch/test|en=English|fr=|lang=fr}} --Zolo (talk) 06:48, 23 October 2010 (UTC)
{{LangSwitch/test|en=English|fr=|lang=fr}} returns nothing because of the issue discussed above. It's a very problematic thing. If you want to have the template return nothing you should use {{LangSwitch|en=English|fr=<nowiki/>|lang=fr}}. That works and is much less problamtic than the empty string. --Slomox (talk) 11:16, 23 October 2010 (UTC)
My intention was for {{LangSwitch/test|en=English|fr=|lang=fr}} and {{LangSwitch/test|en=English|lang=fr}} to have different behavior. The first one where you explicitly say to return nothing for french language and second one where I would expect to see default/en. The {{LangSwitch|en=English|fr=<nowiki/>|lang=fr}} syntax might be to esoteric for most users. Also it seems unfair that you can ask for no english as in {{LangSwitch|en=|fr=French}} but you can not ask for no French. --Jarekt (talk) 16:43, 23 October 2010 (UTC)

Change language through mld[edit]

Just wondering: it is somewhat frustrating that when we choose another language with {{mld}}, langSwitch texts do not change language. I guess that for non-registered users - who have English by default - it is barely understandable. Would it be possible to make the langSwitch text change when another language is selected through mld ?--Zolo (talk) 06:48, 23 October 2010 (UTC)

Would it be possible to make the langSwitch text change when another language is selected through mld ? Yes. By replacing LangSwitch with MLD.
LangSwitch and MLD have two different approaches. LangSwitch selects the right language server-side and delivers only this language to the client, while MLD delivers all languages to the client and the right language is selected client-side. These two approaches are mutually exclusive. You cannot integrate LangSwitch with MLD without rendering LangSwitch obsolete.
From a strictly rational point of view we should decide for one of the two solutions and completely disable the other. It's a bit like Blu-ray vs. HD DVD. They both do their job, but there's still no point in supporting both. From the point of view of the end-user it only has disadvantages to have two incompatible formats. But they were both developed and compete(d) against each other. --Slomox (talk) 11:01, 23 October 2010 (UTC)
There was a curious case with File:Freedom of Panorama in Europe NC.svg, which used LangSwitch inside mld — I had it removed, because of the discussion here. This is relevant, because the trouble with LangSwitch is that it's impossible to switch languages with it, and the issue with mld is that unless it only contains text, it requires more code, especially with longer image descriptions. The ideal would be this:
|en=Text in English
|it=Text in Italian}}
|en=OK, including works of art
|it=OK, incluse opere d'arte}}
— In which the default language could be English (if it's not provided, then a fallback language) or a user's default language when logged in, or based on geography; and if I change the language, text both under mld and LangSwitch would change to the desired language.
-Mardus (talk) 06:39, 11 April 2012 (UTC)

Please understand that {{LangSwitch}} is a server-side implementation and does not require JavaScript while {{Mld}} depends on MediaWiki:Multilingual description.js. You can't load other languages of LangSwitch, except using an XHR or CSS (to hide them by default). -- RE rillke questions? 17:41, 11 April 2012 (UTC)

Proposed new version of the template (part 2)[edit]

I rewrote proposed new version of {{LangSwitch}} again and new version can be found at {{LangSwitch/test}}. I started with User:Slomox/test18 which has identical output while being much smaller and simpler than the current version of {{LangSwitch}}, and did following changes:

  • Reformatted for easier reading
  • Use special character "~" to indicate desire for some languages not to be displayed, so {{LangSwitch|en=English|fr=~|lang=fr}} will return "Template:LangSwitch/test". Current version of the template does not allow empty returns if English or default are provided.

Much more testing of the current and new template can be found at User:Jarekt/e. Please add to it if other examples are needed. --Jarekt (talk) 19:29, 29 October 2010 (UTC)

Looks fine to me, thanks.--Zolo (talk) 20:21, 29 October 2010 (UTC)
Currently in both versions of the template, "lang" overrides both "default" and the user's locale. Isn't it supposed to just set "default" to the value specified for the language specified with "lang"? --AVRS (talk) 14:33, 30 October 2010 (UTC)
Default language is always English. Parameter "default" is for the default message which could be more language neutral. One use would be for templates which add links to wikipedia articles in different languages, where default can be commons gallery page. --Jarekt (talk) 03:23, 31 October 2010 (UTC)
And what is the parameter "lang" for? --AVRS (talk) 15:57, 31 October 2010 (UTC)
I hoped to use "lang" to make {{User Firefox}} use translations even for users who have specified a language for the template when it was not autotranslated. That way, it would be possible to make such info default to the owner's language instead of English. --AVRS (talk) 16:18, 31 October 2010 (UTC)

✓ Done I uploaded the new version. --Jarekt (talk) 01:01, 2 November 2010 (UTC)

bugs ?[edit]

Isn't {{langSwitch|en=english|ca|es=catalan or spanish|lang=ca}} supposed to give "catalan or spanish" both because of the |ca|es and the fallback ?--Zolo (talk) 20:10, 20 January 2011 (UTC)

{{LangSwitch}} is has similar syntax to {{#switch: }} but not the same, since one is a template and the other one a ParserFunction. This is one of the differences. In above case "ca" is interpreted in the template as {{{2}}}=ca not as {{{ca}}}. Other difference is "default" vs. "#default". --Jarekt (talk) 21:47, 20 January 2011 (UTC)
Oh yes sorry. It would be convenient if we were able to have |ca|es (for example in {{size/test2}}, but I suppose there is no way to do that.--Zolo (talk) 08:03, 21 January 2011 (UTC)

langSwitch vithout English[edit]

Should the template categorize in langSwitch without English even when there is a "default". Cases like {{conj}} with {{langSwitch|zh=|default=&#32}} certainly cram the category but it may be better to write out "en" in any case.--Zolo (talk) 08:13, 8 March 2011 (UTC)

I changed the template so langSwitch with default but without "en" will not be categorized. I also added "nocat" parameter. Set it to "1" and category should disappear. --Jarekt (talk) 02:18, 9 March 2011 (UTC)


Hi, why this template don't care about {{SUBPAGENAME}}? in this cases there is an alternative for it? my ideaebraminiotalk 19:09, 9 March 2011 (UTC)

Can you provide examples of the situations where use of {{SUBPAGENAME}} would be useful? --Jarekt (talk) 20:34, 9 March 2011 (UTC)
Template:PD-USGov-USDA-ARS/fa -> Template:In category.−ebraminiotalk 01:44, 10 March 2011 (UTC)
I am still confused about how you would like to use it, but maybe {{LangSwitch|lang={{SUBPAGENAME}}|en=......|fa=....}} would work. --Jarekt (talk) 13:02, 6 April 2011 (UTC)
Oh, I just wanted "This template will categorize into..." message, be on Persian on this page. May I thinking wrong... −ebraminiotalk 17:28, 26 July 2011 (UTC)
If your language is set to fa than you should see {{In category}} in Persian. If you want to see it in Persian even if your language is set to other language than use {{In category|........|lang=fa}}. However you should not have additional documentation (like calls to {{In category}}) in language subpages like {{PD-USGov-USDA-ARS/fa}}. All that should be on {{PD-USGov-USDA-ARS}}. --Jarekt (talk) 19:14, 26 July 2011 (UTC)

bug with RTL languages[edit]

In Tibor Sekelj I put a summary in 24 languages. SwitchLanguages work fines with all languages but the two RTL-languages (he and yi).

  • when selecting any language, the text is shown in this language and in the RTL languages
  • when selecting one of this two ones, all languages are shown but the selected.
  • Selecting all languages, it is fine.

--Arno Lagrange 10:15, 29 August 2011 (UTC)

Bug, but I think wrong template. MediaWiki:Multilingual_description.js is maybe the right one. -- RE rillke questions? 12:38, 29 August 2011 (UTC)
No bug. They were just in a new table field. The script cannot guess what belongs to one description. I removed the new field and it works now. -- RE rillke questions? 13:02, 29 August 2011 (UTC)

no default[edit]

{{editrequest}} If there is no default only the template that bears that template should be added to the category "LangSwitch template without English version" not all pages carrying that template. But I don't know if that's possible. --Cwbm (commons) (talk) 11:50, 18 August 2012 (UTC)

I know it is a problem but as far as I know there is no way to fix it. --Jarekt (talk) 11:45, 25 October 2012 (UTC)


LangSwitch has the following prerequisites:

  1. Template:GetFallback
  2. Template:GetFallback2
  3. Extension:ParserFunctions
  4. Language codes set up in Lang, e.g. Mediawiki:Lang, Mediawiki:Lang/ru, Mediawiki:Lang/lv (is there a better solution for this?)

P.S. I suggest including this on LangSwitch documentation. DavisNT (talk) 22:59, 7 August 2013 (UTC)

Current documentation says "Relies on: {{GetFallback}}, {{GetFallback2}}". As for Parser Functions and Mediawiki:Lang, almost all commons templates depend on those. I do not see a need to add them. --Jarekt (talk) 03:40, 8 August 2013 (UTC)
I guess DavisNT tried porting this template to some private wikis or test wikis. I am not aware of a variable returning the user langue but you may ask someone from the i18n-team in #mediawiki webchat or #mediawiki-i18n webchat. -- Rillke(q?) 10:28, 27 September 2013 (UTC)

Recommend for uses outside the Template namespace?[edit]

Multiple documentation pages (including the /doc page of Template:LangSwitch itself) suggest that LangSwitch should only be used in the Template namespace. Is there any practical reason for this limitation? I would prefer LangSwitch over Mld (and even more over the simple 2-letter language templates) for galleries and for file description pages, too. Any reason why I shouldn't use it there? Thanks --Reinhard Müller (talk) 15:47, 26 September 2013 (UTC)

I think this template is used in all the namespaces, so writing in documentation that it should be only used in template namespace is a little pointless. However some people go overboard with {{LangSwitch}} templates, having different descriptions for each language or translating every field of {{Artwork}} template. So in most cases LangSwitch should be used in template namespace. I am not a big fan of Mld, and try to avoid it, but than I just use {{en}}, {{de}}, etc. and keep multiple translations of the descriptions. --Jarekt (talk) 16:47, 26 September 2013 (UTC)

New version[edit]

I have created a new Lua version at Template:LangSwitch/sandbox. It is necessary if we want to make langSwitch like function in module and it has several other benefits (more at Template talk:Fallback. From what I can see it works the same as the current version, save for a slightly different error handling, but error reports are welcome. If no one objects, I will replace the main template in a few days. --Zolo (talk) 16:36, 21 November 2013 (UTC)

Edit request: Heavily used template[edit]

{{Edit request}} Please add <noinclude>{{heavily used template}}</noinclude> to the top of this high use template (example). Riley Huntley (talk) 08:49, 30 April 2016 (UTC)

✓ Done--Jarekt (talk) 13:18, 2 May 2016 (UTC)

Langswitch considered harmful (when used beyond its intended purpose)[edit]

The "langswitch" template element was really originally intended for software interface messages (the underlying Wikimedia software telling you that some kind of error has occurred in a language that you'll understand, etc). Unfortunately, some people seem to want to extend langswitch to uses for which it was not designed, and to which it is not suited -- i.e. managing various types of general-purpose multilingual descriptions (of images, etc). In such cases, if you want to check if the translations between the different languages are correct, or see file descriptions in a language different from your browser interface language, then langswitch does nothing for you. The rigid inflexible simplistic "langswitch" approach is simply not capable of handling the various diverse situations and needs which arise in the context of multilingual image etc. descriptions, and should not generally be used for such purposes (as has been discussed previously at various times on the "Village pump". etc). AnonMoos (talk) 16:11, 30 October 2016 (UTC)

Using default with en[edit]

Is the following example from the documentation correct?


The above displays as Warsaw

Examples which show this section:

It seems that all languages fall back to en, so en will always be used if it is present. That means default has no effect when en is specified. Johnuniq (talk) 06:10, 15 September 2017 (UTC)

Yes "default" is only going to be used if there is no "en" option, so int the above example "default" will never be used. --Jarekt (talk) 18:24, 15 September 2017 (UTC)
Maybe I will change the documentation to present "default" as alternative argument name to "en". It is only useful if your default text is not English and you do not want to call it English. --Jarekt (talk) 18:42, 15 September 2017 (UTC)
Clearly I also was mistaken by default documentation.
If this is the behavior, then I will have to implement another LangSwitch.
Because with Wikidata what we want now to do is {{LangSwitch|en=...|default={{label|Q16965488}} }} which does not work.
Regards Liné1 (talk) 18:02, 22 September 2017 (UTC)
@Liné1: what will you say about this? A bug or not, but the {{label}} fallback (not to be confused with LangSwitch) in {{Maps}} is now completely knocked out “thanks” to Verdy p. I have no opinion how specifically {{LangSwitch}} should work, but, please, converge to some definite solution about it. Either keep status quo and propose another implementation, or make default= usable here. Incnis Mrsi (talk) 17:23, 17 February 2018 (UTC)
@Incnis Mrsi: Again this is a bug in Module:Fallback which still does not correctly handle the "default" we need on Commons. See the talk page of this module and the Module talk:Fallback/testcases showing the strategy we want on Commons (this is a limitation of the internal MediaWiki fallback chains that do not include any "default" option in the fallback lists it currently returns; but we can work around this, as demonstrated in the testcases). I have documented the small change needed in the talk page of the module. This is how it worked on Commons before the module was rewritten to use the fallbacks exported by MW, instead of the local lists of fallbacks where Commons has always needed a "default" option to come first before the "en" option. verdy_p (talk) 17:28, 17 February 2018 (UTC)
That's wrong, the default is used first, before using fallback to English. This default will not be used is you look for the English version and there's an "en" value supplied, or if a language has an "explicit" fallback coming first to English, instead of using the other fallbacks including "default" at end.
That's how it should work, and so specifying *both* "default" and "en" has a meaning, they are at different places of the fallback chains.
This allows tracking missing translations where an additional formatting (or note) is necessary, which won't be used in the plain English version. English ("en") is effectively in the last position of all chains, the penultimate position being the "default".
As well the "default" is not necessarily in English or could be "international English" different from the standard English used in "en", to avoid some (implicit) semantic shortcuts used in US ("en" is often tuned for "en-US" for topics geolocated in US and all non-geolocated topics, or tuned for "en-GB" for topics geolocated in UK), but when the "default" is used to display English text, it is better for English-speaking users living elsewhere, in UK (if the "en" resource was tuned for US), or in US (if the "en" resource was tuned for UK), or in India, South Africa, etc.
The "default" is not necessarily in English and may be an official local toponym adopting its standardized orthography (not used in US where it was simplified), and even the "default" may be in another non-Latin script for this case. So "en" has very low priority for all other languages, "default" is more international and more standard. verdy_p (talk) 15:57, 17 February 2018 (UTC)
I did not follow the conversation, but clearly default should be prioritary to en. In fact I don't even know how to document a default= parameters used only when there is no en=. Regards Liné1 (talk) 22:02, 17 February 2018 (UTC)
You've effectively not followed the discussion: "default" is to be used independantly of the presence of "en". It is pêrfectly valid to have both set differently (see the example above as an application, where English (or variants of English) would go to a Wikipedia article in English, and any unspecified language would go to Wikidata via the "default"). There are may other uses of the "default", such as tracking untranslated messages in categories, or asking for translators to improve the translation by adding a real one instead of the default one (possibly in English but not necessarily, it is just a text meant to be usable by most people including non-English readers). That's exactly what I've done in the sandbox version, which multiple users have confirmed to be correct, and which unifies the management of fallbacks, by adding automatically the fallbacks that are built in MediaWiki (but only for its own UI translations), after the translations tuned specifically on Commons in the "Fallback" data module.
Also I made it more compliant to BCP47, by taking into account automatically for all languages coming from the two existing sources of fallbacks those that are variants of a base language, and automatically adding the base language to the list (local on this Commons Wiki, and global on MediaWiki), and here again these additions for variants are taken AFTER each source of fallbacks, so we have full control on the search order for fallback and never see any one missing. As well the code is more optimal, avoids all non trailing recursions, runs faster, and even uses less memory. verdy_p (talk) 01:48, 21 February 2018 (UTC)

Mapping the same value to several languages with LangSwitch[edit]

I'd like to make another improvement to "LangSwitch" : being able to specify parameters that are comma-separated (or space separated) lists of languages to which we want to map the same translation.

Unlike "#switch:" where it is simple (use a vertical bar to separate languages and map the same value after the next equal sign), it is not possible with the template syntax of "LangSwitch" (you need to map each language individually to the same value, which may be quite complex in some templates), but we could pass multiple languages in the same parameter name: it is perfectly possible because valid language codes do not contain any space, or comma, only character in [a-z0-9] or hyphens [-] (note that underscores are also recognized as equivalent as hyphens, and the letter case of given language codes is not significant).

So I just propose to parse in Module:Fallback these parameter names and split them where they contain commas (or spaces), as if we had passed separate parameters with the same value (at the same time I can detect if the same language is specified twice in separate parameters and render a usage error, this duplication is already possible by passing for example "|en=value1|EN=value2" and the effect is unspecified as we can't predict which value will be used). This would also simplify various cases, for example "|hr,sr-latn,bs=value1" instead of "|hr=value1|sr-latn=value1|bs=value1", or "|ko,ja,wuu,yue,zh-hant=value2" instead of "|ko=value2|ja=value2|wuu=value2|yue=value2|zh-hant=value2" to reduce the code size of various templates. verdy_p (talk) 01:48, 21 February 2018 (UTC)