From a6c0927751b5b2a1cda8f191fa0f9f1a41b87cd0 Mon Sep 17 00:00:00 2001 From: Awilum Date: Fri, 27 Apr 2018 23:54:09 +0300 Subject: [PATCH] Remove I18n class --- flextype/Flextype.php | 3 - flextype/I18n.php | 157 ------------------------------------------ 2 files changed, 160 deletions(-) delete mode 100644 flextype/I18n.php diff --git a/flextype/Flextype.php b/flextype/Flextype.php index a0712c37..8d76c46e 100755 --- a/flextype/Flextype.php +++ b/flextype/Flextype.php @@ -92,9 +92,6 @@ class Flextype // Create Cache Instance Cache::instance(); - // Create I18n Instance - I18n::instance(); - // Create Shortcodes Instance Shortcodes::instance(); diff --git a/flextype/I18n.php b/flextype/I18n.php deleted file mode 100644 index 5a056090..00000000 --- a/flextype/I18n.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @link http://flextype.org - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flextype; - -use Flextype\Component\Filesystem\Filesystem; -use Symfony\Component\Yaml\Yaml; - -class I18n -{ - /** - * An instance of the I18n class - * - * @var object - */ - protected static $instance = null; - - /** - * Locales array - * - * @var array - */ - public static $locales = [ - 'ar' => 'العربية', - 'bg' => 'Български', - 'ca' => 'Català', - 'cs' => 'Česky', - 'da' => 'Dansk', - 'de' => 'Deutsch', - 'el' => 'Ελληνικά', - 'en' => 'English', - 'es' => 'Español', - 'fa' => 'Farsi', - 'fi' => 'Suomi', - 'fr' => 'Français', - 'gl' => 'Galego', - 'ka-ge' => 'Georgian', - 'hu' => 'Magyar', - 'it' => 'Italiano', - 'id' => 'Bahasa Indonesia', - 'ja' => '日本語', - 'lt' => 'Lietuvių', - 'nl' => 'Nederlands', - 'no' => 'Norsk', - 'pl' => 'Polski', - 'pt' => 'Português', - 'pt-br' => 'Português do Brasil', - 'ru' => 'Русский', - 'sk' => 'Slovenčina', - 'sl' => 'Slovenščina', - 'sv' => 'Svenska', - 'sr' => 'Srpski', - 'tr' => 'Türkçe', - 'uk' => 'Українська', - 'zh-cn' => '简体中文', - ]; - - /** - * Dictionary - * - * @var array - */ - public static $dictionary = []; - - /** - * Protected clone method to enforce singleton behavior. - * - * @access protected - */ - protected function __clone() - { - // Nothing here. - } - - /** - * Protected constructor since this is a static class. - * - * @access protected - */ - protected function __construct() - { - static::init(); - } - - /** - * Init I18n - * - * @access protected - * @return void - */ - protected static function init() : void - { - - // Get Plugins and Site Locales list - (array) $plugins_list = Config::get('site.plugins'); - (array) $dictionary = []; - - // Create dictionary - if (is_array($plugins_list) && count($plugins_list) > 0) { - foreach (static::$locales as $locale => $locale_title) { - foreach ($plugins_list as $plugin) { - $language_file = PLUGINS_PATH . '/' . $plugin . '/languages/' . $locale . '.yml'; - if (Filesystem::fileExists($language_file)) { - $dictionary[$plugin][$locale] = Yaml::parseFile($language_file); - } - } - } - } - - // Save dictionary - static::$dictionary = $dictionary; - } - - /** - * Returns translation of a string. If no translation exists, the original - * string will be returned. No parameters are replaced. - * - * @param string $string Text to translate - * @param string $namespace Namespace - * @param string $locale Locale - * @return string - */ - public static function find(string $string, string $namespace, string $locale, array $values = []) : string - { - // Search current string to translate in the Dictionary - if (isset(static::$dictionary[$namespace][$locale][$string])) { - $string = static::$dictionary[$namespace][$locale][$string]; - $string = empty($values) ? $string : strtr($string, $values); - } else { - $string = $string; - } - - // Return translation of a string - return $string; - } - - /** - * Return the I18n instance. - * Create it if it's not already created. - * - * @access public - * @return object - */ - public static function instance() - { - return !isset(self::$instance) and self::$instance = new I18n(); - } -}