Editing Template:Translate/doc

Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
= Overview =
''Note: [[Template:NeedsTranslationTooltip]] directs to this page.''
Navigate to [[Data:Dictionary]] to add or update keys, or create a new key if one does not already exist.


For additional context about where a key is used, see [[Data:Dictionary/sources]].
=How to help translate=
Navigate to [[Data:Dictionary]] and add the translations for a specific key there. For example, to translate  'Patch notes' to spanish (es), edit the record in the Dictionary from


== Tooltip notes ==
<pre>
* '''{{tl|NeedsTranslationTooltip}}''' {{NeedsTranslationTooltip}} - displayed when the key is not translated.
"Patch notes": {
* '''{{tl|MissingValveTranslationTooltip}}''' {{MissingValveTranslationTooltip}} (manual) - displayed in cases where an official translation is expected but unavailable.
"en": "Patch notes",
"ru": "Содержание обновления"
}
</pre>


== Usage ==
to
Use this template to translate reusable text strings and interface text that appear in templates, such as {{tl|Update layout}}. Page-specific content should be translated on the corresponding language subpage.


If a translation is unavailable, the template falls back to the english translation and displays the missing translation tooltip. An optional parameter allows the language to be overridden.
<pre>
"Patch notes": {
"en": "Patch notes",
"ru": "Содержание обновления",
"es": "Notas de revision"
}
</pre>


See also: [[Module:Dictionary]].


=== Examples ===
Similarly, if translating a new key not yet added, simply add the record that looks like the above at the bottom of the page, but be sure the last curly brace } has a comma afterwards.


<code><nowiki>{{Translate|Patch notes}}</nowiki></code> Output: {{Translate|Patch notes}}
To read the surrounding context, check for the entry on at [[Data:Dictionary/sources]] to see where each key is used.


<code><nowiki>{{Translate|Patch notes|lang_code=ru}}</nowiki></code> Output: {{Translate|Patch notes|lang_code=ru}}
=Important translations=
<i>Note: these are not yet important, as most translations are only used for in-development pages right now.<br></i>


<templatedata>
Page/subpage names that can't exist without translation and whose existence is relied on by other pages:
{
* '''Notes''' - for <code><nowiki>[[<ability_name>/Notes]]</nowiki></code> being transcluded to [[Abrams#Abilities]] and <nowiki>[[<ability_name>]]</nowiki>. Notes page can't be created by Deadbot until translated, transcluding the english Notes in its place.
"description": " ",
*
"params": {
 
"1": {
Other:
"label": "Dictionary key",
* '''NeedsTranslationTooltip''' - {{NeedsTranslationTooltip}} is displayed when something can't be localized, so the tooltip being localized is quite helpful for guiding potential translators
"description": "The key that corresponds to the text to be translated.",
* '''MissingValveTranslationTooltip''' - {{MissingValveTranslationTooltip}} is displayed... same reason as above
"type": "string",
 
"required": true,
=When to use=
"example": "Patch notes"
This should only be used to translate text written in Templates, such as [[Template:Update layout]] which outputs "Patch notes" above the UI element. Page specific content should be translated on that page in that language, i.e. /Abrams/es or /Abrams/en
},
 
"lang_code": {
=Returned string has weird characters=
"label": "Language code",
If [[Template:Translate]] returns a string that has <code>%s</code> in it, it means it is expecting a parameter passed to be embedded in its place. Use [[Module:Dictionary]]'s <code>translate_embed</code> function instead for this case. The linked page includes documentation for how to use it.
"description": "Optional language code to override the language. See Data:LangCodes.json.",
 
"example": "es, cs, pt-br",
=Example=
"type": "string"
Without providing lang_override, the language will be detected based on the subpage the user is on, i.e. /Abrams/es will be detected as a spanish page.
}
<pre style="width: fit-content">{{Translate|Patch notes}}</pre>
},
 
"paramOrder": [
Outputs
"1",
 
"lang_code"
{{Translate|Patch notes}}
],
 
"format": "inline"
 
<pre style="width: fit-content">{{Translate|Patch notes|ru}}</pre>
 
Outputs
 
{{Translate|Patch notes|ru}}
 
 
If translation to that language does not yet exist, it will default to the english translation. If the english translation also does not exist, it will default to the provided key. In both cases, it will add <code><nowiki>{{NeedsTranslationTooltip}}</nowiki></code> at the end to guide users to help translate it, appearing as {{NeedsTranslationTooltip}}.
 
<pre style="width: fit-content">{{Translate|Patch notes|made-up-code}}</pre>
 
Outputs
 
{{Translate|Patch notes|made-up-code}}
 
=Lua=
This template simply forwards parameters to the Lua function <code>translate</code> from [[Module:Dictionary]]. If familiar with Lua invokes, try using it or <code>translate_embed</code> instead.
 
=Parameters=
 
<templatedata>{
    "description": "A template to fetch translations for a given key, optionally overriding the language.",
    "params": {
        "1": {
            "label": "key_to_translate",
            "description": "The key that corresponds to the text to be translated.",
            "type": "string",
            "required": true,
            "example": "Patch notes"
        },
        "2": {
            "label": "lang_override",
            "description": "Optional language code to override the language (e.g., 'en', 'es'), if page ends in /<lang_code> it defaults to that lang code. See accepted language codes at [[Data:LangCodes.json]]",
            "type": "string",
            "required": false,
            "example": "es",
            "default": ""
        }
    }
}</templatedata>
}</templatedata>
<includeonly>[[Category:Language templates]]</includeonly><noinclude>[[Category:Template documentation]]</noinclude>
Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Deadlock:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template