summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/i18n/src/functions.php
blob: 74d58df634f91d26144ab0b32ca33cbca9d1b91f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

namespace ipl\I18n;

/**
 * Translate a message
 *
 * @param string $message
 * @param string $context Message context
 *
 * @return string Translated message or original message if no translation is found
 */
function t($message, $context = null)
{
    return StaticTranslator::$instance->translate($message, $context);
}

/**
 * Translate a plural message
 *
 * The returned message is based on the given number to decide between the singular and plural forms.
 * That is also the case if no translation is found.
 *
 * @param string $singular Singular message
 * @param string $plural   Plural message
 * @param int    $number   Number to decide between the returned singular and plural forms
 * @param string $context  Message context
 *
 * @return string Translated message or original message if no translation is found
 */
function tp($singular, $plural, $number, $context = null)
{
    return StaticTranslator::$instance->translatePlural($singular, $plural, $number, $context);
}