Language files allow you to add your own lines of text in system languages and replace existing ones. It is forbidden to use text in hacks directly without language files.
Creating language files
Language files are created and edited on the "Language files" page by "Files" button in hack settings. Their names correspond to language codes - ru.php
for Russian and en.php
for English.
The language file must return an associative array of strings. The array key is the string identifier, the value is its composition in the selected language. It is recommended to start the keys with the name of the hack.
Language file example:
<?php return [ 'proxy_config_h' => 'Proxy configuration', 'proxy_config_t' => 'In this section, you can set up the configuration.', ];
Using in the code
To access a string by its ID, use the lang
array of the $core
object. This array is collected by concatenating all language files.
$core->lang['proxy_config_h']
Language file cache
With automatic updates and activation of hacks, the language cache is cleared automatically. If you're developing the hack yourself, you'll need to manually clear the cache when changing the language file.
Go to the "Management - Settings" section, click on the "Diagnostics" button. In the "Cache" section, find "Compiled Language Files" and click "Clear".