Difference between revisions of "Template:GetHonorName"

From Pathfinder Wiki
Line 6: Line 6:
 
<nowiki>{{GetHonorName|page=AY Honors/Alternative Fuels/Requirements/es}}</nowiki><br/>
 
<nowiki>{{GetHonorName|page=AY Honors/Alternative Fuels/Requirements/es}}</nowiki><br/>
 
{{GetHonorName|page=AY Honors/Alternative Fuels/Requirements/es}}
 
{{GetHonorName|page=AY Honors/Alternative Fuels/Requirements/es}}
 +
<nowiki>{{GetHonorName|page=AY Honors/Alternative Fuels (United States)/Requirements}}</nowiki><br/>
 +
{{GetHonorName|page=AY Honors/Alternative Fuels (United States)/Requirements}}
  
 
==How does it work?==
 
==How does it work?==

Revision as of 18:59, 21 March 2021

This template will return the translated honor name of the specified page. If no page parameter is supplied, it operates on the page invoking the template.

{{GetHonorName|page=AY Honors/Alternative Fuels/Requirements}}
Alternative Fuels
{{GetHonorName|page=AY Honors/Alternative Fuels/Requirements/es}}
Combustibles alternativos {{GetHonorName|page=AY Honors/Alternative Fuels (United States)/Requirements}}
Alternative Fuels (United States)

How does it work?

When a page is translated, the page title is also (usually) translated. This translation is saved at [[Translations:source_page_name/Page display title/language]]. This template first uses {{GetLanguageSuffix}} to determine the language of the page. That template will return an empty string if this is the English page (or source page).

The output of GetLangSuffix is passed to an #if parser. If it returns a non-empty string, this template will strip the last element (the language code) off the invoking page, prepends the Translations: name space to it, and then appends "Page display title" and the language code. This give us the name of the page that has the translated title. The contents of that page is passed to the outer #titleparts which extracts the second element from that page name.

This assumes that the second element of the page title is the honor name (as in "AY Honors/honorname/subpages/language".