|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace ipl\Stdlib; |
| 4 | + |
| 5 | +/** |
| 6 | + * Representation of translators |
| 7 | + */ |
| 8 | +interface Translator |
| 9 | +{ |
| 10 | + /** |
| 11 | + * Translate a message |
| 12 | + * |
| 13 | + * @param string $message |
| 14 | + * @param string $context Message context |
| 15 | + * |
| 16 | + * @return string Translated message or original message if no translation is found |
| 17 | + */ |
| 18 | + public function translate($message, $context = null); |
| 19 | + |
| 20 | + /** |
| 21 | + * Translate a message in the given domain |
| 22 | + * |
| 23 | + * If no translation is found in the specified domain, the translation is also searched for in the default domain. |
| 24 | + * |
| 25 | + * @param string $domain |
| 26 | + * @param string $message |
| 27 | + * @param string $context Message context |
| 28 | + * |
| 29 | + * @return string Translated message or original message if no translation is found |
| 30 | + */ |
| 31 | + public function translateInDomain($domain, $message, $context = null); |
| 32 | + |
| 33 | + /** |
| 34 | + * Translate a plural message |
| 35 | + * |
| 36 | + * The returned message is based on the given number to decide between the singular and plural forms. |
| 37 | + * That is also the case if no translation is found. |
| 38 | + * |
| 39 | + * @param string $singular Singular message |
| 40 | + * @param string $plural Plural message |
| 41 | + * @param int $number Number to decide between the returned singular and plural forms |
| 42 | + * @param string $context Message context |
| 43 | + * |
| 44 | + * @return string Translated message or original message if no translation is found |
| 45 | + */ |
| 46 | + public function translatePlural($singular, $plural, $number, $context = null); |
| 47 | + |
| 48 | + /** |
| 49 | + * Translate a plural message in the given domain |
| 50 | + * |
| 51 | + * If no translation is found in the specified domain, the translation is also searched for in the default domain. |
| 52 | + * |
| 53 | + * The returned message is based on the given number to decide between the singular and plural forms. |
| 54 | + * That is also the case if no translation is found. |
| 55 | + * |
| 56 | + * @param string $domain |
| 57 | + * @param string $singular Singular message |
| 58 | + * @param string $plural Plural message |
| 59 | + * @param int $number Number to decide between the returned singular and plural forms |
| 60 | + * @param string $context Message context |
| 61 | + * |
| 62 | + * @return string Translated message or original message if no translation is found |
| 63 | + */ |
| 64 | + public function translatePluralInDomain($domain, $singular, $plural, $number, $context = null); |
| 65 | +} |
0 commit comments