Terraria Wiki
Terraria Wiki
K (sync :: en revid:970564::)
K (sync :: en revid:1027592::)
Zeile 1: Zeile 1:
 
<includeonly><!--
 
<includeonly><!--
  +
-->{{#dplvar:set<!--
trim:
 
-->{{#vardefine:l10n:reg:_p|l10n:{{#trim:{{{2|en}}}}}:{{#trim:{{{1|}}}}}}}<!-- $1 = namespace, $2 = lang
+
-->|l10n:reg:namespace|{{{1|}}}<!--
  +
-->|l10n:reg:lang|{{{2|en}}}<!--
each namespace+lang register only once:
 
  +
-->}}<!--
-->{{#if:{{#dplvar:{{#var:l10n:reg:_p}}:1}}||<!-- if not flag
 
  +
  +
=========================================================================================
  +
If it is autoloading, we only load the language {{l10n|}} needed from /l10n.
  +
  +
For example, for {{l10n|foo|bar|en}}, if it trigger the autoloading, only {{register|test|en|...}} in Template:Test/l10n will actually be registered.
  +
Registers for other languages will skip register process and only set an "exists" flag for that language. By doing so, when we actually need l10n info for that language, autoload will know whether it exists or not, and only load /10n again when there is {{l10/register}} for that language.
  +
  +
By this way, we can avoid to process numerous l10n register for those never used languages, and thus save a lot of runtime resources.
  +
=========================================================================================
  +
  +
{{#var:l10n:autoloading}} is the langcode currently want to autoload. If empty, this register is transcluded manually.
  +
  +
//autoloaded flag: this namespace has been autoloaded.
  +
-->{{#dplvar:set|l10n:autoloaded:{{#dplvar:l10n:reg:namespace}}|{{#var:l10n:autoloading}}}}<!--
  +
  +
-->{{#if:{{#switch:{{#dplvar:l10n:reg:lang}}|{{#var:l10n:autoloading}}|en=y|#default={{#if:{{#var:l10n:autoloading}}||y}}}}|<!--
  +
load all when language matched or is manually transcluded, and always load en lang.
 
-->{{#forargs:|l10n:reg:_key|l10n:reg:_value|<!--
 
-->{{#forargs:|l10n:reg:_key|l10n:reg:_value|<!--
-->{{#dplvar:set|{{#var:l10n:reg:_p}}:{{#var:l10n:reg:_key}}|{{#var:l10n:reg:_value}}}}<!--
+
-->{{#dplvar:set|l10n:{{#dplvar:l10n:reg:namespace}}:{{#dplvar:l10n:reg:lang}}:{{#var:l10n:reg:_key}}|{{#var:l10n:reg:_value}}}}<!--
 
-->}}<!--
 
-->}}<!--
  +
-->|<!--
  +
autoload and lang not matched, set language flag only
  +
-->{{#dplvar:set|l10n:{{#dplvar:l10n:reg:namespace}}:{{#dplvar:l10n:reg:lang}}:2|y}}<!--
 
-->}}<!--
 
-->}}<!--
  +
  +
If it is autoloading, now:
  +
* If {{#dplvar:l10n:<namespace>:<lang>:1}} is true, l10n info for this language has loaded, just use it.
  +
* Otherwise, {{#dplvar:l10n:autoloaded:<namespace>}} marks whether a namespace has been autoloaded or not, if this namespace has been autoloaded, {{#dplvar:l10n:<namespace>:<lang>:2}} marks whether there is l10n for info this language in /10n. Only re-load when it is true.
  +
 
--></includeonly><noinclude>{{doc}}</noinclude>
 
--></includeonly><noinclude>{{doc}}</noinclude>

Version vom 17. Juni 2020, 04:57 Uhr

Template-noinfo.svg Dokumentation
Siehe auch die englische Vorlagenseite: Template:Localization/register. Sie enthält möglicherweise umfassendere oder aktuellere Informationen.

Für diese Vorlage gibt es noch keine Dokumentations-Unterseite. Erstelle jetzt eine.