From 4d8ce7f0d726faee9694a99cbf27594237ffbb3d Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sun, 16 Aug 2015 18:17:38 -0700 Subject: [PATCH] CRM-16373 - Config - Remove gettextResourceDir This field is not a genuine setting - it's a small variant on `$civicrm_root`. Use CRM_Core_I18n::getResourceDir() instead. --- CRM/Core/CodeGen/Schema.php | 8 +------- CRM/Core/Config/Defaults.php | 2 -- CRM/Core/Config/Variables.php | 5 ----- CRM/Core/I18n.php | 16 ++++++++++++---- install/index.php | 1 - 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/CRM/Core/CodeGen/Schema.php b/CRM/Core/CodeGen/Schema.php index c2c2f19de5..c8b0a04f9d 100644 --- a/CRM/Core/CodeGen/Schema.php +++ b/CRM/Core/CodeGen/Schema.php @@ -108,14 +108,8 @@ class CRM_Core_CodeGen_Schema extends CRM_Core_CodeGen_BaseTask { require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(FALSE); $locales = array(); - if (substr($config->gettextResourceDir, 0, 1) === '/') { - $localeDir = $config->gettextResourceDir; - } - else { - $localeDir = '../' . $config->gettextResourceDir; - } + $localeDir = CRM_Core_I18n::getResourceDir(); if (file_exists($localeDir)) { - $config->gettextResourceDir = $localeDir; $locales = preg_grep('/^[a-z][a-z]_[A-Z][A-Z]$/', scandir($localeDir)); } diff --git a/CRM/Core/Config/Defaults.php b/CRM/Core/Config/Defaults.php index c56f7b59c7..cd2ff7398b 100644 --- a/CRM/Core/Config/Defaults.php +++ b/CRM/Core/Config/Defaults.php @@ -59,8 +59,6 @@ class CRM_Core_Config_Defaults { $this->importDataSourceDir = $civicrm_root . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Import' . DIRECTORY_SEPARATOR . 'DataSource' . DIRECTORY_SEPARATOR; - $this->gettextResourceDir = $civicrm_root . DIRECTORY_SEPARATOR . 'l10n' . DIRECTORY_SEPARATOR; - // show tree widget $this->groupTree = defined('CIVICRM_GROUPTREE') ? TRUE : FALSE; diff --git a/CRM/Core/Config/Variables.php b/CRM/Core/Config/Variables.php index 10e72d65f6..e84474f6be 100644 --- a/CRM/Core/Config/Variables.php +++ b/CRM/Core/Config/Variables.php @@ -228,11 +228,6 @@ class CRM_Core_Config_Variables extends CRM_Core_Config_Defaults { */ public $monetaryThousandSeparator = ','; - /** - * Default location of gettext resource files. - */ - public $gettextResourceDir = './l10n/'; - /** * Default user framework. This basically makes Drupal 7 the default */ diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index 7b7e53d767..ff01ff3e3b 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -77,7 +77,7 @@ class CRM_Core_I18n { setlocale(LC_MESSAGES, $locale); setlocale(LC_CTYPE, $locale); - bindtextdomain('civicrm', $config->gettextResourceDir); + bindtextdomain('civicrm', CRM_Core_I18n::getResourceDir()); bind_textdomain_codeset('civicrm', 'UTF-8'); textdomain('civicrm'); @@ -93,11 +93,11 @@ class CRM_Core_I18n { require_once 'PHPgettext/streams.php'; require_once 'PHPgettext/gettext.php'; - $mo_file = $config->gettextResourceDir . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR . 'civicrm.mo'; + $mo_file = CRM_Core_I18n::getResourceDir() . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR . 'civicrm.mo'; if (!file_exists($mo_file)) { // fallback to pre-4.5 mode - $mo_file = $config->gettextResourceDir . $locale . DIRECTORY_SEPARATOR . 'civicrm.mo'; + $mo_file = CRM_Core_I18n::getResourceDir() . $locale . DIRECTORY_SEPARATOR . 'civicrm.mo'; } $streamer = new FileReader($mo_file); @@ -135,7 +135,7 @@ class CRM_Core_I18n { // check which ones are available; add them to $all if not there already $config = CRM_Core_Config::singleton(); $codes = array(); - if (is_dir($config->gettextResourceDir) && $dir = opendir($config->gettextResourceDir)) { + if (is_dir(CRM_Core_I18n::getResourceDir()) && $dir = opendir(CRM_Core_I18n::getResourceDir())) { while ($filename = readdir($dir)) { if (preg_match('/^[a-z][a-z]_[A-Z][A-Z]$/', $filename)) { $codes[] = $filename; @@ -199,6 +199,14 @@ class CRM_Core_I18n { return strtr($str, $tr); } + public static function getResourceDir() { + static $dir = NULL; + if ($dir === NULL) { + $dir = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'l10n' . DIRECTORY_SEPARATOR; + } + return $dir; + } + /** * Smarty block function, provides gettext support for smarty. * diff --git a/install/index.php b/install/index.php index 3e461f5281..d3a822246c 100644 --- a/install/index.php +++ b/install/index.php @@ -170,7 +170,6 @@ $config = CRM_Core_Config::singleton(FALSE); $GLOBALS['civicrm_default_error_scope'] = NULL; // The translation files are in the parent directory (l10n) -$config->gettextResourceDir = '..' . DIRECTORY_SEPARATOR . $config->gettextResourceDir; $i18n = CRM_Core_I18n::singleton(); global $cmsPath; -- 2.25.1