Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
8 / 8
CRAP
n/a
0 / 0
__
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
__p
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
__n
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
__np
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
__d
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
__dp
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
__dn
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
__dnp
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5use Celema\Verba\Verba;
6
7/**
8 * Translate a message through the active domain cascade.
9 *
10 * @param string|int|float|array<array-key, string|int|float> ...$args
11 *
12 * @api
13 */
14function __(string $message, string|int|float|array ...$args): string
15{
16    return Verba::translate($message, Verba::args($args));
17}
18
19/**
20 * Translate a message in a specific context through the active domain cascade.
21 *
22 * @param string|int|float|array<array-key, string|int|float> ...$args
23 *
24 * @api
25 */
26function __p(string $context, string $message, string|int|float|array ...$args): string
27{
28    return Verba::translateContext($context, $message, Verba::args($args));
29}
30
31/**
32 * Translate a pluralized message, choosing the form for $n.
33 *
34 * @param string|int|float|array<array-key, string|int|float> ...$args
35 *
36 * @api
37 */
38function __n(string $one, string $many, int $n, string|int|float|array ...$args): string
39{
40    return Verba::translatePlural($one, $many, $n, Verba::args($args));
41}
42
43/**
44 * Translate a pluralized message in a specific context.
45 *
46 * @param string|int|float|array<array-key, string|int|float> ...$args
47 *
48 * @api
49 */
50function __np(
51    string $context,
52    string $one,
53    string $many,
54    int $n,
55    string|int|float|array ...$args,
56): string {
57    return Verba::translateContextPlural($context, $one, $many, $n, Verba::args($args));
58}
59
60/**
61 * Translate a message from a specific domain.
62 *
63 * @param string|int|float|array<array-key, string|int|float> ...$args
64 *
65 * @api
66 */
67function __d(string $domain, string $message, string|int|float|array ...$args): string
68{
69    return Verba::translateDomain($domain, $message, Verba::args($args));
70}
71
72/**
73 * Translate a contextual message from a specific domain.
74 *
75 * @param string|int|float|array<array-key, string|int|float> ...$args
76 *
77 * @api
78 */
79function __dp(
80    string $domain,
81    string $context,
82    string $message,
83    string|int|float|array ...$args,
84): string {
85    return Verba::translateDomainContext($domain, $context, $message, Verba::args($args));
86}
87
88/**
89 * Translate a pluralized message from a specific domain.
90 *
91 * @param string|int|float|array<array-key, string|int|float> ...$args
92 *
93 * @api
94 */
95function __dn(
96    string $domain,
97    string $one,
98    string $many,
99    int $n,
100    string|int|float|array ...$args,
101): string {
102    return Verba::translateDomainPlural($domain, $one, $many, $n, Verba::args($args));
103}
104
105/**
106 * Translate a contextual pluralized message from a specific domain.
107 *
108 * @param string|int|float|array<array-key, string|int|float> ...$args
109 *
110 * @api
111 * @mago-expect lint:excessive-parameter-list The API mirrors dnpgettext plus interpolation args.
112 */
113function __dnp(
114    string $domain,
115    string $context,
116    string $one,
117    string $many,
118    int $n,
119    string|int|float|array ...$args,
120): string {
121    return Verba::translateDomainContextPlural(
122        $domain,
123        $context,
124        $one,
125        $many,
126        $n,
127        Verba::args($args),
128    );
129}