Difference between revisions of "Template:GetHonorMetaData"

From Pathfinder Wiki
 
(9 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
                     }}
 
                     }}
 
             }}}
 
             }}}
 +
}}{{#vardefine:localizationSource|{{#ifeq:{{{parameter}}}|authority|Authorities|All}}
 
}}{{#vardefine:landingpage
 
}}{{#vardefine:landingpage
 
             |{{#titleparts:{{#var:page}}|2}}
 
             |{{#titleparts:{{#var:page}}|2}}
Line 11: Line 12:
 
|title={{#var:landingpage}}
 
|title={{#var:landingpage}}
 
|include={{{{template|HonorLanding}}}}:{{{parameter|category}}}}}
 
|include={{{{template|HonorLanding}}}}:{{{parameter|category}}}}}
}}{{#if:{{#var:pvalue}}
+
}}{{#if:{{{dontTranslate|}}}
    |{{#vardefine:localOutput
+
    ||{{#if:{{#var:pvalue}}
                  |{{#lst:Localization:All{{{language|{{GetLangSuffix}}}}}
+
          |{{#vardefine:localOutput
                        |{{#var:pvalue}}
+
                |{{Localize|{{#var:pvalue}}|{{#var:localizationSource}}|language={{{language|{{PAGELANGUAGE}}}}}}}
                  }}
+
          }}
      }}
+
    }}
}}{{#if:{{#var:localOutput}}|{{#var:localOutput}}|{{#var:pvalue}}}}{{#if:{{{debug|1}}}
+
}}{{#if:{{#var:localOutput}}|{{#var:localOutput}}|{{#var:pvalue}}}}{{#if:{{{debug|}}}
 
|*landingpage={{#var:landingpage}}
 
|*landingpage={{#var:landingpage}}
 
*parameter={{{parameter|category}}}
 
*parameter={{{parameter|category}}}
Line 25: Line 26:
 
*srcpage={{#var:srcpage}}
 
*srcpage={{#var:srcpage}}
 
}}</includeonly><noinclude>
 
}}</includeonly><noinclude>
This template returns the value of a parameter as defined in a template on a given honor landing page. Unless told otherwise, it will localize the parameter value into the language of the invoking page. If no localization for the parameter value exists, it will return the parameter as it exists in the honor's landing page in the source language.
+
This template returns the value of a parameter as defined in a template on a given honor landing page. Unless told otherwise, it will localize the parameter value into the language of the invoking page. If no localization for the parameter value exists, it will return the parameter as it exists in the honor's landing page in the source language.
  
If the template cannot locate the desired data, it will return an empty string. This can happen if the specified page does not use the specified template, or if the page does not specify the parameter requested.
+
If the template cannot locate the desired data, it will return an empty string. This can happen if the specified page does not use the specified template, or if the page does not specify the parameter requested.
  
 
It takes up to four arguments:
 
It takes up to four arguments:
;page|honor: You can specify either the page or the honor. If you specify both it will use page. If you specify neither, it will assume you are on an honor page or subpage and treat the first two elements of the invoking page's title as the page. The page argument is the page title of an honor or one of its subpages.
+
;page|honor: You can specify either the page or the honor. If you specify both it will use page. If you specify neither, it will assume you are on an honor page or subpage and treat the first two elements of the invoking page's title as the page. The page argument is the page title of an honor or one of its subpages.
;template: Specifies which template holds the parameter you want. If omitted, it defaults to HonorLanding, but if you are experimenting and have some other template in place, you can specify it.
+
;template: Specifies which template holds the parameter you want. If omitted, it defaults to HonorLanding, but if you are experimenting and have some other template in place, you can specify it.
;parameter: This specifies which parameter of template you want the template to return. If omitted, it will assume you want the category parameter.
+
;parameter: This specifies which parameter of template you want the template to return. If omitted, it will assume you want the category parameter.
 
;language: This takes a language suffix. The available once can be seen at [[Template:GetLangSuffix]]. If non is provided, the template will translate the data to the language of the page it has been invoked off. Don't forget the /
 
;language: This takes a language suffix. The available once can be seen at [[Template:GetLangSuffix]]. If non is provided, the template will translate the data to the language of the page it has been invoked off. Don't forget the /
 +
 +
With the new translation system in place, translating the insignia resulted in a error message. Now there is the argument ''dontTranslate'' set it to anything you want and the output, doesn't get translated.
  
 
==Examples==
 
==Examples==
Line 39: Line 42:
 
*<nowiki>{{</nowiki>GetHonorMetaData|page=AY Honors/Cycling/Requirements/es|parameter=skill}} &rarr; {{GetHonorMetaData|page=AY Honors/Cycling/Requirements/es|parameter=skill}}
 
*<nowiki>{{</nowiki>GetHonorMetaData|page=AY Honors/Cycling/Requirements/es|parameter=skill}} &rarr; {{GetHonorMetaData|page=AY Honors/Cycling/Requirements/es|parameter=skill}}
 
*<nowiki>{{</nowiki>GetHonorMetaData|honor=Camping Skills III|parameter=authority}} &rarr; {{GetHonorMetaData|honor=Camping Skills III|parameter=authority}}
 
*<nowiki>{{</nowiki>GetHonorMetaData|honor=Camping Skills III|parameter=authority}} &rarr; {{GetHonorMetaData|honor=Camping Skills III|parameter=authority}}
 +
*<nowiki>{{</nowiki>GetHonorMetaData|honor=Camping Skills III|parameter=authority|language=/es}} &rarr; {{GetHonorMetaData|honor=Camping Skills III|parameter=authority|language=/es}}
 
*<nowiki>{{</nowiki>GetHonorMetaData|honor=Animal Tracking|parameter=year}} &rarr; {{GetHonorMetaData|honor=Animal Tracking|parameter=year}}
 
*<nowiki>{{</nowiki>GetHonorMetaData|honor=Animal Tracking|parameter=year}} &rarr; {{GetHonorMetaData|honor=Animal Tracking|parameter=year}}
*<nowiki>{{</nowiki>GetHonorMetaData|honor=Currency|parameter=year|template=User:DesignerThan/Sandbox/LandingPage}} &rarr; {{GetHonorMetaData|honor=Currency|parameter=year|template=User:DesignerThan/Sandbox/LandingPage}}
 
 
*<nowiki>{{</nowiki>GetHonorMetaData|honor=Biblical Language (Hebrew)|parameter=year}} &rarr; {{GetHonorMetaData|honor=Biblical Language (Hebrew)|parameter=year}}
 
*<nowiki>{{</nowiki>GetHonorMetaData|honor=Biblical Language (Hebrew)|parameter=year}} &rarr; {{GetHonorMetaData|honor=Biblical Language (Hebrew)|parameter=year}}
 +
*<nowiki>{{</nowiki>GetHonorMetaData|honor=Animal Tracking|parameter=insignia|dontTranslate=true}} &rarr; {{GetHonorMetaData|honor=Animal Tracking|parameter=insignia|dontTranslate=true}}
 +
 +
{{PrintLocalizationErrors}}
 
</noinclude>
 
</noinclude>

Latest revision as of 18:57, 4 February 2022

This template returns the value of a parameter as defined in a template on a given honor landing page. Unless told otherwise, it will localize the parameter value into the language of the invoking page. If no localization for the parameter value exists, it will return the parameter as it exists in the honor's landing page in the source language.

If the template cannot locate the desired data, it will return an empty string. This can happen if the specified page does not use the specified template, or if the page does not specify the parameter requested.

It takes up to four arguments:

page|honor
You can specify either the page or the honor. If you specify both it will use page. If you specify neither, it will assume you are on an honor page or subpage and treat the first two elements of the invoking page's title as the page. The page argument is the page title of an honor or one of its subpages.
template
Specifies which template holds the parameter you want. If omitted, it defaults to HonorLanding, but if you are experimenting and have some other template in place, you can specify it.
parameter
This specifies which parameter of template you want the template to return. If omitted, it will assume you want the category parameter.
language
This takes a language suffix. The available once can be seen at Template:GetLangSuffix. If non is provided, the template will translate the data to the language of the page it has been invoked off. Don't forget the /

With the new translation system in place, translating the insignia resulted in a error message. Now there is the argument dontTranslate set it to anything you want and the output, doesn't get translated.

Examples

  • {{GetHonorMetaData|page=AY Honors/Cycling/Requirements|parameter=category}} → Recreation
  • {{GetHonorMetaData|page=AY Honors/Cycling/Requirements/es|parameter=skill}} → 1
  • {{GetHonorMetaData|honor=Camping Skills III|parameter=authority}} → General Conference
  • {{GetHonorMetaData|honor=Camping Skills III|parameter=authority|language=/es}} → Asociación General
  • {{GetHonorMetaData|honor=Animal Tracking|parameter=year}} → 1976
  • {{GetHonorMetaData|honor=Biblical Language (Hebrew)|parameter=year}} → 2020
  • {{GetHonorMetaData|honor=Animal Tracking|parameter=insignia|dontTranslate=true}} → Animal Tracking AY Honor.png