Editing
Module
:
Lang/doc
(section)
Give feedback
Jump to navigation
Jump to search
Warning:
You are not logged in. Once you make an edit, a temporary account will be created for you.
Learn more
.
Log in
or
create an account
to continue receiving notifications after this account expires, and to access other features.
Anti-spam check. Do
not
fill this in!
==get_string== Localizes a given string key to the current language, i.e. [[Data:Lang_en.json]] for English. This function also automatically processes game-specific formatting tags (see "Automatic Text Formatting" section below). Note: If you need to get a string that uses a value referenced from another Data page, pass the <code>item_name</code> parameter to <code>get_string</code>. ===Parameters=== * '''key''' - Key string to localize. * '''lang_code_override''' (OPTIONAL) - Overrides the current language to a specific language code. * '''fallback_str''' (OPTIONAL) - Specifies behavior when a key is not found in the target language. ** Passing <code>en</code> causes it to return the English localization. ** Passing any other string causes it to return that string. ** Both of the above options have [[Template:MissingValveTranslationTooltip]] appended. ** Passing <code>dictionary</code> causes it to return a translation via [[Module:Dictionary]] without the tooltip. ** Use this often, as some keys are not yet localized in every language by the game. If parsing the fallback_str from Lua is computationally expensive, consider using the fallback outside this function so it only computes when needed. * '''remove_var_index''' (OPTIONAL) - Removes %variables% from the resulting string. -1 also removes the character prefixing %variables%, while 1 removes the postfixed character, and 0 removes only the %variables%. * '''item_name''' (OPTIONAL) - Required for strings containing <code>{s:variable}</code> placeholders. It will fetch the corresponding property from [[Module:ItemData]] to fill in the variable. NOTE: When calling from wikitext via #invoke, parameters can be named. When calling from another Lua module, parameters must be passed in order (e.g., <code>p.get_string(key, nil, 'en')</code>). ===Internal Logic & Fallbacks=== The function includes several automatic behaviors to handle inconsistencies in the source data: * '''Key Overrides:''' It checks a hardcoded list of overrides for known edge cases. For example, if the key <code>MoveSlowPercent_label</code> is requested, the module will internally use the value for <code>MovementSlow_label</code> to handle this known inconsistency. * '''Post-value Label Fallback:''' If a key ending in <code>_label</code> is not found, it will automatically try again with a key ending in <code>_postvalue_label</code>. * '''String Parsing:''' If a retrieved string contains <code>|</code> or <code>#</code>, the function will automatically use only the text that comes after the final instance of that character. ===Examples=== Invokes from wikitext:<br> <code><nowiki>{{#invoke:Lang|get_string|CitadelHeroStats_Weapon_Falloff}}</nowiki></code> {{#invoke:Lang|get_string|CitadelHeroStats_Weapon_Falloff}} <code><nowiki>{{#invoke:Lang|get_string|CitadelHeroStats_Weapon_Falloff|lang_code_override=es}}</nowiki></code> {{#invoke:Lang|get_string|CitadelHeroStats_Weapon_Falloff|lang_code_override=es}} ====Strings with Variables==== For strings containing <code>{s:variable}</code>, provide the <code>item_name</code>: '''Example:''' <code><nowiki>{{#invoke:Lang|get_string|upgrade_target_stun_desc|item_name=Knockdown}}</nowiki></code> β {{#invoke:Lang|get_string|upgrade_target_stun_desc|item_name=Knockdown}} Without <code>item_name</code>, variables won't be filled: <code><nowiki>{{#invoke:Lang|get_string|upgrade_target_stun_desc}}</nowiki></code> β {{#invoke:Lang|get_string|upgrade_target_stun_desc}} ===Examples for fallback_str=== <code><nowiki>{{#invoke:Lang|get_string|StatDesc_CritDamageBonusScale|lang_code_override=es}}</nowiki></code> {{#invoke:Lang|get_string|StatDesc_CritDamageBonusScale|lang_code_override=es}} <code><nowiki>{{#invoke:Lang|get_string|StatDesc_CritDamageBonusScale|lang_code_override=es|fallback_str=en}}</nowiki></code> {{#invoke:Lang|get_string|StatDesc_CritDamageBonusScale|lang_code_override=es|fallback_str=en}} <code><nowiki>{{#invoke:Lang|get_string|StatDesc_CritDamageBonusScale|lang_code_override=es|fallback_str=Crit Damage Bonus Scale}}</nowiki></code> {{#invoke:Lang|get_string|StatDesc_CritDamageBonusScale|lang_code_override=es|fallback_str=Crit Damage Bonus Scale}} <code><nowiki>{{#invoke:Lang|get_string|Tech Items|fallback_str=dictionary}}</nowiki></code> {{#invoke:Lang|get_string|Tech Items|fallback_str=dictionary}} ===Examples for remove_var_index=== <code><nowiki>{{#invoke:Lang|get_string|Citadel_HeroBuilds_DefaultHeroBuild}}</nowiki></code> {{#invoke:Lang|get_string|Citadel_HeroBuilds_DefaultHeroBuild}} <i>TODO: Debug why is =0 still removing that extra space? Doesn't matter yet I suppose, no use cases for 0 yet</i> <code><nowiki>{{#invoke:Lang|get_string|Citadel_HeroBuilds_DefaultHeroBuild|remove_var_index=0}}</nowiki></code> {{#invoke:Lang|get_string|Citadel_HeroBuilds_DefaultHeroBuild|remove_var_index=0}} <code><nowiki>{{#invoke:Lang|get_string|Citadel_HeroBuilds_DefaultHeroBuild|remove_var_index=-1}}</nowiki></code> {{#invoke:Lang|get_string|Citadel_HeroBuilds_DefaultHeroBuild|remove_var_index=-1}}
Summary:
Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Deadlock:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Navigation menu
Personal tools
Create account
Log in
associated-pages
Module
Discussion
English
Views
Read
Edit source
History
Tools
Search
Discord
Discord
Navigation
Main page
About us
Random page
Special pages
Recent changes
Venator
7m ago
Β·
Sleuth
Graves/Lore
10m ago
Β·
Dinjoralo
Weapon Damage
33m ago
Β·
Acurrz
Items
2h ago
Β·
Gammaton32
Show more...
Interface Admin
Common CSS
Vector CSS
Minerva CSS
Citizen CSS
Brown theme CSS
Gadgets
Gadgets definition
Editing
How to edit
Style guide
All guides
New files
Unresolved feedback
Tools
What links here
Related changes
Page information