use Bitrix\Main\Localization\Loc; $hello = Loc::getMessage('HELLO_MESSAGE', [], 'en'); echo $hello; // output: "Hello, World!"
use Bitrix\Main\Localization\Loc; $likes = 3; // number of likes $likesText = Loc::getMessage( 'LIKES_MESSAGE', // ID of translation message ['#LIKES#' => $likes], // placeholders Loc::getCurrentLang() // current language locale ); echo $likesText; // output: "3 likes" (English), "3 gusta" (Spanish), etc.In this example, the `Loc::getMessage()` method is used to retrieve a pluralized string with the message code `LIKES_MESSAGE`. The second parameter is an array of placeholders, with `#LIKES#` being replaced by the number of likes. The `Loc::getCurrentLang()` method is used to get the current language locale. Overall, PHP bitrix.main.localization is a useful package library for Bitrix CMS developers who need to build multilingual websites and need simple and convenient tools to handle localization.