Module:Dictionary/doc: Difference between revisions
m →Important translations: phrasing |
m now includes show_needs_translation and better examples |
||
Line 9: | Line 9: | ||
*'''key''' - key to translate | *'''key''' - key to translate | ||
*'''lang_code_override''' (OPTIONAL, Named parameter) - language code that overrides current language. See supported list at [[Data:LangCodes.json]]. | *'''lang_code_override''' (OPTIONAL, Named parameter) - language code that overrides current language. See supported list at [[Data:LangCodes.json]]. | ||
*'''show_needs_translation''' (OPTIONAL, Named parameter) - boolean that determines if the {{NeedsTranslationTooltip}} is appended when its unable to be translated. Defaults to 'true' | |||
===Example=== | ===Example=== | ||
Example where translation does exist<br> | |||
<code><nowiki>{{#invoke:Dictionary|translate|Update history|lang_code_override=en}}</nowiki></code> | |||
Outputs | |||
{{#invoke:Dictionary|translate|Update history|lang_code_override=en}} | |||
Example where translation does not yet exist<br> | |||
<code><nowiki>{{#invoke:Dictionary|translate|Update history|lang_code_override=es}}</nowiki></code> | <code><nowiki>{{#invoke:Dictionary|translate|Update history|lang_code_override=es}}</nowiki></code> | ||
Line 16: | Line 26: | ||
{{#invoke:Dictionary|translate|Update history|lang_code_override=es}} | {{#invoke:Dictionary|translate|Update history|lang_code_override=es}} | ||
Example where translation does not yet exist but displaying the tooltip is off<br> | |||
<code><nowiki>{{#invoke:Dictionary|translate|Update history|show_needs_translation=false}}</nowiki></code> | |||
Outputs | |||
{{#invoke:Dictionary|translate|Update history|show_needs_translation=false}} | |||
==translate_embed== | ==translate_embed== |
Revision as of 03:23, 13 October 2024
Overview
See Template:Translate for how/when to use and more documentation.
Functions
translate
Translates a given key using Data:Dictionary.
Parameters
- key - key to translate
- lang_code_override (OPTIONAL, Named parameter) - language code that overrides current language. See supported list at Data:LangCodes.json.
- show_needs_translation (OPTIONAL, Named parameter) - boolean that determines if the [nt] is appended when its unable to be translated. Defaults to 'true'
Example
Example where translation does exist
{{#invoke:Dictionary|translate|Update history|lang_code_override=en}}
Outputs
Update history
Example where translation does not yet exist
{{#invoke:Dictionary|translate|Update history|lang_code_override=es}}
Outputs
Update history[nt]
Example where translation does not yet exist but displaying the tooltip is off
{{#invoke:Dictionary|translate|Update history|show_needs_translation=false}}
Outputs
Update history
translate_embed
Translates a given key then replaces %s in the string with extra parameters
Parameters
- key - key to translate
- var1 - first variable to embed in the string
- var2 - second
- varN - Nth
Ensure the number of variables passed matches the number of instances of %s
in the translated string.
Examples
Without embedment:
{{#invoke:Dictionary|translate|TranscludedNotesFrom}}
Outputs
Key 'TranscludedNotesFrom' is not in Data:Dictionary
With embedment:
{{#invoke:Dictionary|translate_embed |1=TranscludedNotesFrom |2=https://en.wikipedia.org/wiki/Help:Transclusion |3=[[Source_Page/notes]] |4=https://deadlocked.wiki/index.php?title=Source_Page/notes&action=edit }}
Outputs
Key 'TranscludedNotesFrom' is not in Data:Dictionary
Notes
- The parameters do not need to be prefixed with "1=", "2=", etc., they are used in the above example because the 4th parameter contains an equal sign (
=
) in it, where it would be read as a named parameter rather than a ordinal parameter. - Ensure the number of passed variables (other than the key) matches the number of %s used in the translated string.
Important translations
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
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