Template:Translate/doc: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Sur (talk | contribs)
m NeedsTranslationTooltip instead of NeedsTranslation
Sur (talk | contribs)
m point to Data:Dictionary/sources
 
(8 intermediate revisions by the same user not shown)
Line 4: Line 4:
<pre>
<pre>
"Patch notes": {
"Patch notes": {
"en": "Patch notes",
"en": "Patch notes",
"ru": "Содержание обновления"
"ru": "Содержание обновления"
}
}
</pre>
</pre>
Line 13: Line 13:
<pre>
<pre>
"Patch notes": {
"Patch notes": {
"en": "Patch notes",
"en": "Patch notes",
"ru": "Содержание обновления",
"ru": "Содержание обновления",
"es": "Notas de revision"
"es": "Notas de revision"
}
}
</pre>
</pre>
Line 21: Line 21:


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.
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.
To read the surrounding context, check for the entry on at [[Data:Dictionary/sources]] to see where each key is used.
=Important translations=
<i>Note: these are not yet important, as most translations are only used for in-development pages right now.<br></i>
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.
*
Other:
* '''NeedsTranslationTooltip''' - {{NeedsTranslationTooltip}} is displayed when something can't be localized, so the tooltip being localized is quite helpful for guiding potential translators
* '''MissingValveTranslationTooltip''' - {{MissingValveTranslationTooltip}} is displayed... same reason as above


=When to use=
=When to use=
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
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
=Returned string has weird characters=
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.


=Example=
=Example=
Line 41: Line 57:




If translation to that language does not yet exist, it will default to the english translation, and add <code><nowiki>{{NeedsTranslationTooltip}}</nowiki></code> at the end to guide users to help translate it.
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|zh}}</pre>
<pre style="width: fit-content">{{Translate|Patch notes|made-up-code}}</pre>


Outputs
Outputs


{{Translate|Patch notes|zh}}
{{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=
=Parameters=
Line 63: Line 82:
         "2": {
         "2": {
             "label": "lang_override",
             "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.",
             "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",
             "type": "string",
             "required": false,
             "required": false,

Latest revision as of 03:48, 15 October 2024

How to help translate[edit source]

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

"Patch notes": {
	"en": "Patch notes",
	"ru": "Содержание обновления"
	}

to

"Patch notes": {
	"en": "Patch notes",
	"ru": "Содержание обновления",
	"es": "Notas de revision"
	}


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.

To read the surrounding context, check for the entry on at Data:Dictionary/sources to see where each key is used.

Important translations[edit source]

Note: these are not yet important, as most translations are only used for in-development pages right now.

Page/subpage names that can't exist without translation and whose existence is relied on by other pages:

  • Notes - for [[<ability_name>/Notes]] being transcluded to Abrams#Abilities and [[<ability_name>]]. Notes page can't be created by Deadbot until translated, transcluding the english Notes in its place.

Other:

  • NeedsTranslationTooltip - [nt] is displayed when something can't be localized, so the tooltip being localized is quite helpful for guiding potential translators
  • MissingValveTranslationTooltip - [vt] is displayed... same reason as above

When to use[edit source]

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

Returned string has weird characters[edit source]

If Template:Translate returns a string that has %s in it, it means it is expecting a parameter passed to be embedded in its place. Use Module:Dictionary's translate_embed function instead for this case. The linked page includes documentation for how to use it.

Example[edit source]

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.

{{Translate|Patch notes}}

Outputs

Patch notes


{{Translate|Patch notes|ru}}

Outputs

Содержание обновления


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 {{NeedsTranslationTooltip}} at the end to guide users to help translate it, appearing as [nt].

{{Translate|Patch notes|made-up-code}}

Outputs

Patch notes[nt]

Lua[edit source]

This template simply forwards parameters to the Lua function translate from Module:Dictionary. If familiar with Lua invokes, try using it or translate_embed instead.

Parameters[edit source]

A template to fetch translations for a given key, optionally overriding the language.

Template parameters

ParameterDescriptionTypeStatus
key_to_translate1

The key that corresponds to the text to be translated.

Example
Patch notes
Stringrequired
lang_override2

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]]

Default
Example
es
Stringoptional