Template:String: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
<includeonly><onlyinclude>{{#switch: {{{input|}}}
| {{{id|}}} = {{{{{{{{{force|{{intlang}}}}}>}}}|{{{{{{force|{{intlang}}}}}|{{{{{{default|}}}|{{{en|}}}}}}}}}}}}
| + = +{{{{{{force|{{intlang}}}}}+|}}}
| all = +{{{{{{default|}}}|{{{en|}}}}}}
}}</onlyinclude></includeonly>
{{Warning|Designed for the new page format. Please do not use or edit this template yet.}}
{{Warning|Designed for the new page format. Please do not use or edit this template yet.}}




Alternative version of {{Tl|autolang}} template.
Alternative version of {{Tl|autolang}} template.  
{{Important|If your default text is not displayed, try adding {{Code|1=1=}} at the beginning of parameter.}}


{{CodeBlock|src=Example|lines=14|<nowiki>{{String
| id = Hello // Id of this string. If the input parameter is equal to id, the string will be displayed.
| input = {{{1|}}} // Input value. You can count the lines by entering "all" in this parameter or count their translations by entering "+".
| force = {{{force|{{intlang}}}}} // Causes a string to be loaded in a specific language (if it is translated into it).
| default = es // Allows you to specify which translation is the main one. It will also be taken into account in calculating the total number of strings. By default it is equal to "en"


Common use of the template:
| en+ = 1 // A special parameter that adds translation to the total count of translated strings.
| en = Hello, User! // String in this language.


{{Code|<nowiki>{{String|Default Text|ru=Russian Text|it=Italian Text}}</nowiki>}} → {{String|Default Text|ru=Russian Text|it=Italian Text}}
| ru+ = 1
| eo = Saluton, Uzanto!


 
| es+ = 1
Default text is empty (in a language that is not specified there will be an empty line):
| es> = eo // A language code with a ">" at the end means that the language refers to another language. This allows to avoid repeating the same text if it is completely identical in two or more languages
 
}}</nowiki>}}
{{Code|<nowiki>{{String|en=English Text|it=Italian Text}}</nowiki>}} → {{String|en=English Text|it=Italian Text}}
 
 
The {{Param|force}} parameter forces the template to intentionally load the selected language (useful for testing):
 
{{Code|<nowiki>{{String|Default Text|force=ru|es=Spanish Text|ru=Russian Text|it=Italian Text}}</nowiki>}} → {{String|Default Text|force=ru|es=Spanish Text|ru=Russian Text|it=Italian Text}}
{{Note|To force Default text to be displayed, use {{Code|1=force=1}}}}
 
 
By using a hyphen before the language code, it can be linked to any other language (even to default text):
 
{{Code|<nowiki>{{String|Default Text|-en=it|it=Some Text}}</nowiki>}} → {{String|Default Text|-en=it|it=Some Text}}
{{Note|To link a language (for example Spanish) to the default text, use {{Code|1=-es=1}}}}
 
 
<includeonly><onlyinclude>{{{{{{-{{{force|{{intlang}}}}}}}}|{{{{{{force|{{intlang}}}}}|{{{1|}}}}}}}}}</onlyinclude></includeonly>

Revision as of 04:18, 22 April 2024

Warning.pngWarning:Designed for the new page format. Please do not use or edit this template yet.


Alternative version of {{autolang}} template.

Example
  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
{{String | id = Hello // Id of this string. If the input parameter is equal to id, the string will be displayed. | input = {{{1|}}} // Input value. You can count the lines by entering "all" in this parameter or count their translations by entering "+". | force = {{{force|{{intlang}}}}} // Causes a string to be loaded in a specific language (if it is translated into it). | default = es // Allows you to specify which translation is the main one. It will also be taken into account in calculating the total number of strings. By default it is equal to "en" | en+ = 1 // A special parameter that adds translation to the total count of translated strings. | en = Hello, User! // String in this language. | ru+ = 1 | eo = Saluton, Uzanto! | es+ = 1 | es> = eo // A language code with a ">" at the end means that the language refers to another language. This allows to avoid repeating the same text if it is completely identical in two or more languages }}