/** * Container for the main instance of the class. * * @since 6.5.0 * @var WP_Translation_Controller|null */ private static $instance = null;
/** * Utility method to retrieve the main instance of the class. * * The instance will be created if it does not exist yet. * * @since 6.5.0 * * @return WP_Translation_Controller */ public static function get_instance(): WP_Translation_Controller { if ( null === self::$instance ) { self::$instance = new self(); }
return self::$instance; }
/** * Returns the current locale. * * @since 6.5.0 * * @return string Locale. */ public function get_locale(): string { return $this->current_locale; }
/** * Sets the current locale. * * @since 6.5.0 * * @param string $locale Locale. */ public function set_locale( string $locale ) { $this->current_locale = $locale; }
/** * Loads a translation file for a given text domain. * * @since 6.5.0 * * @param string $translation_file Translation file. * @param string $textdomain Optional. Text domain. Default 'default'. * @param string $locale Optional. Locale. Default current locale. * @return bool True on success, false otherwise. */ public function load_file( string $translation_file, string $textdomain = 'default', ?string $locale = null ): bool { if ( null === $locale ) { $locale = $this->current_locale; }