1 | <?php |
||
7 | class Localizer |
||
8 | { |
||
9 | /** |
||
10 | * Supported Locales |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $supportedLocales; |
||
15 | |||
16 | /** |
||
17 | * default Locales |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | |||
22 | protected $defaultLocale; |
||
23 | |||
24 | /** |
||
25 | * If `hideDefaultLocaleInURL` is true, then a url without locale |
||
26 | * is identical with the same url with default locale. |
||
27 | * |
||
28 | * @var bool |
||
29 | */ |
||
30 | protected $hideDefaultLocaleInURL = true; |
||
31 | |||
32 | /** |
||
33 | * Имя фйала с переводами |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $translationFileName = 'routes'; |
||
38 | |||
39 | /** |
||
40 | * Используется в атрибуте 'as' |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $localizerNamePrefix = 'localizer-'; |
||
45 | |||
46 | public function __construct($config) |
||
63 | |||
64 | /** |
||
65 | * Set supported Locales |
||
66 | * |
||
67 | * @return array |
||
68 | */ |
||
69 | public function setSupportedLocales($supportedLocales): void |
||
85 | |||
86 | /** |
||
87 | * Get supported Locales |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | public function getSupportedLocales(): array |
||
95 | |||
96 | /** |
||
97 | * Get slag Locales |
||
98 | * |
||
99 | * @return array |
||
100 | */ |
||
101 | public function getSlagsSupportedLocales(): array |
||
105 | |||
106 | /** |
||
107 | * is Supported Locale |
||
108 | * |
||
109 | * @param string $locale |
||
110 | * @return boolean |
||
111 | */ |
||
112 | public function isSupportedLocale($locale): bool |
||
116 | |||
117 | /** |
||
118 | * Получаем локаль по умолчанию |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | public function getDefaultLocale() |
||
126 | |||
127 | /** |
||
128 | * Установка локали |
||
129 | * |
||
130 | * @param string $locale |
||
131 | * @return void |
||
132 | */ |
||
133 | public function setLocale($locale): void |
||
139 | |||
140 | /** |
||
141 | * Получить локаль |
||
142 | * |
||
143 | * @return string |
||
144 | */ |
||
145 | public function getLocale(): string |
||
149 | |||
150 | /** Скрывать ли локаль по умолчанию в URL |
||
151 | * |
||
152 | * |
||
153 | * @return boolean |
||
154 | */ |
||
155 | public function isHideDefaultLocaleInURL(): bool |
||
159 | |||
160 | /** |
||
161 | * Имя фйала с переводами |
||
162 | * |
||
163 | * @return string |
||
164 | */ |
||
165 | public function getTranslationFileName(): string |
||
169 | |||
170 | /** |
||
171 | * Используется в атрибуте 'as' |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | public function getNamePrefix(): string |
||
179 | } |