Difference between revisions of "Template:LocalizePrintf"

From Pathfinder Wiki
Line 2: Line 2:
 
  | value
 
  | value
 
  | {{#vardefine:znum|{{#expr:{{#var:number}}-1}}}}
 
  | {{#vardefine:znum|{{#expr:{{#var:number}}-1}}}}
{{#ifeq:{{#var:number}}|1|{{#vardefine:string|{{#var:value}}}}
+
{{#ifeq:{{#var:number}}|1|{{#vardefine:string|{{#lst:Localization:All{{GetLangSuffix}}|{{#var:value}}}}}}
  |{{#vardefine:string|{{#replace:{{#var:string}}|%{{#var:znum}}|{{#var:value}}}}}}}}
+
  |{{#vardefine:string|{{#replace:{{#var:string}}|%{{#var:znum}}|{{#lst:Localization:All{{GetLangSuffix}}|{{#var:value}}}}}}}}}}
 
}}{{#var:string}}
 
}}{{#var:string}}
 
</includeonly>
 
</includeonly>
Line 11: Line 11:
  
 
Here is an example:
 
Here is an example:
<nowiki>{{</nowiki>{{FULLPAGENAME}}|The quick brown fox jumps over the lazy dog}}<br/>
+
<nowiki>{{</nowiki>{{FULLPAGENAME}}|The red rose}}<br/>
  
{{{{FULLPAGENAME}}|The quick brown fox jumps over the lazy dog}}
+
{{{{FULLPAGENAME}}|The red rose}}
  
 
It is also possible to pass in numbered place-holders in the form of %''n'' where ''n'' is a number starting at 1.  The arguments that follow will replace the placeholders:
 
It is also possible to pass in numbered place-holders in the form of %''n'' where ''n'' is a number starting at 1.  The arguments that follow will replace the placeholders:
  
<nowiki>{{</nowiki>{{FULLPAGENAME}}|The %1 brown %2 jumps %3 the %4 dog<br/>
+
<nowiki>{{</nowiki>{{FULLPAGENAME}}|The %1 rose<br/>
|quick<br/>
+
|red<br/>
|fox<br/>
 
|over<br/>
 
|lazy<br/>
 
 
}}
 
}}
  
{{{{FULLPAGENAME}}|The %1 brown %2 jumps %3 the %4 dog
+
{{{{FULLPAGENAME}}|The %1 rose|red}}
|quick
 
|fox
 
|over
 
|lazy
 
}}
 
 
 
The order of the placeholders can be swapped around to help with syntax issues:
 
 
 
<nowiki>{{</nowiki>{{FULLPAGENAME}}|The %2 brown %1 jumps %3 the %4 dog<br/>
 
|fox<br/>
 
|quick<br/>
 
|over<br/>
 
|lazy<br/>
 
}}<br/>
 
  
{{{{FULLPAGENAME}}|The %2 brown %1 jumps %3 the %4 dog
 
|fox
 
|quick
 
|over
 
|lazy
 
}}
 
 
</noinclude>
 
</noinclude>

Revision as of 01:01, 1 March 2021


This template returns a localized version of a "canned" phrase that we use in the interfaces. The phrase passed in is in English, but the output is in the language of the page that invokes it. Therefore if we call the template from [[some page]], we'd get the English version of the page, but if we call it from [[some page/es]], we would get the Spanish version of the phrase.

Here is an example: {{Template:LocalizePrintf|The red rose}}


It is also possible to pass in numbered place-holders in the form of %n where n is a number starting at 1. The arguments that follow will replace the placeholders:

{{Template:LocalizePrintf|The %1 rose
|red
}}