1 | <?php |
||
18 | abstract class lang |
||
19 | { |
||
20 | /** |
||
21 | * @var string default language code |
||
22 | */ |
||
23 | const DEFAULT_LANGUAGE = "en"; |
||
24 | |||
25 | /** |
||
26 | * Use this property to set an error callback - you can use this for error reporting in test-suites. |
||
27 | * |
||
28 | * @var callable function ($message) : void |
||
29 | */ |
||
30 | public static $on_error; |
||
31 | |||
32 | /** |
||
33 | * @var string active language code |
||
34 | */ |
||
35 | protected static $code = self::DEFAULT_LANGUAGE; |
||
36 | |||
37 | /** |
||
38 | * @var (string|callable)[][] map where "{domain}/{code}" => translation strings or callables |
||
39 | */ |
||
40 | protected static $lang = []; |
||
41 | |||
42 | /** |
||
43 | * @var string[] map where "{domain}" or "{domain}/{code}" => absolute path to language file |
||
44 | */ |
||
45 | protected static $paths = []; |
||
46 | |||
47 | /** |
||
48 | * Change the current active language code. |
||
49 | * |
||
50 | * @param string $code two-letter ISO-639-1 language code (such as "en", "da", "es", etc.) |
||
51 | * |
||
52 | * @link https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes |
||
53 | */ |
||
54 | 1 | public static function set($code) |
|
58 | |||
59 | /** |
||
60 | * Register the physical base path of language files for a given translation domain name. |
||
61 | * |
||
62 | * @param string $domain translation domain name |
||
63 | * @param string $path absolute path to language directory (or base filename, without ".php") |
||
64 | */ |
||
65 | 1 | public static function register($domain, $path) |
|
69 | |||
70 | /** |
||
71 | * Translate the given text in the given domain and substitute the given tokens. |
||
72 | * |
||
73 | * @param string $domain translation domain name |
||
74 | * @param string $text english text |
||
75 | * @param array|null $tokens map where token name => replacement string |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | 1 | public static function text($domain, $text, array $tokens = null) |
|
83 | |||
84 | /** |
||
85 | * Obtain a translation callback for a given domain, optionally for a specific language. |
||
86 | * |
||
87 | * The returned function has the following signature: |
||
88 | * |
||
89 | * function (string $text, array $tokens) : string |
||
90 | * |
||
91 | * This may be useful in a view/template, for example, so you don't have to repeat the |
||
92 | * domain name for every call. It may also be useful to inject this function as a dependency. |
||
93 | * |
||
94 | * @param string $domain translation domain name |
||
95 | * @param string|null $code optional language code (defaults to the current language) |
||
96 | * |
||
97 | * @return callable function ($text, array $tokens) : string |
||
98 | */ |
||
99 | 1 | public static function domain($domain, $code = null) |
|
105 | |||
106 | /** |
||
107 | * This is the lowest-level function, which requires every parameter to be given explicitly. |
||
108 | * |
||
109 | * @param string $code two-letter ISO-639-1 language code |
||
110 | * @param string $domain translation domain name |
||
111 | * @param string $text english text |
||
112 | * @param array $tokens map where token name => replacement string |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | 1 | public static function translate($code, $domain, $text, array $tokens = null) |
|
173 | |||
174 | /** |
||
175 | * Reset the internal state of the language registry. |
||
176 | * |
||
177 | * This may be useful for unit-testing or other special situations. |
||
178 | */ |
||
179 | 1 | public static function reset() |
|
185 | |||
186 | /** |
||
187 | * Internally find a load a given language file. |
||
188 | * |
||
189 | * @param string $name full language file base name, e.g. "{domain}/{code}" |
||
190 | */ |
||
191 | 1 | protected static function load($name) |
|
232 | } |
||
233 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.