Difference between revisions of "Category:Language aware Templates"

From Free Pascal wiki
Jump to navigationJump to search
(Description with examples)
 
(+ category)
Line 12: Line 12:
 
| Warning
 
| Warning
 
}}</pre>
 
}}</pre>
 +
 +
 +
[[Category:Wiki]]

Revision as of 15:20, 2 June 2015

This category shall contain all Wiki templates which are language aware and show texts which are translated to the transcluding page.

Example

Page Installing Lazarus uses {{Warning|Warning text}} and will show up the text Warning: Warning text whereas the German page Installing Lazarus/de uses {{Warning|Text der Warnung}} which will show up as 'Warnung: Text der Warnung. Both pages use the same template.

How To use in templates

This expression {{#titleparts:{{PAGENAME}}| | -1}} retrieves the language part of the page (e.g. de for German). The {{#switch: statement gets the actual string depending on the language. If no language is available, the default string will be shown.

{{#switch:{{#titleparts:{{PAGENAME}}| | -1}}
| de= Warnung
| en= Warning
| fr= Avertissement
| Warning
}}