Module:Dictionary/doc: Difference between revisionsGive feedback
Jump to navigation
Jump to search
m →Examples: example updated for embedment |
New version. |
||
| Line 1: | Line 1: | ||
=Overview= | = Overview = | ||
See | See {{tl|Translate}} for how/when to use and more documentation. | ||
== p.translate == | |||
==translate== | Translates a given key from [[Data:Dictionary]]. '''Manual invocation should only be used for special cases''', such as {{tl|Update link}}. For normal usage, use the basic template. | ||
Translates a given key | |||
=== | === Function parameters === | ||
*'''key''' - | * '''key''' – translation key (required). | ||
*'''lang_code_override''' ( | * Language-specific: | ||
*'''fallback_str''' ( | ** '''lang_code_override''' (optional, named parameter) – language code overriding the automatic detection. See [[Data:LangCodes.json]]. | ||
** '''fallback_str''' (optional, named parameter) – value returned '''only if translation is missing'''. If set to empty string or nil, fallback will be empty (useful for detecting missing translations). | |||
=== | === Examples === | ||
<code><nowiki>{{#invoke:Dictionary|translate|Update history}}</nowiki></code> Output: {{#invoke:Dictionary|translate|Update history}} | |||
<code><nowiki>{{#invoke:Dictionary|translate|Update history | |||
<code><nowiki>{{#invoke:Dictionary|translate|Updates|lang_code_override=pt-br}}</nowiki></code> Output: {{#invoke:Dictionary|translate|Updates|lang_code_override=pt-br}} | |||
<code><nowiki>{{#invoke:Dictionary|translate|Update history|fallback_str=Custom fallback text.}}</nowiki></code> Output: {{#invoke:Dictionary|translate|Updates|lang_code_override=xx<!-- invalid language code to force fallback. -->|fallback_str=Custom fallback text.}} | |||
<includeonly>[[Category:Modules]]</includeonly><noinclude>[[Category:Module documentation]]</noinclude> | |||
<code><nowiki>{{#invoke:Dictionary|translate|Update history| | |||
< | |||
Revision as of 02:57, 6 June 2026
Overview
See {{Translate}} for how/when to use and more documentation.
p.translate
Translates a given key from Data:Dictionary. Manual invocation should only be used for special cases, such as {{Update link}}. For normal usage, use the basic template.
Function parameters
- key – translation key (required).
- Language-specific:
- lang_code_override (optional, named parameter) – language code overriding the automatic detection. See Data:LangCodes.json.
- fallback_str (optional, named parameter) – value returned only if translation is missing. If set to empty string or nil, fallback will be empty (useful for detecting missing translations).
Examples
{{#invoke:Dictionary|translate|Update history}} Output: Update history
{{#invoke:Dictionary|translate|Updates|lang_code_override=pt-br}} Output: Atualizações
{{#invoke:Dictionary|translate|Update history|fallback_str=Custom fallback text.}} Output: Custom fallback text.[nt]