API
1 month ago
Blocks
10 months ago
License
1 month ago
AdminNotice.php
3 weeks ago
AdminNotices.php
3 weeks ago
AjaxActions.php
3 weeks ago
Blocks.php
1 year ago
Compatibility.php
10 months ago
Learn.php
1 month ago
Menu.php
1 month ago
Migrations.php
1 year ago
NpsSurvey.php
5 months ago
Onboarding.php
3 weeks ago
Player.php
3 days ago
PluginInstaller.php
1 month ago
PreloadService.php
1 year ago
ProCompatibility.php
1 month ago
ReusableVideos.php
2 weeks ago
RewriteRulesManager.php
1 year ago
Scripts.php
2 weeks ago
Settings.php
1 month ago
Shortcodes.php
1 month ago
Streamer.php
3 weeks ago
Translation.php
3 weeks ago
Usage.php
3 weeks ago
VideoPostType.php
2 weeks ago
Translation.php
154 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Translation. |
| 4 | * |
| 5 | * @package PrestoPlayer\Services |
| 6 | */ |
| 7 | |
| 8 | namespace PrestoPlayer\Services; |
| 9 | |
| 10 | use PrestoPlayer\Models\Setting; |
| 11 | use PrestoPlayer\Contracts\Service; |
| 12 | |
| 13 | /** |
| 14 | * Translation. |
| 15 | */ |
| 16 | class Translation implements Service { |
| 17 | |
| 18 | /** |
| 19 | * Preset name translations. |
| 20 | * |
| 21 | * @var array |
| 22 | */ |
| 23 | protected $preset_name_translations = array(); |
| 24 | |
| 25 | /** |
| 26 | * Register the service. |
| 27 | * |
| 28 | * @return void |
| 29 | */ |
| 30 | public function register() { |
| 31 | add_filter( 'presto_player/presto_player_presets/data', array( $this, 'translateDefaultPresets' ) ); |
| 32 | add_action( 'init', array( $this, 'loadPluginTextDomain' ), 0 ); |
| 33 | add_action( 'init', array( $this, 'initPresetTranslations' ), 0 ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * This is needed for Loco translate to work properly. |
| 38 | * |
| 39 | * @return void |
| 40 | */ |
| 41 | public function loadPluginTextDomain() { |
| 42 | load_plugin_textdomain( 'presto-player', false, dirname( plugin_basename( PRESTO_PLAYER_PLUGIN_FILE ) ) . '/languages' ); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Translate the default presets. |
| 47 | * |
| 48 | * @param object $preset Preset object. |
| 49 | * @return object |
| 50 | */ |
| 51 | public function translateDefaultPresets( $preset ) { |
| 52 | if ( empty( $preset->is_locked ) ) { |
| 53 | return $preset; |
| 54 | } |
| 55 | |
| 56 | // Translate name. |
| 57 | $preset->name = isset( $this->preset_name_translations[ $preset->slug ] ) ? $this->preset_name_translations[ $preset->slug ] : $preset->name; |
| 58 | |
| 59 | // Youtube options. |
| 60 | if ( 'youtube' === $preset->slug ) { |
| 61 | $preset->action_bar['text'] = __( 'Subscribe To Our YouTube Channel', 'presto-player' ); |
| 62 | // Unset action bar if no channel id. |
| 63 | if ( ! Setting::get( 'youtube', 'channel_id' ) ) { |
| 64 | unset( $preset->action_bar ); |
| 65 | return $preset; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | return $preset; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Get the i18n. |
| 74 | * |
| 75 | * @return array |
| 76 | */ |
| 77 | public static function geti18n() { |
| 78 | return array( |
| 79 | 'skip' => __( 'Skip', 'presto-player' ), |
| 80 | 'rewatch' => __( 'Rewatch', 'presto-player' ), |
| 81 | 'emailPlaceholder' => __( 'Email address', 'presto-player' ), |
| 82 | 'emailDefaultHeadline' => __( 'Enter your email to play this episode.', 'presto-player' ), |
| 83 | 'chapters' => __( 'Chapters', 'presto-player' ), |
| 84 | 'show_chapters' => __( 'Show Chapters', 'presto-player' ), |
| 85 | 'hide_chapters' => __( 'Hide Chapters', 'presto-player' ), |
| 86 | 'restart' => __( 'Restart', 'presto-player' ), |
| 87 | /* translators: {seektime} is replaced with the number of seconds, e.g. "Rewind 10s" */ |
| 88 | 'rewind' => __( 'Rewind {seektime}s', 'presto-player' ), |
| 89 | 'play' => __( 'Play', 'presto-player' ), |
| 90 | 'pause' => __( 'Pause', 'presto-player' ), |
| 91 | /* translators: {seektime} is replaced with the number of seconds, e.g. "Forward 10s" */ |
| 92 | 'fastForward' => __( 'Forward {seektime}s', 'presto-player' ), |
| 93 | 'seek' => __( 'Seek', 'presto-player' ), |
| 94 | /* translators: {currentTime} = current playback time, {duration} = total video length */ |
| 95 | 'seekLabel' => __( '{currentTime} of {duration}', 'presto-player' ), |
| 96 | 'played' => __( 'Played', 'presto-player' ), |
| 97 | 'buffered' => __( 'Buffered', 'presto-player' ), |
| 98 | 'currentTime' => __( 'Current time', 'presto-player' ), |
| 99 | 'duration' => __( 'Duration', 'presto-player' ), |
| 100 | 'volume' => __( 'Volume', 'presto-player' ), |
| 101 | 'mute' => __( 'Mute', 'presto-player' ), |
| 102 | 'unmute' => __( 'Unmute', 'presto-player' ), |
| 103 | 'enableCaptions' => __( 'Enable captions', 'presto-player' ), |
| 104 | 'disableCaptions' => __( 'Disable captions', 'presto-player' ), |
| 105 | 'download' => __( 'Download', 'presto-player' ), |
| 106 | 'enterFullscreen' => __( 'Enter fullscreen', 'presto-player' ), |
| 107 | 'exitFullscreen' => __( 'Exit fullscreen', 'presto-player' ), |
| 108 | 'frameTitle' => __( 'Player for {title}', 'presto-player' ), |
| 109 | 'captions' => __( 'Captions', 'presto-player' ), |
| 110 | 'settings' => __( 'Settings', 'presto-player' ), |
| 111 | 'pip' => __( 'PIP', 'presto-player' ), |
| 112 | 'menuBack' => __( 'Go back to previous menu', 'presto-player' ), |
| 113 | 'speed' => __( 'Speed', 'presto-player' ), |
| 114 | 'normal' => __( 'Normal', 'presto-player' ), |
| 115 | 'quality' => __( 'Quality', 'presto-player' ), |
| 116 | 'loop' => __( 'Loop', 'presto-player' ), |
| 117 | 'start' => __( 'Start', 'presto-player' ), |
| 118 | 'end' => __( 'End', 'presto-player' ), |
| 119 | 'all' => __( 'All', 'presto-player' ), |
| 120 | 'reset' => __( 'Reset', 'presto-player' ), |
| 121 | 'disabled' => __( 'Disabled', 'presto-player' ), |
| 122 | 'enabled' => __( 'Enabled', 'presto-player' ), |
| 123 | 'advertisement' => __( 'Ad', 'presto-player' ), |
| 124 | 'qualityBadge' => array( |
| 125 | 2160 => __( '4K', 'presto-player' ), |
| 126 | 1440 => __( 'HD', 'presto-player' ), |
| 127 | 1080 => __( 'HD', 'presto-player' ), |
| 128 | 720 => __( 'HD', 'presto-player' ), |
| 129 | 576 => __( 'SD', 'presto-player' ), |
| 130 | 480 => __( 'SD', 'presto-player' ), |
| 131 | ), |
| 132 | 'auto' => __( 'AUTO', 'presto-player' ), |
| 133 | 'next' => __( 'Next', 'presto-player' ), |
| 134 | 'upNext' => __( 'Up Next', 'presto-player' ), |
| 135 | 'startOver' => __( 'Start Over', 'presto-player' ), |
| 136 | ); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Set translated preset names here after text domain is loaded. |
| 141 | * |
| 142 | * @return void |
| 143 | */ |
| 144 | public function initPresetTranslations() { |
| 145 | $this->preset_name_translations = array( |
| 146 | 'default' => __( 'Default', 'presto-player' ), |
| 147 | 'course' => __( 'Course', 'presto-player' ), |
| 148 | 'simple' => __( 'Simple', 'presto-player' ), |
| 149 | 'minimal' => __( 'Minimal', 'presto-player' ), |
| 150 | 'youtube' => __( 'YouTube Optimized', 'presto-player' ), |
| 151 | ); |
| 152 | } |
| 153 | } |
| 154 |