Template talk:Stub text: Difference between revisions

From MEpedia, a crowd-sourced encyclopedia of ME and CFS science and history
m (reply)
 
Line 18: Line 18:
</pre>
</pre>
::::Hope this helps [[User:Pyrrhus|Pyrrhus]] ([[User talk:Pyrrhus|talk]]) 23:57, August 22, 2019 (EDT)
::::Hope this helps [[User:Pyrrhus|Pyrrhus]] ([[User talk:Pyrrhus|talk]]) 23:57, August 22, 2019 (EDT)
:::::I think I'm finally grasped it. I was using int:lang like a template by mistake, the code I used was a syntax error which somehow always resulted in false. <nowiki>{{int:lang}}</nowiki > always defaults to the value in [[MediaWiki:lang/en]] because "en" is the wiki's language, so never needs an ifeq statement. But there are times when templates need to check the value of a parameter called "lang", and if it doesn't exist fallback to <nowiki>{{int:lang}}</nowiki >. I will do an update of the code. Thanks for your help. [[User:Notjusttired|notjusttired]] ([[User talk:Notjusttired|talk]]) 12:49, August 23, 2019 (EDT)

Latest revision as of 16:49, August 23, 2019

{{int:lang|en}} will not work -- Pyrrhus (talk) 14:03, August 22, 2019 (EDT)[edit source | reply | new]

{{int:lang|en}} will not work, since MediaWiki:lang does not contain a $1, and does not accept parameters. I think you are confusing variables with parser functions. With variables, you can set a fallback value, as in {{lang|en}}. This works. But it won't work with a parser function, so {{int:lang|en}} won't work. Here is the code you are looking for:

{{#ifeq: {{int:lang}} | ⧼lang⧽ | en | {{int:lang}} }}

Pyrrhus (talk) 14:03, August 22, 2019 (EDT)

This isn't looking for a parameter, {{abc|test}} syntax just means if the value returned by "abc" is blank then default to "test". {{int:lang}} doesn't take parameters but finds the user's language and uses the value MediaWiki:lang/de (for instance). Any user with a language not set falls back to "en" using the setting in LocalSettings.php. The code to fallback to "en" should hopefully never be used, but isn't a problem to leave there. en</nowiki > is more useful because if no "lang" parameter exists it defaults to "en" - this is more useful for things like defaulting little used languages or variants / dialects to a language with better support, eg if Afrikaans is passed in then it can fall back to English when no Afrikaans is available, or Galician (regional language in Spain) can fall back to Spanish (Spain has multiple official languages). Two {{ }} is used for templates, if statements or switches etc, and int:lang, three {{{ }}}are used for parameters or magic words.

This template is now working after today's changes here and in the Asbox module. notjusttired (talk) 14:32, August 22, 2019 (EDT)

You're confused. {{int:}} does take parameters and you have introduced a syntax error. I have described how {{int:}} takes parameters here: MEpedia:Template_translation#Using_the_MediaWiki:_namespace_for_template_translations. Again, you are confusing variables and parser functions. Please review what I wrote so you don't create more syntax errors.
Pyrrhus (talk) 17:21, August 22, 2019 (EDT)
I read your documentation and checked elsewhere too. It turns out int: is a magic word needing {{ }} - parser functions always start with # eg invoke or if are parser functions. Oddly what MediaWiki calls a "variable" seems to be more a system generated value which is confusing. If you want the |"en" fallback to go I'm fine with that, or any other change as long as it works. At the moment I am pretty foggy headed as I'm sure it's obvious.
User:Pyrrhus Are you ever having issues with not getting notifications when tagged in pages? I seem to be missing some at times. notjusttired (talk) 20:17, August 22, 2019 (EDT)
I haven't noticed any problems with not getting notifications, but the notifications seem to "disappear" after a certain period of time. Weird. Note that not all parser functions start with #. "int:" is a parser function. Both parser functions and system variables are both considered "magic words". And a system variable is different from a template variable. It's all too damn confusing, I know. :) But there's absolutely nothing wrong with the "en" fallback, as long as the syntax is correct. For "int:lang", here is the correct syntax:
{{#ifeq: {{int:lang}} | ⧼lang⧽ | en | {{int:lang}} }}
Hope this helps Pyrrhus (talk) 23:57, August 22, 2019 (EDT)
I think I'm finally grasped it. I was using int:lang like a template by mistake, the code I used was a syntax error which somehow always resulted in false. {{int:lang}} always defaults to the value in MediaWiki:lang/en because "en" is the wiki's language, so never needs an ifeq statement. But there are times when templates need to check the value of a parameter called "lang", and if it doesn't exist fallback to {{int:lang}}. I will do an update of the code. Thanks for your help. notjusttired (talk) 12:49, August 23, 2019 (EDT)