2013-06-07 11:44:37 +02:00
|
|
|
<?php
|
2016-02-08 15:41:00 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */
|
2013-06-07 11:44:37 +02:00
|
|
|
|
2021-05-20 09:28:12 +02:00
|
|
|
use ipl\Stdlib\Contract\Translator;
|
|
|
|
use ipl\I18n\StaticTranslator;
|
2014-01-29 16:25:08 +01:00
|
|
|
|
2015-09-16 14:16:40 +02:00
|
|
|
/**
|
|
|
|
* No-op translate
|
|
|
|
*
|
|
|
|
* Supposed to be used for marking a string as available for translation without actually translating it immediately.
|
|
|
|
* The returned string is the one given in the input. This does only work with the standard gettext macros t() and mt().
|
|
|
|
*
|
|
|
|
* @param string $messageId
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function N_($messageId)
|
|
|
|
{
|
|
|
|
return $messageId;
|
|
|
|
}
|
|
|
|
|
2016-02-25 18:07:29 +01:00
|
|
|
// Workaround for test issues, this is required unless our tests are able to
|
|
|
|
// accomplish "real" bootstrapping
|
|
|
|
if (function_exists('t')) {
|
|
|
|
return;
|
|
|
|
}
|
2015-09-16 14:16:40 +02:00
|
|
|
|
2014-01-29 16:25:08 +01:00
|
|
|
if (extension_loaded('gettext')) {
|
2014-09-16 15:19:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see Translator::translate() For the function documentation.
|
|
|
|
*/
|
|
|
|
function t($messageId, $context = null)
|
2013-06-07 11:44:37 +02:00
|
|
|
{
|
2021-05-20 09:28:12 +02:00
|
|
|
return StaticTranslator::$instance->translate($messageId, $context);
|
2013-06-07 11:44:37 +02:00
|
|
|
}
|
|
|
|
|
2014-09-16 15:19:23 +02:00
|
|
|
/**
|
2021-05-20 09:28:12 +02:00
|
|
|
* @see Translator::translateInDomain() For the function documentation.
|
2014-09-16 15:19:23 +02:00
|
|
|
*/
|
|
|
|
function mt($domain, $messageId, $context = null)
|
2013-06-07 11:44:37 +02:00
|
|
|
{
|
2021-05-20 09:28:12 +02:00
|
|
|
return StaticTranslator::$instance->translateInDomain($domain, $messageId, $context);
|
2013-06-07 11:44:37 +02:00
|
|
|
}
|
2014-09-15 14:11:42 +02:00
|
|
|
|
2014-09-16 15:19:23 +02:00
|
|
|
/**
|
|
|
|
* @see Translator::translatePlural() For the function documentation.
|
|
|
|
*/
|
|
|
|
function tp($messageId, $messageId2, $number, $context = null)
|
2014-09-15 14:11:42 +02:00
|
|
|
{
|
2021-05-20 09:28:12 +02:00
|
|
|
return StaticTranslator::$instance->translatePlural($messageId, $messageId2, $number, $context);
|
2014-09-15 14:11:42 +02:00
|
|
|
}
|
|
|
|
|
2014-09-16 15:19:23 +02:00
|
|
|
/**
|
2021-05-20 09:28:12 +02:00
|
|
|
* @see Translator::translatePluralInDomain() For the function documentation.
|
2014-09-16 15:19:23 +02:00
|
|
|
*/
|
|
|
|
function mtp($domain, $messageId, $messageId2, $number, $context = null)
|
2014-09-11 18:04:10 +02:00
|
|
|
{
|
2021-05-20 09:28:12 +02:00
|
|
|
return StaticTranslator::$instance->translatePluralInDomain(
|
|
|
|
$domain,
|
|
|
|
$messageId,
|
|
|
|
$messageId2,
|
|
|
|
$number,
|
|
|
|
$context
|
|
|
|
);
|
2014-09-11 18:04:10 +02:00
|
|
|
}
|
2014-09-16 15:19:23 +02:00
|
|
|
|
2013-06-07 11:44:37 +02:00
|
|
|
} else {
|
2014-09-16 15:19:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see Translator::translate() For the function documentation.
|
|
|
|
*/
|
|
|
|
function t($messageId, $context = null)
|
2013-06-07 11:44:37 +02:00
|
|
|
{
|
|
|
|
return $messageId;
|
|
|
|
}
|
|
|
|
|
2014-09-16 15:19:23 +02:00
|
|
|
/**
|
|
|
|
* @see Translator::translate() For the function documentation.
|
|
|
|
*/
|
|
|
|
function mt($domain, $messageId, $context = null)
|
2013-06-07 11:44:37 +02:00
|
|
|
{
|
|
|
|
return $messageId;
|
|
|
|
}
|
2014-09-15 14:11:42 +02:00
|
|
|
|
2014-09-16 15:19:23 +02:00
|
|
|
/**
|
|
|
|
* @see Translator::translatePlural() For the function documentation.
|
|
|
|
*/
|
|
|
|
function tp($messageId, $messageId2, $number, $context = null)
|
2014-09-15 14:11:42 +02:00
|
|
|
{
|
2014-09-16 15:19:23 +02:00
|
|
|
if ((int) $number !== 1) {
|
2014-09-15 14:11:42 +02:00
|
|
|
return $messageId2;
|
|
|
|
}
|
2021-05-20 09:28:12 +02:00
|
|
|
|
2014-09-15 14:11:42 +02:00
|
|
|
return $messageId;
|
|
|
|
}
|
|
|
|
|
2014-09-16 15:19:23 +02:00
|
|
|
/**
|
|
|
|
* @see Translator::translatePlural() For the function documentation.
|
|
|
|
*/
|
|
|
|
function mtp($domain, $messageId, $messageId2, $number, $context = null)
|
2014-09-15 14:11:42 +02:00
|
|
|
{
|
2014-09-16 15:19:23 +02:00
|
|
|
if ((int) $number !== 1) {
|
2014-09-15 14:11:42 +02:00
|
|
|
return $messageId2;
|
|
|
|
}
|
2021-05-20 09:28:12 +02:00
|
|
|
|
2014-09-15 14:11:42 +02:00
|
|
|
return $messageId;
|
|
|
|
}
|
2014-09-16 15:19:23 +02:00
|
|
|
|
2013-06-07 11:44:37 +02:00
|
|
|
}
|