PluginProbe
WPIDE – File Manager & Code Editor / 3.5.9
WPIDE – File Manager & Code Editor v3.5.9
3.5.9 3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 All 55 releases
wpide / vendor / rakit / validation / src / Traits / TranslationsTrait.php

TranslationsTrait.php in WPIDE – File Manager & Code Editor 3.5.9, at vendor/rakit/validation/src/Traits/TranslationsTrait.php

55 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Rakit\Validation\Traits;
4
5 trait TranslationsTrait
6 {
7
8 /** @var array */
9 protected $translations = [];
10
11 /**
12 * Given $key and $translation to set translation
13 *
14 * @param mixed $key
15 * @param mixed $translation
16 * @return void
17 */
18 public function setTranslation(string $key, string $translation)
19 {
20 $this->translations[$key] = $translation;
21 }
22
23 /**
24 * Given $translations and set multiple translations
25 *
26 * @param array $translations
27 * @return void
28 */
29 public function setTranslations(array $translations)
30 {
31 $this->translations = array_merge($this->translations, $translations);
32 }
33
34 /**
35 * Given translation from given $key
36 *
37 * @param string $key
38 * @return string
39 */
40 public function getTranslation(string $key): string
41 {
42 return array_key_exists($key, $this->translations) ? $this->translations[$key] : $key;
43 }
44
45 /**
46 * Get all $translations
47 *
48 * @return array
49 */
50 public function getTranslations(): array
51 {
52 return $this->translations;
53 }
54 }
55