Difference between revisions of "Template:LocalizePrintf"

From Pathfinder Wiki
(Created page with "<includeonly><nowiki/> {{#fornumargs: number | value | {{#vardefine:znum|{{#expr:{{#var:number}}-1}}}} {{#ifeq:{{#var:number}}|1|{{#vardefine:string|{{#var:value}}}} |{{#v...")
 
Line 1: Line 1:
<includeonly><nowiki/>
+
<includeonly><nowiki/>{{#fornumargs: number
 
 
{{#fornumargs: number
 
 
  | value
 
  | value
 
  | {{#vardefine:znum|{{#expr:{{#var:number}}-1}}}}
 
  | {{#vardefine:znum|{{#expr:{{#var:number}}-1}}}}
Line 9: Line 7:
 
</includeonly>
 
</includeonly>
 
<noinclude>
 
<noinclude>
This template returns a localized version of a "canned" phrase that we use in the interfaces.  THe phrase is in the language of the page that invokes it, so if we call the template from  
+
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  
<nowiki>[[</nowiki>some page<nowiki>[[</nowiki>some page]], we'd get the English version of the page, but if we call it from <nowiki>[[</nowiki>some page/es]], we would get the Spanish version of the phrase.   
+
<nowiki>[[</nowiki>some page]], we'd get the English version of the page, but if we call it from <nowiki>[[</nowiki>some page/es]], we would get the Spanish version of the phrase.   
  
 
Here is an example:
 
Here is an example:
 +
<nowiki>{{</nowiki>{{FULLPAGENAME}}|The quick brown fox jumps over the lazy dog}}<br/>
  
<nowiki>{{</nowiki}}LocalizePrintf|The %1 brown %2 jumps %3 the %4 dog
+
{{{{FULLPAGENAME}}|The quick brown fox jumps over the lazy dog}}
 +
 
 +
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/>
 +
|quick<br/>
 +
|fox<br/>
 +
|over<br/>
 +
|lazy<br/>
 +
}}
 +
 
 +
{{{{FULLPAGENAME}}|The %1 brown %2 jumps %3 the %4 dog
 
|quick
 
|quick
 
|fox
 
|fox
Line 21: Line 31:
 
}}
 
}}
  
----
+
The order of the placeholders can be swapped around to help with syntax issues:
{{LocalizePrintf|The %1 brown %2 jumps %3 the %4 dog
+
 
 +
<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
 
|quick
|fox
 
 
|over
 
|over
 
|lazy
 
|lazy
 
}}
 
}}
 
</noinclude>
 
</noinclude>

Revision as of 00:52, 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 quick brown fox jumps over the lazy dog}}

The quick brown fox jumps over the lazy dog


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 brown %2 jumps %3 the %4 dog
|quick
|fox
|over
|lazy
}}

The quick brown fox jumps over the lazy dog


The order of the placeholders can be swapped around to help with syntax issues:

{{Template:LocalizePrintf|The %2 brown %1 jumps %3 the %4 dog
|fox
|quick
|over
|lazy
}}

The quick brown fox jumps over the lazy dog