API
6 years ago
Access
6 years ago
Application
6 years ago
Archive
6 years ago
ArchiveProcessor
6 years ago
Archiver
6 years ago
AssetManager
6 years ago
Auth
6 years ago
Category
6 years ago
CliMulti
6 years ago
Columns
6 years ago
Composer
6 years ago
Concurrency
6 years ago
Config
6 years ago
Container
6 years ago
CronArchive
6 years ago
DataAccess
5 years ago
DataFiles
6 years ago
DataTable
6 years ago
Db
6 years ago
DeviceDetector
5 years ago
Email
6 years ago
Exception
6 years ago
Http
6 years ago
Intl
6 years ago
Mail
6 years ago
Measurable
6 years ago
Menu
6 years ago
Metrics
6 years ago
Notification
6 years ago
Period
6 years ago
Plugin
6 years ago
ProfessionalServices
6 years ago
Report
6 years ago
ReportRenderer
6 years ago
Scheduler
6 years ago
Segment
6 years ago
Session
6 years ago
Settings
6 years ago
Tracker
5 years ago
Translation
6 years ago
UpdateCheck
6 years ago
Updater
6 years ago
Updates
6 years ago
Validators
6 years ago
View
6 years ago
ViewDataTable
6 years ago
Visualization
6 years ago
Widget
6 years ago
.htaccess
6 years ago
Access.php
6 years ago
Archive.php
6 years ago
ArchiveProcessor.php
6 years ago
AssetManager.php
6 years ago
Auth.php
6 years ago
BaseFactory.php
6 years ago
Cache.php
6 years ago
CacheId.php
6 years ago
CliMulti.php
6 years ago
Common.php
6 years ago
Config.php
6 years ago
Console.php
6 years ago
Context.php
6 years ago
Cookie.php
5 years ago
CronArchive.php
5 years ago
DataArray.php
6 years ago
DataTable.php
6 years ago
Date.php
6 years ago
Db.php
6 years ago
DbHelper.php
6 years ago
Development.php
6 years ago
DeviceDetectorFactory.php
6 years ago
ErrorHandler.php
6 years ago
EventDispatcher.php
6 years ago
ExceptionHandler.php
6 years ago
FileIntegrity.php
6 years ago
Filechecks.php
6 years ago
Filesystem.php
6 years ago
FrontController.php
6 years ago
Http.php
6 years ago
IP.php
6 years ago
Log.php
6 years ago
LogDeleter.php
6 years ago
Mail.php
6 years ago
Metrics.php
6 years ago
MetricsFormatter.php
6 years ago
Nonce.php
5 years ago
Notification.php
6 years ago
NumberFormatter.php
6 years ago
Option.php
5 years ago
Period.php
6 years ago
Piwik.php
6 years ago
Plugin.php
6 years ago
Profiler.php
6 years ago
ProxyHeaders.php
6 years ago
ProxyHttp.php
6 years ago
QuickForm2.php
6 years ago
RankingQuery.php
6 years ago
Registry.php
6 years ago
ReportRenderer.php
6 years ago
ScheduledTask.php
6 years ago
Segment.php
6 years ago
Sequence.php
6 years ago
Session.php
6 years ago
SettingsPiwik.php
6 years ago
SettingsServer.php
6 years ago
Singleton.php
6 years ago
Site.php
6 years ago
TCPDF.php
6 years ago
TaskScheduler.php
6 years ago
Theme.php
6 years ago
Timer.php
6 years ago
Tracker.php
6 years ago
Translate.php
6 years ago
Twig.php
6 years ago
Unzip.php
6 years ago
UpdateCheck.php
6 years ago
Updater.php
6 years ago
Updates.php
6 years ago
Url.php
6 years ago
UrlHelper.php
6 years ago
Version.php
5 years ago
View.php
6 years ago
bootstrap.php
6 years ago
dispatch.php
6 years ago
testMinimumPhpVersion.php
6 years ago
Translate.php
130 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Piwik - free/libre analytics platform |
| 4 | * |
| 5 | * @link https://matomo.org |
| 6 | * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 7 | * |
| 8 | */ |
| 9 | namespace Piwik; |
| 10 | |
| 11 | use Exception; |
| 12 | use Piwik\Container\StaticContainer; |
| 13 | use Piwik\Plugin\Manager; |
| 14 | use Piwik\Translation\Translator; |
| 15 | |
| 16 | /** |
| 17 | * @deprecated Use Piwik\Translation\Translator instead. |
| 18 | * @see \Piwik\Translation\Translator |
| 19 | */ |
| 20 | class Translate |
| 21 | { |
| 22 | /** |
| 23 | * Clean a string that may contain HTML special chars, single/double quotes, HTML entities, leading/trailing whitespace |
| 24 | * |
| 25 | * @param string $s |
| 26 | * @return string |
| 27 | */ |
| 28 | public static function clean($s) |
| 29 | { |
| 30 | return html_entity_decode(trim($s), ENT_QUOTES, 'UTF-8'); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * @deprecated |
| 35 | */ |
| 36 | public static function loadEnglishTranslation() |
| 37 | { |
| 38 | self::loadAllTranslations(); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @deprecated |
| 43 | */ |
| 44 | public static function unloadEnglishTranslation() |
| 45 | { |
| 46 | self::reset(); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @deprecated |
| 51 | */ |
| 52 | public static function reloadLanguage($language = false) |
| 53 | { |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Reads the specified code translation file in memory. |
| 58 | * |
| 59 | * @param bool|string $language 2 letter language code. If not specified, will detect current user translation, or load default translation. |
| 60 | * @return void |
| 61 | */ |
| 62 | public static function loadCoreTranslation($language = false) |
| 63 | { |
| 64 | self::getTranslator()->addDirectory(PIWIK_INCLUDE_PATH . '/lang'); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * @deprecated |
| 69 | */ |
| 70 | public static function mergeTranslationArray($translation) |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * @return string the language filename prefix, eg 'en' for english |
| 76 | * @throws exception if the language set is not a valid filename |
| 77 | */ |
| 78 | public static function getLanguageToLoad() |
| 79 | { |
| 80 | return self::getTranslator()->getCurrentLanguage(); |
| 81 | } |
| 82 | |
| 83 | /** Reset the cached language to load. Used in tests. */ |
| 84 | public static function reset() |
| 85 | { |
| 86 | self::getTranslator()->reset(); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Either the name of the currently loaded language such as 'en' or 'de' or null if no language is loaded at all. |
| 91 | * @return bool|string |
| 92 | */ |
| 93 | public static function getLanguageLoaded() |
| 94 | { |
| 95 | return self::getTranslator()->getCurrentLanguage(); |
| 96 | } |
| 97 | |
| 98 | public static function getLanguageDefault() |
| 99 | { |
| 100 | return self::getTranslator()->getDefaultLanguage(); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Generate javascript translations array |
| 105 | */ |
| 106 | public static function getJavascriptTranslations() |
| 107 | { |
| 108 | return self::getTranslator()->getJavascriptTranslations(); |
| 109 | } |
| 110 | |
| 111 | public static function findTranslationKeyForTranslation($translation) |
| 112 | { |
| 113 | return self::getTranslator()->findTranslationKeyForTranslation($translation); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * @return Translator |
| 118 | */ |
| 119 | private static function getTranslator() |
| 120 | { |
| 121 | return StaticContainer::get('Piwik\Translation\Translator'); |
| 122 | } |
| 123 | |
| 124 | public static function loadAllTranslations() |
| 125 | { |
| 126 | self::loadCoreTranslation(); |
| 127 | Manager::getInstance()->loadPluginTranslations(); |
| 128 | } |
| 129 | } |
| 130 |