| 1 |
<?php |
| 2 |
|
| 3 |
namespace ipl\I18n; |
| 4 |
|
| 5 |
/** |
| 6 |
* Translate a message |
| 7 |
* |
| 8 |
* @param string $message |
| 9 |
* @param ?string $context Message context |
| 10 |
* |
| 11 |
* @return string Translated message or original message if no translation is found |
| 12 |
*/ |
| 13 |
function t(string $message, ?string $context = null): string |
| 14 |
{ |
| 15 |
return StaticTranslator::$instance->translate($message, $context); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Translate a plural message |
| 20 |
* |
| 21 |
* The returned message is based on the given number to decide between the singular and plural forms. |
| 22 |
* That is also the case if no translation is found. |
| 23 |
* |
| 24 |
* @param string $singular Singular message |
| 25 |
* @param string $plural Plural message |
| 26 |
* @param int $number Number to decide between the returned singular and plural forms |
| 27 |
* @param ?string $context Message context |
| 28 |
* |
| 29 |
* @return string Translated message or original message if no translation is found |
| 30 |
*/ |
| 31 |
function tp(string $singular, string $plural, int $number, ?string $context = null): string |
| 32 |
{ |
| 33 |
return StaticTranslator::$instance->translatePlural($singular, $plural, $number, $context); |
| 34 |
} |