Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/main/lib/localization/ |
Upload File : |
<?php namespace Bitrix\Main\Localization; use Bitrix\Main\Diag; use Bitrix\Main\IO\Path; /** * This class is used to defer the localization of a phrase until it is actually needed. * It allows you to get the localized text in any language at any point before the end of the hit. * * This class should only be instantiated when the message is actually going to be displayed. * Otherwise, unnecessary load may be created in the constructor method. * * @see Loc::getMessage() */ class LocalizableMessage implements LocalizableMessageInterface { public function __construct( protected string $code, protected ?array $replace = null, protected ?string $language = null, /** @var string Path to the file that owns the phrase */ protected ?string $phraseSrcFile = null, ) { if (!isset($this->phraseSrcFile)) { // guess the file that owns the phrase $trace = Diag\Helper::getBackTrace(1, DEBUG_BACKTRACE_IGNORE_ARGS); $this->phraseSrcFile = Path::normalize($trace[0]['file']); } } public function localize(string $language): ?string { $message = Loc::getMessage($this->code, $this->replace, $language); if (!isset($message)) { Loc::loadLanguageFile($this->phraseSrcFile, $language, false); $message = Loc::getMessage($this->code, $this->replace, $language); } return $message; } public function __toString() { return $this->localize($this->language ?? Loc::getCurrentLang()); } }