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...")
 
 
(8 intermediate revisions by 2 users not shown)
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}}}}
{{#ifeq:{{#var:number}}|1|{{#vardefine:string|{{#var:value}}}}
+
{{#ifeq:{{#var:number}}|1
|{{#vardefine:string|{{#replace:{{#var:string}}|%{{#var:znum}}|{{#var:value}}}}}}}}
+
      |{{#vardefine:string|{{Localize|{{#var:value}}}}}}
}}{{#var:string}}
+
      |{{#vardefine:string|{{#replace:{{#var:string}}
</includeonly>
+
                                      |%{{#var:znum}}
 +
                                      |{{#var:value}}
 +
                            }}
 +
        }}
 +
}}
 +
}}{{#var:string}}</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.   
 +
 
 +
All output phrases are found in [[Localization:All]], [[Localization:All/es]], etc.  If you need to add a new phrase, it should be added there (and translated).
 +
 
 +
It is built upon the [[Template:Localize|Localize-Template]], so to understand it completely, read the documentation there too. Also it has some nice features, about which it is good to know about.
  
 
Here is an example:
 
Here is an example:
 +
<nowiki>{{</nowiki>{{FULLPAGENAME}}|Edit Overview}}<br/>
 +
 +
{{{{FULLPAGENAME}}|Edit Overview}}
 +
 +
It is also possible to pass in numbered place-holders in the form of %''n'' where ''n'' is a number between 1 and 9 (it stops at 9 because %1 will match %10 - maybe we could fix that, but we really shouldn't need that many place-holders).  The arguments that follow will replace the placeholders:
  
<nowiki>{{</nowiki}}LocalizePrintf|The %1 brown %2 jumps %3 the %4 dog
+
<nowiki>{{</nowiki>{{FULLPAGENAME}}|The %1 rose<br/>
|quick
+
|red<br/>
|fox
 
|over
 
|lazy
 
 
}}
 
}}
  
----
+
{{{{FULLPAGENAME}}|The %1 rose|red}}
{{LocalizePrintf|The %1 brown %2 jumps %3 the %4 dog
+
 
|quick
+
[[Category:Localization Templates]]
|fox
 
|over
 
|lazy
 
}}
 
 
</noinclude>
 
</noinclude>

Latest revision as of 03:40, 31 January 2022


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.

All output phrases are found in Localization:All, Localization:All/es, etc. If you need to add a new phrase, it should be added there (and translated).

It is built upon the Localize-Template, so to understand it completely, read the documentation there too. Also it has some nice features, about which it is good to know about.

Here is an example: {{Template:LocalizePrintf|Edit Overview}}

Edit Overview


It is also possible to pass in numbered place-holders in the form of %n where n is a number between 1 and 9 (it stops at 9 because %1 will match %10 - maybe we could fix that, but we really shouldn't need that many place-holders). The arguments that follow will replace the placeholders:

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

The red rose