From: Elliott Eggleston Date: Sun, 6 Oct 2019 16:24:18 +0000 (+0200) Subject: dev/translation#30 Move l10n resource dir under private files X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1b94154b5b444fcc363b199c0d3a31e481622153;p=civicrm-core.git dev/translation#30 Move l10n resource dir under private files Looks under [civicrm.private]/l10n if that exists, falling back to [civicrm.root]/l10n. Since I18n::getResourceDirectory needs to be called from GenCode, where we don't have the base directory defined, we make the l10n path factory function consult new #define CIVICRM_L10N_BASEDIR first. In GenCode itself, keep using the old location for now, but make it possible to change the location with an env var as soon as we update buildkit. --- diff --git a/CRM/Core/Config/MagicMerge.php b/CRM/Core/Config/MagicMerge.php index 84f27ed990..401c0c0ef5 100644 --- a/CRM/Core/Config/MagicMerge.php +++ b/CRM/Core/Config/MagicMerge.php @@ -178,6 +178,7 @@ class CRM_Core_Config_MagicMerge { // Option: `restrict` - auto-restrict remote access 'configAndLogDir' => ['path', 'civicrm.log', ['mkdir', 'restrict']], 'templateCompileDir' => ['path', 'civicrm.compile', ['mkdir', 'restrict']], + 'l10nDir' => ['path', 'civicrm.l10n', ['mkdir', 'restrict']], // "setting-path" properties are settings with special filtering // to return normalized file paths. diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index be23d592ff..8a97d428c2 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -282,11 +282,7 @@ class CRM_Core_I18n { * @return string */ public static function getResourceDir() { - static $dir = NULL; - if ($dir === NULL) { - $dir = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'l10n' . DIRECTORY_SEPARATOR; - } - return $dir; + return \Civi::paths()->getPath('[civicrm.l10n]/.'); } /** diff --git a/Civi/Core/Paths.php b/Civi/Core/Paths.php index 29bd7393d0..a4ab40c220 100644 --- a/Civi/Core/Paths.php +++ b/Civi/Core/Paths.php @@ -78,6 +78,12 @@ class Paths { 'path' => defined('CIVICRM_TEMPLATE_COMPILEDIR') ? CIVICRM_TEMPLATE_COMPILEDIR : \Civi::paths()->getPath('[civicrm.private]/templates_c'), ]; }) + ->register('civicrm.l10n', function () { + $dir = defined('CIVICRM_L10N_BASEDIR') ? CIVICRM_L10N_BASEDIR : \Civi::paths()->getPath('[civicrm.private]/l10n'); + return [ + 'path' => is_dir($dir) ? $dir : \Civi::paths()->getPath('[civicrm.root]/l10n'), + ]; + }) ->register('wp.frontend.base', function () { return ['url' => rtrim(CIVICRM_UF_BASEURL, '/') . '/']; }) diff --git a/xml/GenCode.php b/xml/GenCode.php index cee7f1475a..01b541c9bd 100644 --- a/xml/GenCode.php +++ b/xml/GenCode.php @@ -27,6 +27,7 @@ date_default_timezone_set('UTC'); define('CIVICRM_UF', 'Drupal'); define('CIVICRM_UF_BASEURL', '/'); +define('CIVICRM_L10N_BASEDIR', getenv('CIVICRM_L10N_BASEDIR') ? getenv('CIVICRM_L10N_BASEDIR') : __DIR__ . '/../l10n'); require_once 'CRM/Core/ClassLoader.php'; CRM_Core_ClassLoader::singleton()->register();