Difference between revisions of "Template:Localize"

From Pathfinder Wiki
Line 1: Line 1:
<includeonly><nowiki/>{{#lst:Localization:All{{GetLangSuffix}}|{{{1|Phrase cannot be localized}}}}}</includeonly><noinclude>
+
<includeonly><nowiki/>{{#fornumargs: number
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  
+
| value
<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.   
+
| {{#vardefine:znum|{{#expr:{{#var:number}}-1}}}}
 +
{{#ifeq:{{#var:number}}|1|{{#vardefine:string|{{#lst:Localization:All{{GetLangSuffix}}|{{#var:value}}}}}}
 +
|{{#vardefine:string|{{#replace:{{#var:string}}|%{{#var:znum}}|{{#lst:Localization:All{{GetLangSuffix}}|{{#var:value}}}}}}}}}}
 +
}}{{#var:string}}
 +
</includeonly>
 +
<noinclude>
 +
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]], 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>Localize|Answer Key}}
+
<nowiki>{{</nowiki>{{FULLPAGENAME}}|The red rose}}<br/>
  
{{Localize|Answer Key}}
+
{{{{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:
 +
 
 +
<nowiki>{{</nowiki>{{FULLPAGENAME}}|The %1 rose<br/>
 +
|red<br/>
 +
}}
 +
 
 +
{{{{FULLPAGENAME}}|The %1 rose|red}}
  
 
</noinclude>
 
</noinclude>

Revision as of 03:28, 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:Localize|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:Localize|The %1 rose
|red
}}