Variable strings in localization
Last updated
Last updated
The game settings provide the ability to configure the order button and assign hotkeys for in-game actions. This requires identifying the corresponding keys in the localization files. For this, variable strings are used.
<&mouse_action_key>
By default, right-click button orders are used. In the Options window, players can enable left-click button orders by selecting the "LMB orders" checkbox.
<&optkey:anyAction>
When displaying localization texts, the value corresponding to the user's settings recorded in the keys.opt
file will be substituted instead of <&optkey:anyAction>
.
<&key:keycode>
Used to specify a specific keyboard key.
To specify keys, you need to use values from the keycode
list.
<&hotbar_key:anyAction>
Working Algorithm:
If the specified action is on the Hotbar, the game will display the corresponding hotbar key value in the text instead of the variable string.
If the specified action is not on the Hotbar, the action hotkey value will be displayed if set.
Otherwise, an empty value []
will be displayed.
Fragment of a .lng file using variable strings:
{"02" "To build a breastwork, select your riflemen and press <&hotbar_key:barricade>
. Then select a starting spot for the breastwork and press <&mouse_action_key>
. Drag the mouse cursor to set the length for the fortification. Press <&mouse_action_key>
again to order the breastwork to be built."
Explanation of variables
<&hotbar_key:barricade>
This variable will be replaced by the key assigned to the barricade
action in the hotbar. If the barricade
action is assigned to a key, that key will be displayed. If not, it will display the hotkey for the action if set, or an empty value []
if neither is set.
<&mouse_action_key>
This variable will be replaced by the mouse button configured for order issuance in the options window. By default, it is the right mouse button (RMB). If the "LMB orders" option is checked, it will be replaced by the left mouse button (LMB).
Example user settings
Assume the barricade
action is assigned to the key F1
in the hotbar.
Assume the mouse order button is set to the right mouse button (RMB).
Resulting In-Game Text
With these settings, the variables will be substituted as follows:
<&hotbar_key:barricade>
becomes F1
.
<&mouse_action_key>
becomes RMB
.
Thus, the text displayed in the game will be:
To build a breastwork, select your riflemen and press
F1
. Then select a starting spot for the breastwork and pressRMB
. Drag the mouse cursor to set the length for the fortification. PressRMB
again to order the breastwork to be built.
By understanding how the variables are substituted with actual key values set by the user, we can see how the text dynamically adapts to the player's configuration, ensuring that the instructions are always accurate and relevant to the current settings.
keys.opt
Configuration of in-game actions to hotkeys
scene\hud2\action.set
File with descriptions of in-game actions
interface\text#ingame+.lng
Localization file for in-game actions
*.lng