class-kirki-l10n.php (12919B)
1 <?php 2 /** 3 * Internationalization helper. 4 * 5 * @package Kirki 6 * @category Core 7 * @author Aristeides Stathopoulos 8 * @copyright Copyright (c) 2016, Aristeides Stathopoulos 9 * @license http://opensource.org/licenses/https://opensource.org/licenses/MIT 10 * @since 1.0 11 */ 12 13 if ( ! class_exists('Kirki_l10n')) { 14 15 /** 16 * Handles translations 17 */ 18 class Kirki_l10n 19 { 20 21 /** 22 * The plugin textdomain 23 * 24 * @access protected 25 * @var string 26 */ 27 protected $textdomain = 'materialis'; 28 29 /** 30 * The class constructor. 31 * Adds actions & filters to handle the rest of the methods. 32 * 33 * @access public 34 */ 35 public function __construct() 36 { 37 38 add_action('plugins_loaded', array($this, 'load_textdomain')); 39 40 } 41 42 /** 43 * Load the plugin textdomain 44 * 45 * @access public 46 */ 47 public function load_textdomain() 48 { 49 50 if (null !== $this->get_path()) { 51 load_textdomain($this->textdomain, $this->get_path()); 52 } 53 load_plugin_textdomain($this->textdomain, false, Kirki::$path . '/languages'); 54 55 } 56 57 /** 58 * Gets the path to a translation file. 59 * 60 * @access protected 61 * @return string Absolute path to the translation file. 62 */ 63 protected function get_path() 64 { 65 $path_found = false; 66 $found_path = null; 67 foreach ($this->get_paths() as $path) { 68 if ($path_found) { 69 continue; 70 } 71 $path = wp_normalize_path($path); 72 if (file_exists($path)) { 73 $path_found = true; 74 $found_path = $path; 75 } 76 } 77 78 return $found_path; 79 80 } 81 82 /** 83 * Returns an array of paths where translation files may be located. 84 * 85 * @access protected 86 * @return array 87 */ 88 protected function get_paths() 89 { 90 91 return array( 92 WP_LANG_DIR . '/' . $this->textdomain . '-' . get_locale() . '.mo', 93 Kirki::$path . '/languages/' . $this->textdomain . '-' . get_locale() . '.mo', 94 ); 95 96 } 97 98 /** 99 * Shortcut method to get the translation strings 100 * 101 * @static 102 * @access public 103 * 104 * @param string $config_id The config ID. See Kirki_Config. 105 * 106 * @return array 107 */ 108 public static function get_strings($config_id = 'global') 109 { 110 111 $translation_strings = array( 112 'background-color' => esc_attr__('Background Color', 'materialis'), 113 'background-image' => esc_attr__('Background Image', 'materialis'), 114 'no-repeat' => esc_attr__('No Repeat', 'materialis'), 115 'repeat-all' => esc_attr__('Repeat All', 'materialis'), 116 'repeat-x' => esc_attr__('Repeat Horizontally', 'materialis'), 117 'repeat-y' => esc_attr__('Repeat Vertically', 'materialis'), 118 'inherit' => esc_attr__('Inherit', 'materialis'), 119 'background-repeat' => esc_attr__('Background Repeat', 'materialis'), 120 'cover' => esc_attr__('Cover', 'materialis'), 121 'contain' => esc_attr__('Contain', 'materialis'), 122 'background-size' => esc_attr__('Background Size', 'materialis'), 123 'fixed' => esc_attr__('Fixed', 'materialis'), 124 'scroll' => esc_attr__('Scroll', 'materialis'), 125 'background-attachment' => esc_attr__('Background Attachment', 'materialis'), 126 'left-top' => esc_attr__('Left Top', 'materialis'), 127 'left-center' => esc_attr__('Left Center', 'materialis'), 128 'left-bottom' => esc_attr__('Left Bottom', 'materialis'), 129 'right-top' => esc_attr__('Right Top', 'materialis'), 130 'right-center' => esc_attr__('Right Center', 'materialis'), 131 'right-bottom' => esc_attr__('Right Bottom', 'materialis'), 132 'center-top' => esc_attr__('Center Top', 'materialis'), 133 'center-center' => esc_attr__('Center Center', 'materialis'), 134 'center-bottom' => esc_attr__('Center Bottom', 'materialis'), 135 'background-position' => esc_attr__('Background Position', 'materialis'), 136 'background-opacity' => esc_attr__('Background Opacity', 'materialis'), 137 'on' => esc_attr__('ON', 'materialis'), 138 'off' => esc_attr__('OFF', 'materialis'), 139 'all' => esc_attr__('All', 'materialis'), 140 'cyrillic' => esc_attr__('Cyrillic', 'materialis'), 141 'cyrillic-ext' => esc_attr__('Cyrillic Extended', 'materialis'), 142 'devanagari' => esc_attr__('Devanagari', 'materialis'), 143 'greek' => esc_attr__('Greek', 'materialis'), 144 'greek-ext' => esc_attr__('Greek Extended', 'materialis'), 145 'khmer' => esc_attr__('Khmer', 'materialis'), 146 'latin' => esc_attr__('Latin', 'materialis'), 147 'latin-ext' => esc_attr__('Latin Extended', 'materialis'), 148 'vietnamese' => esc_attr__('Vietnamese', 'materialis'), 149 'hebrew' => esc_attr__('Hebrew', 'materialis'), 150 'arabic' => esc_attr__('Arabic', 'materialis'), 151 'bengali' => esc_attr__('Bengali', 'materialis'), 152 'gujarati' => esc_attr__('Gujarati', 'materialis'), 153 'tamil' => esc_attr__('Tamil', 'materialis'), 154 'telugu' => esc_attr__('Telugu', 'materialis'), 155 'thai' => esc_attr__('Thai', 'materialis'), 156 'serif' => _x('Serif', 'font style', 'materialis'), 157 'sans-serif' => _x('Sans Serif', 'font style', 'materialis'), 158 'monospace' => _x('Monospace', 'font style', 'materialis'), 159 'font-family' => esc_attr__('Font Family', 'materialis'), 160 'font-size' => esc_attr__('Font Size', 'materialis'), 161 'mobile-font-size' => esc_attr__('Mobile Font Size', 'materialis'), 162 'font-weight' => esc_attr__('Font Weight', 'materialis'), 163 'line-height' => esc_attr__('Line Height', 'materialis'), 164 'font-style' => esc_attr__('Font Style', 'materialis'), 165 'letter-spacing' => esc_attr__('Letter Spacing', 'materialis'), 166 'top' => esc_attr__('Top', 'materialis'), 167 'bottom' => esc_attr__('Bottom', 'materialis'), 168 'left' => esc_attr__('Left', 'materialis'), 169 'right' => esc_attr__('Right', 'materialis'), 170 'center' => esc_attr__('Center', 'materialis'), 171 'justify' => esc_attr__('Justify', 'materialis'), 172 'color' => esc_attr__('Color', 'materialis'), 173 'add-image' => esc_attr__('Add Image', 'materialis'), 174 'change-image' => esc_attr__('Change Image', 'materialis'), 175 'no-image-selected' => esc_attr__('No Image Selected', 'materialis'), 176 'add-file' => esc_attr__('Add File', 'materialis'), 177 'change-file' => esc_attr__('Change File', 'materialis'), 178 'no-file-selected' => esc_attr__('No File Selected', 'materialis'), 179 'remove' => esc_attr__('Remove', 'materialis'), 180 'select-font-family' => esc_attr__('Select a font-family', 'materialis'), 181 'variant' => esc_attr__('Variant', 'materialis'), 182 'subsets' => esc_attr__('Subset', 'materialis'), 183 'size' => esc_attr__('Size', 'materialis'), 184 'height' => esc_attr__('Height', 'materialis'), 185 'spacing' => esc_attr__('Spacing', 'materialis'), 186 'ultra-light' => esc_attr__('Thin (100)', 'materialis'), 187 'ultra-light-italic' => esc_attr__('Thin (100) Italic', 'materialis'), 188 'light' => esc_attr__('Extra light (200)', 'materialis'), 189 'light-italic' => esc_attr__('Extra light (200) Italic', 'materialis'), 190 'book' => esc_attr__('Light (300)', 'materialis'), 191 'book-italic' => esc_attr__('Light (300) Italic', 'materialis'), 192 'regular' => esc_attr__('Normal (400)', 'materialis'), 193 'italic' => esc_attr__('Normal (400) Italic', 'materialis'), 194 'medium' => esc_attr__('Medium (500)', 'materialis'), 195 'medium-italic' => esc_attr__('Medium (500) Italic', 'materialis'), 196 'semi-bold' => esc_attr__('Semi Bold (600)', 'materialis'), 197 'semi-bold-italic' => esc_attr__('Semi Bold (600) Italic', 'materialis'), 198 'bold' => esc_attr__('Bold (700)', 'materialis'), 199 'bold-italic' => esc_attr__('Bold (700) Italic', 'materialis'), 200 'extra-bold' => esc_attr__('Extra Bold (800)', 'materialis'), 201 'extra-bold-italic' => esc_attr__('Extra Bold (800) Italic', 'materialis'), 202 'ultra-bold' => esc_attr__('Black (900)', 'materialis'), 203 'ultra-bold-italic' => esc_attr__('Black (900) Italic', 'materialis'), 204 'invalid-value' => esc_attr__('Invalid Value', 'materialis'), 205 'add-new' => esc_attr__('Add new', 'materialis'), 206 'row' => esc_attr__('row', 'materialis'), 207 'limit-rows' => esc_attr__('Limit: %s rows', 'materialis'), 208 'open-section' => esc_attr__('Press return or enter to open this section', 'materialis'), 209 'back' => esc_attr__('Back', 'materialis'), 210 'reset-with-icon' => sprintf(esc_attr__('%s Reset', 'materialis'), '<span class="dashicons dashicons-image-rotate"></span>'), 211 'text-align' => esc_attr__('Text Align', 'materialis'), 212 'text-transform' => esc_attr__('Text Transform', 'materialis'), 213 'none' => esc_attr__('None', 'materialis'), 214 'capitalize' => esc_attr__('Capitalize', 'materialis'), 215 'uppercase' => esc_attr__('Uppercase', 'materialis'), 216 'lowercase' => esc_attr__('Lowercase', 'materialis'), 217 'initial' => esc_attr__('Initial', 'materialis'), 218 'select-page' => esc_attr__('Select a Page', 'materialis'), 219 'open-editor' => esc_attr__('Open Editor', 'materialis'), 220 'close-editor' => esc_attr__('Close Editor', 'materialis'), 221 'switch-editor' => esc_attr__('Switch Editor', 'materialis'), 222 'hex-value' => esc_attr__('Hex Value', 'materialis'), 223 'addwebfont' => esc_attr__('Add Web Font', 'materialis'), 224 ); 225 226 // Apply global changes from the kirki/config filter. 227 // This is generally to be avoided. 228 // It is ONLY provided here for backwards-compatibility reasons. 229 // Please use the kirki/{$config_id}/l10n filter instead. 230 $config = apply_filters('kirki/config', array()); 231 if (isset($config['i18n'])) { 232 $translation_strings = wp_parse_args($config['i18n'], $translation_strings); 233 } 234 235 // Apply l10n changes using the kirki/{$config_id}/l10n filter. 236 return apply_filters('kirki/' . $config_id . '/l10n', $translation_strings); 237 238 } 239 } 240 }