PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Core/wordpress/language.php +0 -285 10.11.1 → 11.1.1 View file →
@@ -1,285 +1,0 @@
1 -<?php
2 -
3 -global $acyWPLangCodes;
4 -$acyWPLangCodes = [
5 - 'af' => 'af-ZA',
6 - 'ar' => 'ar-AA',
7 - 'as' => 'as-AS', // Not sure
8 - 'az' => 'az-AZ', // Not sure
9 - 'bo' => 'bo-BO', // Not sure
10 - 'ca' => 'ca-ES',
11 - 'cy' => 'cy-GB',
12 - 'el' => 'el-GR',
13 - 'eo' => 'eo-XX',
14 - 'et' => 'et-EE',
15 - 'eu' => 'eu-ES',
16 - 'fi' => 'fi-FI',
17 - 'gd' => 'gd-GD', // Not sure
18 - 'gu' => 'gu-GU', // Not sure
19 - 'hr' => 'hr-HR',
20 - 'hy' => 'hy-AM',
21 - 'ja' => 'ja-JP',
22 - 'kk' => 'kk-KK', // Not sure
23 - 'km' => 'km-KH',
24 - 'lo' => 'lo-LO', // Not sure
25 - 'lv' => 'lv-LV',
26 - 'mn' => 'mn-MN', // Not sure
27 - 'mr' => 'mr-MR', // Not sure
28 - 'ps' => 'ps-PS', // Not sure
29 - 'sq' => 'sq-AL',
30 - 'te' => 'te-TE',
31 - 'th' => 'th-TH',
32 - 'tl' => 'tl-TL', // Not sure
33 - 'uk' => 'uk-UA',
34 - 'ur' => 'ur-PK', // Not sure
35 - 'vi' => 'vi-VN',
36 -];
37 -
38 -global $acymLanguages;
39 -
40 -function acym_translation(string $key, bool $jsSafe = false, bool $interpretBackSlashes = true, string $textdomain = 'acymailing'): string
41 -{
42 - $translation = $key;
43 -
44 - global $acymLanguages;
45 - acym_getLanguageTag();
46 - if (!isset($acymLanguages[$acymLanguages['currentLanguage']])) acym_loadLanguage();
47 -
48 - $acymailingEnglishText = '';
49 - foreach ($acymLanguages[ACYM_DEFAULT_LANGUAGE] as $fileContent) {
50 - if (isset($fileContent[$key])) {
51 - $acymailingEnglishText = $fileContent[$key];
52 - break;
53 - }
54 - }
55 -
56 - global $customTranslation;
57 - acym_getCustomTranslation();
58 -
59 - if (!empty($customTranslation) && isset($customTranslation[$key])) {
60 - $translation = $customTranslation[$key];
61 - } elseif (!empty($acymailingEnglishText)) {
62 - $translation = empty($textdomain) ? __($acymailingEnglishText) : __($acymailingEnglishText, $textdomain);
63 -
64 - if ($translation === $acymailingEnglishText && $acymLanguages['currentLanguage'] != ACYM_DEFAULT_LANGUAGE) {
65 - foreach ($acymLanguages[$acymLanguages['currentLanguage']] as $fileContent) {
66 - if (isset($fileContent[$key])) {
67 - $translation = $fileContent[$key];
68 - break;
69 - }
70 - }
71 - }
72 - }
73 -
74 - if ($jsSafe) {
75 - $translation = str_replace('"', '\"', $translation);
76 - } elseif ($interpretBackSlashes && strpos($translation, '\\') !== false) {
77 - $translation = str_replace(['\\\\', '\t', '\n'], ["\\", "\t", "\n"], $translation);
78 - }
79 -
80 - if ($translation == $key) {
81 - $translation = empty($textdomain) ? __($translation) : __($translation, $textdomain);
82 - }
83 -
84 - return $translation;
85 -}
86 -
87 -function acym_setLanguage(string $lang): string
88 -{
89 - global $acymLanguages;
90 - $previousLanguage = $acymLanguages['currentLanguage'];
91 - $acymLanguages['currentLanguage'] = $lang;
92 -
93 - return $previousLanguage;
94 -}
95 -
96 -function acym_translationSprintf(): string
97 -{
98 - $args = func_get_args();
99 - $args[0] = acym_translation($args[0]);
100 -
101 - return call_user_func_array('sprintf', $args);
102 -}
103 -
104 -function acym_getLanguages(bool $uppercaseLangCode = false, bool $published = false): array
105 -{
106 - global $acyWPLangCodes;
107 -
108 - $result = [];
109 -
110 - require_once ABSPATH.'wp-admin/includes/translation-install.php';
111 - $wplanguages = wp_get_available_translations();
112 - $languages = get_available_languages();
113 - foreach ($languages as $oneLang) {
114 - $wpLangCode = $oneLang;
115 - if (!empty($acyWPLangCodes[$oneLang])) $oneLang = $acyWPLangCodes[$oneLang];
116 - $langTag = str_replace('_', '-', $oneLang);
117 -
118 - $lang = new stdClass();
119 - $lang->sef = empty($wplanguages[$oneLang]['iso'][1]) ? null : $wplanguages[$oneLang]['iso'][1];
120 - $lang->language = $uppercaseLangCode ? $langTag : strtolower($langTag);
121 - $lang->name = empty($wplanguages[$wpLangCode]) ? $langTag : $wplanguages[$wpLangCode]['native_name'];
122 - $lang->exists = file_exists(ACYM_LANGUAGE.$langTag.'.'.ACYM_LANGUAGE_FILE.'.ini');
123 - $lang->content = true;
124 -
125 - $result[$langTag] = $lang;
126 - }
127 -
128 - if (!in_array('en-US', array_keys($result))) {
129 - $lang = new stdClass();
130 - $lang->sef = 'en';
131 - $lang->language = 'en-us';
132 - $lang->name = 'English (United States)';
133 - $lang->exists = file_exists(ACYM_LANGUAGE.'en-US.'.ACYM_LANGUAGE_FILE.'.ini');
134 - $lang->content = true;
135 -
136 - $result['en-US'] = $lang;
137 - }
138 -
139 - return $result;
140 -}
141 -
142 -function acym_getLanguageTag(bool $simple = false): string
143 -{
144 - if (acym_isAdmin()) {
145 - $currentLocale = get_user_locale(acym_currentUserId());
146 - } else {
147 - $currentLocale = get_locale();
148 - }
149 -
150 - $currentLocale = convertWPLocaleToAcyLocale($currentLocale);
151 -
152 - global $acymLanguages;
153 - if (!isset($acymLanguages['currentLanguage'])) {
154 - $acymLanguages['currentLanguage'] = $currentLocale;
155 - }
156 -
157 - return $simple ? substr($acymLanguages['currentLanguage'], 0, 2) : $acymLanguages['currentLanguage'];
158 -}
159 -
160 -function acym_getCustomTranslation()
161 -{
162 - global $customTranslation;
163 - if (isset($customTranslation)) return;
164 - $customTranslation = [];
165 - $currentLanguage = acym_getLanguageTag();
166 - $filePath = ACYM_LANGUAGE.$currentLanguage.'.'.ACYM_LANGUAGE_FILE.'_custom.ini';
167 - if (file_exists($filePath)) {
168 - $data = acym_fileGetContent($filePath);
169 - $data = str_replace('"_QQ_"', '"', $data);
170 - $separate = explode("\n", $data);
171 - foreach ($separate as $raw) {
172 - if (strpos($raw, '=') === false) continue;
173 -
174 - $keyval = explode('=', $raw);
175 - $key = array_shift($keyval);
176 -
177 - $customTranslation[$key] = trim(implode('=', $keyval), "\"\r\n\t ");
178 - }
179 - }
180 -}
181 -
182 -function acym_loadLanguageFile(string $extension, ?string $basePath = null, ?string $lang = null, bool $reload = false, bool $default = true): void
183 -{
184 - global $acymLanguages;
185 - $currentLanguage = acym_getLanguageTag();
186 - if (isset($acymLanguages[$currentLanguage][$extension]) && !$reload) {
187 - return;
188 - }
189 -
190 - if (ACYM_PRODUCTION) {
191 - $base = ACYM_LANGUAGE;
192 - }
193 -
194 -
195 - $language = $currentLanguage;
196 -
197 - if (!file_exists($base.$language.'.'.$extension.'.ini')) {
198 - $language = ACYM_DEFAULT_LANGUAGE;
199 - if (!file_exists($base.$language.'.'.$extension.'.ini')) {
200 - $base = ACYM_FOLDER.'language'.DS;
201 - $language = $currentLanguage;
202 - if (!file_exists($base.$language.'.'.$extension.'.ini')) {
203 - $language = ACYM_DEFAULT_LANGUAGE;
204 - if (!file_exists($base.$language.'.'.$extension.'.ini')) return;
205 - }
206 - }
207 - }
208 -
209 - $data = acym_fileGetContent($base.$language.'.'.$extension.'.ini');
210 - $data = str_replace('"_QQ_"', '"', $data);
211 - $separate = explode("\n", $data);
212 - $storeExtension = $extension === ACYM_LANGUAGE_FILE.'_custom' ? ACYM_LANGUAGE_FILE : $extension;
213 - foreach ($separate as $raw) {
214 - if (strpos($raw, '=') === false) continue;
215 -
216 - $keyval = explode('=', $raw);
217 - $key = array_shift($keyval);
218 -
219 - $acymLanguages[$acymLanguages['currentLanguage']][$storeExtension][$key] = trim(implode('=', $keyval), "\"\r\n\t ");
220 - }
221 -
222 - if (!empty($acymLanguages[ACYM_DEFAULT_LANGUAGE])) return;
223 -
224 - $data = acym_fileGetContent($base.ACYM_DEFAULT_LANGUAGE.'.'.$extension.'.ini');
225 - $data = str_replace('"_QQ_"', '"', $data);
226 - $separate = explode("\n", $data);
227 -
228 - foreach ($separate as $raw) {
229 - if (strpos($raw, '=') === false) continue;
230 -
231 - $keyval = explode('=', $raw);
232 - $key = array_shift($keyval);
233 -
234 - $acymLanguages[ACYM_DEFAULT_LANGUAGE][$extension][$key] = trim(implode('=', $keyval), "\"\r\n\t ");
235 - }
236 -}
237 -
238 -function acym_getLanguagePath(string $basePath, ?string $language = null): string
239 -{
240 - return rtrim(ACYM_LANGUAGE, DS);
241 -}
242 -
243 -function acym_languageOption(?string $emailLanguage, string $name): string
244 -{
245 - return '';
246 -}
247 -
248 -function convertWPLocaleToAcyLocale(string $locale): string
249 -{
250 - if (strpos($locale, '-') !== false) return $locale;
251 -
252 - global $acyWPLangCodes;
253 - if (!empty($acyWPLangCodes[$locale])) return $acyWPLangCodes[$locale];
254 -
255 - if (strpos($locale, '_') === false) {
256 - return $locale.'-'.strtoupper($locale);
257 - } else {
258 - return str_replace('_', '-', $locale);
259 - }
260 -}
261 -
262 -function acym_getCmsUserLanguage(?int $userId = null): ?string
263 -{
264 - if ($userId === null) $userId = acym_currentUserId();
265 - if (empty($userId)) return '';
266 -
267 - return convertWPLocaleToAcyLocale(get_user_locale($userId));
268 -}
269 -
270 -function acym_getTranslationTools(): array
271 -{
272 - $options = [
273 - (object)['value' => 'no', 'text' => 'ACYM_NO'],
274 - ];
275 -
276 - $polylangOption = (object)['value' => 'polylang', 'text' => 'Polylang'];
277 - if (!acym_isExtensionActive('polylang/polylang.php') && !acym_isExtensionActive('polylang-pro/polylang.php')) $polylangOption->disable = true;
278 - $options[] = $polylangOption;
279 -
280 - $wpmlOption = (object)['value' => 'wpml', 'text' => 'WPML'];
281 - if (!acym_isExtensionActive('sitepress-multilingual-cms/sitepress.php')) $wpmlOption->disable = true;
282 - $options[] = $wpmlOption;
283 -
284 - return $options;
285 -}