Template:String: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Warning|Designed for the new page format. Please do not use or edit this template yet.}}
{{Tdeprecated|notes = Use #switch parser function instead. Example
<pre>
{{#switch: {{language}}
| #default = English
| ja = 日本語
| zh-tw = 中文(台灣)‎
}}
</pre>
If you are looking for creating the strings subpage, see [[Template:Strings subpage]] instead.
}}


<includeonly><onlyinclude>{{{{{{>{{{force|{{Pagelang}}}}}}}}|{{{{{{force|{{Pagelang}}}}}|{{{en|}}}}}}}}}</onlyinclude></includeonly>
Alternative version of {{T|Autolang}} template.


Alternative version of {{Tl|autolang}} template.
{{CodeBlock|src=Example|lines=10|<nowiki>{{String
{{Important|If your default text is not displayed, try adding {{Code|1=1=}} at the beginning of parameter.}}
| force = ru // Causes a string to be loaded in a specific language (if it is translated into it). This parameter is mainly for testing purposes.


 
| en = Hello, User! // English String. Even if {{{default}}} is specified, if there is no translation in that language, English will be used.
Common use of the template:
| eo = Saluton, Uzanto! // Spanish String.
 
| ru = Здравствуй, пользователь! // Russian String.
{{Code|<nowiki>{{String|Default Text|ru=Russian Text|it=Italian Text}}</nowiki>}} → {{String|Default Text|ru=Russian Text|it=Italian Text}}
|>es = eo // A language code with a ">" at the begining 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
 
|>el = eo // If you referring one language to another, link to that translation, do not link to another link. In this example, writing >el = es (or >el = >es) will be incorrect.
 
}}</nowiki>}}
Default text is empty (in a language that is not specified there will be an empty line):
 
{{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>

Latest revision as of 10:27, 24 January 2025

Red x.png
This template (and its redirect) is Wikipedia icon Deprecated. Its use is not recommended and its functionality may be compromised.
You can help our editors by replacing or deleting this template on the Pages that use this template. Once no more pages use this template, it should be Marked for deletion.

Additional notes:
Use #switch parser function instead. Example
{{#switch: {{language}}
| #default = English
| ja = 日本語
| zh-tw = 中文(台灣)‎
}}
If you are looking for creating the strings subpage, see Template:Strings subpage instead.


Alternative version of {{Autolang}} template.

Example
  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
{{String | force = ru // Causes a string to be loaded in a specific language (if it is translated into it). This parameter is mainly for testing purposes. | en = Hello, User! // English String. Even if {{{default}}} is specified, if there is no translation in that language, English will be used. | eo = Saluton, Uzanto! // Spanish String. | ru = Здравствуй, пользователь! // Russian String. |>es = eo // A language code with a ">" at the begining 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 |>el = eo // If you referring one language to another, link to that translation, do not link to another link. In this example, writing >el = es (or >el = >es) will be incorrect. }}