class-redux-i18n.php (1538B)
1 <?php 2 /** 3 * Load the plugin text domain for translation. 4 * 5 * @package Redux Framework/Classes 6 * @since 3.0.5 7 */ 8 9 defined( 'ABSPATH' ) || exit; 10 11 if ( ! class_exists( 'Redux_I18n', false ) ) { 12 13 /** 14 * Class Redux_I18n 15 */ 16 class Redux_I18n extends Redux_Class { 17 18 /** 19 * Redux_I18n constructor. 20 * 21 * @param object $parent ReduxFramework pointer. 22 * @param string $file Translation file. 23 */ 24 public function __construct( $parent, string $file ) { 25 parent::__construct( $parent ); 26 27 $this->load( $file ); 28 } 29 30 /** 31 * Load translations. 32 * 33 * @param string $file Path to translation files. 34 */ 35 private function load( string $file ) { 36 $domain = 'redux-framework'; 37 38 $core = $this->core(); 39 40 /** 41 * Locale for text domain 42 * filter 'redux/textdomain/basepath/{opt_name}' 43 * 44 * @param string The locale of the blog or from the 'locale' hook 45 * @param string 'redux-framework' text domain 46 */ 47 // phpcs:ignore WordPress.NamingConventions.ValidHookName 48 $locale = apply_filters( 'redux/locale', get_locale(), 'redux-framework' ); 49 $mofile = $domain . '-' . $locale . '.mo'; 50 51 // phpcs:ignore WordPress.NamingConventions.ValidHookName 52 $basepath = apply_filters( "redux/textdomain/basepath/{$core->args['opt_name']}", Redux_Core::$dir ); 53 54 $loaded = load_textdomain( $domain, Redux_Core::$dir . 'languages/' . $mofile ); 55 56 if ( ! $loaded ) { 57 $mofile = WP_LANG_DIR . '/plugins/' . $mofile; 58 59 $loaded = load_textdomain( $domain, $mofile ); 60 } 61 } 62 } 63 }