| @@ -1,47 +1,70 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Define the internationalization functionality | |
| 5 | - * | |
| 6 | - * Loads and defines the internationalization files for this plugin | |
| 7 | - * so that it is ready for translation. | |
| 8 | - * | |
| 9 | - * @link https://ays-pro.com/ | |
| 10 | - * @since 1.0.0 | |
| 11 | - * | |
| 12 | - * @package Chart_Builder | |
| 13 | - * @subpackage Chart_Builder/includes | |
| 14 | - */ | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * Define the internationalization functionality. | |
| 18 | - * | |
| 19 | - * Loads and defines the internationalization files for this plugin | |
| 20 | - * so that it is ready for translation. | |
| 21 | - * | |
| 22 | - * @since 1.0.0 | |
| 23 | - * @package Chart_Builder | |
| 24 | - * @subpackage Chart_Builder/includes | |
| 25 | - * @author Chart Builder Team <[email protected]> | |
| 26 | - */ | |
| 27 | -class Chart_Builder_i18n { | |
| 28 | - | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * Load the plugin text domain for translation. | |
| 32 | - * | |
| 33 | - * @since 1.0.0 | |
| 34 | - */ | |
| 35 | - public function load_plugin_textdomain() { | |
| 36 | - | |
| 37 | - load_plugin_textdomain( | |
| 38 | - "chart-builder", | |
| 39 | - false, | |
| 40 | - dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' | |
| 41 | - ); | |
| 42 | - | |
| 43 | - } | |
| 44 | - | |
| 45 | - | |
| 46 | - | |
| 47 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Define the internationalization functionality | |
| 5 | + * | |
| 6 | + * Loads and defines the internationalization files for this plugin | |
| 7 | + * so that it is ready for translation. | |
| 8 | + * | |
| 9 | + * @link https://ays-pro.com/ | |
| 10 | + * @since 1.0.0 | |
| 11 | + * | |
| 12 | + * @package Chart_Builder | |
| 13 | + * @subpackage Chart_Builder/includes | |
| 14 | + */ | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Define the internationalization functionality. | |
| 18 | + * | |
| 19 | + * Loads and defines the internationalization files for this plugin | |
| 20 | + * so that it is ready for translation. | |
| 21 | + * | |
| 22 | + * @since 1.0.0 | |
| 23 | + * @package Chart_Builder | |
| 24 | + * @subpackage Chart_Builder/includes | |
| 25 | + * @author Chart Builder Team <[email protected]> | |
| 26 | + */ | |
| 27 | +class Chart_Builder_i18n { | |
| 28 | + | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * Load the plugin text domain for translation. | |
| 32 | + * | |
| 33 | + * @since 1.0.0 | |
| 34 | + */ | |
| 35 | + public function load_plugin_textdomain() { | |
| 36 | + | |
| 37 | + if ( version_compare( get_bloginfo( 'version' ), '6.7', '>=' ) ) { | |
| 38 | + $plugin = 'chart-builder'; | |
| 39 | + if( is_admin() ){ | |
| 40 | + $locale = get_user_locale(); | |
| 41 | + } else { | |
| 42 | + $locale = get_locale(); | |
| 43 | + } | |
| 44 | + | |
| 45 | + | |
| 46 | + if ( is_textdomain_loaded( $plugin ) ) { | |
| 47 | + unload_textdomain( $plugin ); | |
| 48 | + } | |
| 49 | + $mofile = sprintf( '%s-%s.mo', $plugin, $locale ); | |
| 50 | + //check the installation language path first. | |
| 51 | + $domain_path = path_join( WP_LANG_DIR, 'plugins' ); | |
| 52 | + $loaded = load_textdomain( $plugin, path_join( $domain_path, $mofile ) ); | |
| 53 | + | |
| 54 | + if ( ! $loaded ) { //else, check the plugin language folder. | |
| 55 | + $domain_path = path_join( WP_PLUGIN_DIR, "{$plugin}/languages" ); | |
| 56 | + load_textdomain( $plugin, path_join( $domain_path, $mofile ) ); | |
| 57 | + } | |
| 58 | + } else { | |
| 59 | + load_plugin_textdomain( | |
| 60 | + 'chart-builder', | |
| 61 | + false, | |
| 62 | + dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' | |
| 63 | + ); | |
| 64 | + } | |
| 65 | + | |
| 66 | + } | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | +} | |