Module talk:LangSwitch

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

error[edit]

@Jarekt: can you take care for "LangSwitch Error: no default" at Category:Chemnitz please? --Te750iv (talk) 13:51, 4 June 2018 (UTC)[reply]

Fixed see here. --Jarekt (talk) 15:48, 4 June 2018 (UTC)[reply]

lang=no (Norwegian) falls back to {{int:lang}}[edit]

{{Editprotected}} @Jarekt: I'm testing the following code:

{{LangSwitch
 |lang=no
 |en=en-test
 |no=no-test
 |ru=ru-test
 |#default=DEFAULT
}}

If I set the user interface language to English, the code outputs "en-test"; if I set Russian, it outputs "ru-test". Despite having |lang=no, I can't make this code output "no-test". If I set |lang=en or |lang=ru, then this code is not sensitive to user interface language, and the output is as expected. DmitTrix (talk) 17:38, 19 October 2018 (UTC)[reply]

Test: no-test. DmitTrix (talk) 20:05, 19 October 2018 (UTC)[reply]

  • No, I mean code no, which refers to Norwegian language without further specifying whether it's Bokmål (code nb) or Nynorsk (code nn). When I explicitly set |lang=no in LangSwitch, I expect it to output the value given in |no=value, rather than falling back to the language that the user has set for the interface. See the testcase at the end of my original post. DmitTrix (talk)
PS: I think this phab:T102533#4425468 describes the situation exact. So the question is, should we accept 'no' or not (I thinks the only answer is no). -- User: Perhelion 13:43, 25 February 2019 (UTC)[reply]
✓ Done now supported -- User: Perhelion 13:54, 25 February 2019 (UTC)[reply]
 Thank you. DmitTrix (talk) 14:06, 25 February 2019 (UTC)[reply]

I created new Module:LangSwitch/sandbox using isKnownLanguageTag function instead of "isSupportedLanguage". I also added Perhelion's "quick switch" to the _langSwitch function used by other modules. I tested it at Module talk:LangSwitch/sandbox/testcases and if there are no other issues I will make that version live tomorrow. --Jarekt (talk) 14:43, 25 February 2019 (UTC)[reply]

Oops seems like Perhelion beat me to it as I was testing. --Jarekt (talk) 14:45, 25 February 2019 (UTC)[reply]

Option to machine-readably mark output language[edit]

Machine-readable language (using the HTML lang attribute) helps in many cases from assistive technology (e.g. screen readers) and search engine optimization to usual browsers (e.g. in case of right-to-left languages appearing in the right direction). When using this module, the caller template has no clue what languages are available (apart from duplicating data by hard coding what language parameters are present in the module call), so only this module knows what language is actually used. I would like to ask an extra parameter which can have the values “span” and “div”, and if one of these is given, it wraps the translation in the appropriate tag, e.g.

{{#invoke:LangSwitch|langSwitch|en=English text|fr=texte français|lang=fr|wrap=span}}

would become

<span lang="fr" dir="ltr">texte français</span>

(another parameter name can be used if a better is found). Of course, this mechanism should not be used automatically, as the langSwitch output is often used at places where HTML code is undesirable and causes errors. —Tacsipacsi (talk) 11:25, 23 June 2019 (UTC)[reply]

Multiple languages[edit]

In SVG, multiple languages can be assigned by e.g.

 ... systemLanguage="de,en,nl" ...

It is fine that multilinguality can be defined with e.g.

{{LangSwitch
 |de/en/nl = ...
 |fr = ...

It seems finer when also LangSwitch would allow commata as separators, e.g.

{{LangSwitch
 |de,en,nl = ...
 |fr = ...

That will be no problem when stmt 130 of the module changes from

for str in string.gmatch( name, "([^/]+)" ) do

to

for str in string.gmatch( name, "([^/,]+)" ) do

As a test, I did it at Module:LangSwitch/sandbox before I saw that it is used 353 K times.
Neveretheless, it works, with slashes as well as with commata, e.g.

{{LangSwitch/sandbox
 |de,en,nl = ...
 |fr/hr/it = ...
 |sl/sr,sv = ...

The current version of Multilingual description/Mld also allows both separators !
I would like to have this expansion -- sarang사랑 05:14, 1 August 2022 (UTC)[reply]

require('strict')[edit]

{{Edit protected}} As per the new lua feature mentioned at m:Tech/News/2022/42, could require('Module:No globals') be replaced with require('strict') -- WOSlinker (talk) 17:21, 25 October 2022 (UTC)[reply]

✓ Done Awesome! Thank you! —‍Mdaniels5757 (talk • contribs) 17:41, 29 October 2022 (UTC)[reply]

Error: no default[edit]

The module mistakenly gives back Error: no default when the default or English version is associated with other languages, e.g. |de/en/it/nl = xxx or |default/de/en/it/nl = xxx (the second option was just a try to understand how the error works). The module should recognize the default or English version even when they're in a group with other language codes. Daniele Fisichella 07:42, 21 June 2023 (UTC)[reply]

add_labels[edit]

I removed parameter "add_labels" from {{Madonna and Child}}. It was intended to be used as a parameter in Artwork template. Somebody decided to put it into a section title of a gallery page, namely Jacopo Tintoretto. I noticed similar issues with {{Still-life}} at Francisco de Zurbarán, {{Portrait of a woman}} at Rembrandt/1634-1645. Jarash (talk) 11:23, 4 September 2023 (UTC)[reply]