Jump to content

Module:Dictionary

From Deadlock Wiki
Revision as of 11:21, 26 January 2025 by 149.28.42.29 (talk) (Blanked the page)

Overview

See Template:Translate for how/when to use and more documentation. See Data:Dictionary/sources for list of where each translation is used. This may be particularly helpful for reading on the context of the phrase that needs translation.

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.
  • fallback_str (OPTIONAL, Named parameter) - string to return if key cannot be translated. Defaults to the english translation. Use a blank string or nil for easier catching of missed translations, where the needs translation tooltip will also not be added.
  • show_needs_translation (OPTIONAL, Named parameter) - boolean that determines if the <span class="tooltip" title="Script error: The module returned a nil value. It is supposed to return an export table.">[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

Script error: The module returned a nil value. It is supposed to return an export table.


Example where translation does not yet exist
{{#invoke:Dictionary|translate|Update history|lang_code_override=es}}

Outputs

Script error: The module returned a nil value. It is supposed to return an export table.


Example where translation does not yet exist but displaying the tooltip is off
{{#invoke:Dictionary|translate|Update history|lang_code_override=es|show_needs_translation=false}}

Outputs

Script error: The module returned a nil value. It is supposed to return an export table.

Example where translation does not yet exist and the fallback is an empty string
{{#invoke:Dictionary|translate|Update history|lang_code_override=es|fallback_str=}}

Outputs

Script error: The module returned a nil value. It is supposed to return an export table.


Example where translation does not yet exist and the fallback is another text
{{#invoke:Dictionary|translate|Update history|lang_code_override=es|fallback_str=My custom fallback text}}

Outputs

Script error: The module returned a nil value. It is supposed to return an export table.

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|NeedsTranslationTooltip}}

Outputs

Script error: The module returned a nil value. It is supposed to return an export table.

With embedment:

{{#invoke:Dictionary|translate_embed
|1=NeedsTranslationTooltip
|2=Template:Translate
}}

Outputs

Script error: The module returned a nil value. It is supposed to return an export table.

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.