Template:Translate/doc: Difference between revisions

From The Deadlock Wiki
Jump to navigation Jump to search
Sur (talk | contribs)
mNo edit summary
rewrite documentation for clarity
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=How to help translate=
= Overview =
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
Navigate to [[Data:Dictionary]] to add or update keys, or create a new key if one does not already exist.


<pre>
For additional context about where a key is used, see [[Data:Dictionary/sources]].
"Patch notes": {
"en": "Patch notes",
"ru": "Содержание обновления"
}
</pre>


to
== Tooltip notes ==
* '''{{tl|NeedsTranslationTooltip}}''' {{NeedsTranslationTooltip}} - displayed when the key is not translated.
* '''{{tl|MissingValveTranslationTooltip}}''' {{MissingValveTranslationTooltip}} (manual) - displayed in cases where an official translation is expected but unavailable.


<pre>
== Usage ==
"Patch notes": {
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.
"en": "Patch notes",
"ru": "Содержание обновления",
"es": "Notas de revision"
}
</pre>


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.


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.
See also: [[Module:Dictionary]].


=Example=
=== Examples ===
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>


Outputs
<code><nowiki>{{Translate|Patch notes}}</nowiki></code> Output: {{Translate|Patch notes}}


{{Translate|Patch notes}}
<code><nowiki>{{Translate|Patch notes|lang_code=ru}}</nowiki></code> Output: {{Translate|Patch notes|lang_code=ru}}


 
<templatedata>
<pre style="width: fit-content">{{Translate|Patch notes|ru}}</pre>
{
 
"description": " ",
Outputs
"params": {
 
"1": {
{{Translate|Patch notes|ru}}
"label": "Dictionary key",
 
"description": "The key that corresponds to the text to be translated.",
 
"type": "string",
If translation to that language does not yet exist, it will default to the english translation, and add <code><nowiki>{{NeedsTranslation}}</nowiki></code> at the end.
"required": true,
 
"example": "Patch notes"
<pre style="width: fit-content">{{Translate|Patch notes|zh}}</pre>
},
 
"lang_code": {
Outputs
"label": "Language code",
 
"description": "Optional language code to override the language. See Data:LangCodes.json.",
{{Translate|Patch notes|zh}}
"example": "es, cs, pt-br",
 
"type": "string"
=Parameters=
}
 
},
<templatedata>{
"paramOrder": [
    "description": "A template to fetch translations for a given key, optionally overriding the language.",
"1",
    "params": {
"lang_code"
        "1": {
],
            "label": "key_to_translate",
"format": "inline"
            "description": "The key that corresponds to the text to be translated.",
            "type": "string",
            "required": true,
            "example": "Patch notes"
        },
        "2": {
            "label": "lang_override",
            "description": "Optional two-letter language code to override the language (e.g., 'en', 'es'), if page ends in /<lang_code> it defaults to that lang code.",
            "type": "string",
            "required": false,
            "example": "es",
            "default": ""
        }
    }
}</templatedata>
}</templatedata>
<includeonly>[[Category:Language templates]]</includeonly><noinclude>[[Category:Template documentation]]</noinclude>

Latest revision as of 20:45, 6 June 2026

Overview

[edit source]

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.

Tooltip notes

[edit source]
  • {{NeedsTranslationTooltip}} [nt] - displayed when the key is not translated.
  • {{MissingValveTranslationTooltip}} [vt] (manual) - displayed in cases where an official translation is expected but unavailable.

Use this template to translate reusable text strings and interface text that appear in templates, such as {{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.

See also: Module:Dictionary.

Examples

[edit source]

{{Translate|Patch notes}} Output: Patch notes

{{Translate|Patch notes|lang_code=ru}} Output: Содержание обновления

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Dictionary key1

The key that corresponds to the text to be translated.

Example
Patch notes
Stringrequired
Language codelang_code

Optional language code to override the language. See Data:LangCodes.json.

Example
es, cs, pt-br
Stringoptional