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 -279 10.2.2 → 11.1.1 View file →
@@ -1,279 +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($key, $jsSafe = false, $interpretBackSlashes = true, $textdomain = 'acymailing')
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($lang)
88 -{
89 - global $acymLanguages;
90 - $previousLanguage = $acymLanguages['currentLanguage'];
91 - $acymLanguages['currentLanguage'] = $lang;
92 -
93 - return $previousLanguage;
94 -}
95 -
96 -function acym_translationSprintf()
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($uppercaseLangCode = false, $published = false)
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($simple = false)
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($extension, $basePath = null, $lang = null, $reload = false, $default = true)
183 -{
184 - global $acymLanguages;
185 - $currentLanguage = acym_getLanguageTag();
186 - if (isset($acymLanguages[$currentLanguage][$extension]) && !$reload) return;
187 -
188 - $base = ACYM_LANGUAGE;
189 - $language = $currentLanguage;
190 -
191 - if (!file_exists($base.$language.'.'.$extension.'.ini')) {
192 - $language = ACYM_DEFAULT_LANGUAGE;
193 - if (!file_exists($base.$language.'.'.$extension.'.ini')) {
194 - $base = ACYM_FOLDER.'language'.DS;
195 - $language = $currentLanguage;
196 - if (!file_exists($base.$language.'.'.$extension.'.ini')) {
197 - $language = ACYM_DEFAULT_LANGUAGE;
198 - if (!file_exists($base.$language.'.'.$extension.'.ini')) return;
199 - }
200 - }
201 - }
202 -
203 - $data = acym_fileGetContent($base.$language.'.'.$extension.'.ini');
204 - $data = str_replace('"_QQ_"', '"', $data);
205 - $separate = explode("\n", $data);
206 - $storeExtension = $extension === ACYM_LANGUAGE_FILE.'_custom' ? ACYM_LANGUAGE_FILE : $extension;
207 - foreach ($separate as $raw) {
208 - if (strpos($raw, '=') === false) continue;
209 -
210 - $keyval = explode('=', $raw);
211 - $key = array_shift($keyval);
212 -
213 - $acymLanguages[$acymLanguages['currentLanguage']][$storeExtension][$key] = trim(implode('=', $keyval), "\"\r\n\t ");
214 - }
215 -
216 - if (!empty($acymLanguages[ACYM_DEFAULT_LANGUAGE])) return;
217 -
218 - $data = acym_fileGetContent($base.ACYM_DEFAULT_LANGUAGE.'.'.$extension.'.ini');
219 - $data = str_replace('"_QQ_"', '"', $data);
220 - $separate = explode("\n", $data);
221 -
222 - foreach ($separate as $raw) {
223 - if (strpos($raw, '=') === false) continue;
224 -
225 - $keyval = explode('=', $raw);
226 - $key = array_shift($keyval);
227 -
228 - $acymLanguages[ACYM_DEFAULT_LANGUAGE][$extension][$key] = trim(implode('=', $keyval), "\"\r\n\t ");
229 - }
230 -}
231 -
232 -function acym_getLanguagePath($basePath, $language = null)
233 -{
234 - return rtrim(ACYM_LANGUAGE, DS);
235 -}
236 -
237 -function acym_languageOption($emailLanguage, $name)
238 -{
239 - return '';
240 -}
241 -
242 -function convertWPLocaleToAcyLocale($locale)
243 -{
244 - if (strpos($locale, '-') !== false) return $locale;
245 -
246 - global $acyWPLangCodes;
247 - if (!empty($acyWPLangCodes[$locale])) return $acyWPLangCodes[$locale];
248 -
249 - if (strpos($locale, '_') === false) {
250 - return $locale.'-'.strtoupper($locale);
251 - } else {
252 - return str_replace('_', '-', $locale);
253 - }
254 -}
255 -
256 -function acym_getCmsUserLanguage($userId = null)
257 -{
258 - if ($userId === null) $userId = acym_currentUserId();
259 - if (empty($userId)) return '';
260 -
261 - return convertWPLocaleToAcyLocale(get_user_locale($userId));
262 -}
263 -
264 -function acym_getTranslationTools()
265 -{
266 - $options = [
267 - (object)['value' => 'no', 'text' => 'ACYM_NO'],
268 - ];
269 -
270 - $polylangOption = (object)['value' => 'polylang', 'text' => 'Polylang'];
271 - if (!acym_isExtensionActive('polylang/polylang.php') && !acym_isExtensionActive('polylang-pro/polylang.php')) $polylangOption->disable = true;
272 - $options[] = $polylangOption;
273 -
274 - $wpmlOption = (object)['value' => 'wpml', 'text' => 'WPML'];
275 - if (!acym_isExtensionActive('sitepress-multilingual-cms/sitepress.php')) $wpmlOption->disable = true;
276 - $options[] = $wpmlOption;
277 -
278 - return $options;
279 -}