Source
* Translates the string with respect to the given context and plural forms, also replaces placeholders with supplied
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* In case gettext functions do not exist, just replacing them with our own,
* so user can see at least English translation.
*/
if (!function_exists('_')) {
/**
* Stub gettext function in case gettext is not available.
*
* @param string $string
*
* @return string
*/
function _($string) {
return $string;
}
}
if (!function_exists('ngettext')) {
/**
* Stub gettext function in case gettext is not available. Do not use directly, use _n() instead.
*
* @see _n
*
* @param string $string1
* @param string $string2
* @param string $n
*
* @return string
*/
function ngettext($string1, $string2, $n) {
return ($n == 1) ? $string1 : $string2;
}
}
/**
* Translates the string with respect to the given context.
*
* @see _x
*
* @param string $context
* @param string $msgId
*
* @return string
*/
function pgettext($context, $msgId) {
$contextString = $context."\004".$msgId;
$translation = _($contextString);