Module talk:LangSwitch
error
[edit]@Jarekt: can you take care for "LangSwitch Error: no default" at Category:Chemnitz please? --Te750iv (talk) 13:51, 4 June 2018 (UTC)
Fixed see here. --Jarekt (talk) 15:48, 4 June 2018 (UTC)
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)
Test: no-test. DmitTrix (talk) 20:05, 19 October 2018 (UTC)
- Hey DmitTrix, I can't confirm your claim, maybe you mean Norwegian Nynorsk which code is nn!? -- User: Perhelion 22:43, 24 February 2019 (UTC)
- No, I mean code
no
, which refers to Norwegian language without further specifying whether it's Bokmål (codenb
) or Nynorsk (codenn
). 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)
- Oh, I see now what you mean. This is depending on
mw.language.isSupportedLanguage
. Then simply "no" is not a supported language here... -- User: Perhelion 12:24, 25 February 2019 (UTC)
- So, what should be the next step?
no
is a valid ISO639 language code… Can this be worked around in the module (with someif
)? DmitTrix (talk) 12:36, 25 February 2019 (UTC)
- I opened a ticket phab:T217022 -- User: Perhelion 12:52, 25 February 2019 (UTC)
- We could simply use
isKnownLanguageTag
instead, but I'm not sure. @Jarekt: -- User: Perhelion 13:01, 25 February 2019 (UTC)
- 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)
- So, what should be the next step?
- Oh, I see now what you mean. This is depending on
- No, I mean code
Done now supported -- User: Perhelion 13:54, 25 February 2019 (UTC)
Thank you. DmitTrix (talk) 14:06, 25 February 2019 (UTC)
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)
- Oops seems like Perhelion beat me to it as I was testing. --Jarekt (talk) 14:45, 25 February 2019 (UTC)
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)
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)
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)
Done Awesome! Thank you! —Mdaniels5757 (talk • contribs) 17:41, 29 October 2022 (UTC)
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)
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)