3namespace Bitrix\Translate;
7use Bitrix\Main\Localization\Loc;
20 private const CACHE_TTL = 3600;
69 return [
'ru',
'en',
'de',
'kz'];
104 $mess = Loc::loadLanguageFile(__FILE__);
107 $mess = Loc::loadLanguageFile(__FILE__,
'en');
110 $encTitle = Loc::getMessage(
'TRANSLATE_ENCODING_'.\mb_strtoupper(\str_replace(
'-',
'_', $encoding)));
111 if (!empty($encTitle))
113 $encTitle .=
" ($encoding)";
117 $encTitle = $encoding;
118 $encAlias = self::getAliasEncoding($encoding);
121 $encTitle .=
" ($encAlias)";
137 static $aliasEncoding = [
138 'windows-1250' =>
'iso-8859-2',
139 'windows-1252' =>
'iso-8859-1',
141 if (isset($aliasEncoding[$encoding]))
143 return $aliasEncoding[$encoding];
146 $alias = array_search($encoding, $aliasEncoding);
147 if ($alias !==
false)
164 static $cultureEncoding;
165 if ($cultureEncoding ===
null)
167 $cultureEncoding = [];
169 'select' => [
'ID',
'CODE',
'CHARSET'],
170 'cache' => [
'ttl' => self::CACHE_TTL],
174 $cultureEncoding[\mb_strtolower($row[
'CODE'])] = \mb_strtolower($row[
'CHARSET']);
178 return ($cultureEncoding[$languageId] ??
null) ?:
null;
189 if ($languages ===
null)
193 'select' => [
'ID',
'SORT'],
194 'order' => [
'SORT' =>
'ASC'],
195 'cache' => [
'ttl' => $skipCache ? 0 : self::CACHE_TTL],
199 $languages[] = mb_strtolower($row[
'ID']);
214 if ($languages ===
null)
218 'select' => [
'ID',
'SORT'],
219 'filter' => [
'=ACTIVE' =>
'Y'],
220 'order' => [
'SORT' =>
'ASC'],
221 'cache' => [
'ttl' => self::CACHE_TTL],
225 $languages[] = mb_strtolower($row[
'ID']);
243 $cacheId = \implode(
'-', $languageIds);
244 if (!isset($cache[$cacheId]))
246 $cache[$cacheId] = [];
249 'select' => [
'ID',
'NAME'],
251 '=ID' => $languageIds,
254 'order' => [
'SORT' =>
'ASC'],
255 'cache' => [
'ttl' => self::CACHE_TTL],
259 $cache[$cacheId][mb_strtolower($row[
'ID'])] = $row[
'NAME'];
263 return $cache[$cacheId];
274 if ($languages ===
null)
276 $languages = \array_unique(\array_merge(
277 self::getAvailableDefaultLanguages(),
278 self::getTranslationRepositoryLanguages()
293 if ($languages ===
null)
297 foreach ($langDirList->getChildren() as $langDir)
299 $langId = $langDir->getName();
304 $languages[] = $langId;
319 if ($languages ===
null)
325 foreach ($langDirList->getChildren() as $langDir)
327 $langId = $langDir->getName();
332 $languages[] = $langId;
345 public static function getInitPath():
array
349 if ($initFolders ===
null)
354 self::OPTION_INIT_FOLDERS,
357 $folders = \explode(
',', \trim($folders));
358 foreach ($folders as $oneFolder)
360 if (!empty($oneFolder))
363 $initFolders[] =
'/'.\ltrim($oneFolder,
'/');
379 if ($defaultPath ===
null)
381 $folders = \explode(
',', self::getModuleDefault(self::OPTION_INIT_FOLDERS));
382 $defaultPath = $folders[0];
396 static $needToBackUpFiles;
397 if ($needToBackUpFiles ===
null)
399 $def = self::getModuleDefault(self::OPTION_BACKUP_FILES);
403 return $needToBackUpFiles;
413 static $backupFolder;
414 if ($backupFolder ===
null)
417 if (!empty($confOption))
419 if (\mb_strpos($confOption,
'/') === 0)
421 $backupFolder = $confOption;
423 elseif (\strncasecmp(\PHP_OS,
'WIN', 3) === 0 && \preg_match(
"#^[a-z]{1}:/#i", $confOption))
425 $backupFolder = $confOption;
434 $defOption = self::getModuleDefault(self::OPTION_BACKUP_FOLDER);
435 if (empty($defOption))
437 $defOption =
'bitrix/backup/translate/';
443 return $backupFolder;
453 static $needToSortPhrases;
454 if ($needToSortPhrases ===
null)
456 $def = self::getModuleDefault(self::OPTION_SORT_PHRASES);
460 return $needToSortPhrases;
470 static $nonSortPhraseLanguages;
471 if ($nonSortPhraseLanguages ===
null)
473 $nonSortPhraseLanguages = [];
474 $def = self::getModuleDefault(self::OPTION_DONT_SORT_LANGUAGES);
476 if (!is_array($nonSortPhraseLanguages))
478 $nonSortPhraseLanguages = \explode(
',', $nonSortPhraseLanguages);
482 return $nonSortPhraseLanguages;
492 static $exportFolder = -1;
493 if ($exportFolder === -1)
495 $exportFolder =
null;
497 if (!empty($confOption))
501 $exportFolder = $confOption;
510 return $exportFolder;
static getDefaults($moduleId)
static get($moduleId, $name, $default="", $siteId=false)
static useTranslationRepository()
static getTranslationRepositoryPath()
static getList(array $parameters=array())
static getAvailableDefaultLanguages()
const OPTION_INIT_FOLDERS
const OPTION_BACKUP_FOLDER
static getCultureEncoding(string $languageId)
static getEncodingName(string $encoding)
static getAvailableLanguages()
const OPTION_EXPORT_CSV_DELIMITER
const OPTION_BACKUP_FILES
static needToSortPhrases()
static getNonSortPhraseLanguages()
static getEnabledLanguages()
static getModuleDefault(string $optionName)
static getLanguages(bool $skipCache=false)
static getDefaultLanguages()
static getAllowedEncodings()
const OPTION_SORT_PHRASES
static needToBackUpFiles()
static getAliasEncoding(string $encoding)
const OPTION_BUTTON_LANG_FILES
static getTranslationRepositoryLanguages()
const OPTION_DONT_SORT_LANGUAGES
const OPTION_EXPORT_FOLDER
static getLanguagesTitle(array $languageIds)
static getOption(string $optionName)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
foreach($arTemplatesList as $templ) if(mb_strpos($templ["NAME"] $def