Skip to content

Commit

Permalink
Merge pull request #23435 from mlutfy/removeOldL10nDir
Browse files Browse the repository at this point in the history
Translation: remove support for CiviCRM pre-4.5 l10n file locations
  • Loading branch information
eileenmcnaughton authored May 11, 2022
2 parents 5376bfc + 6a0d01b commit fed6123
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions CRM/Core/I18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public function isNative() {
* @param string $locale
*/
protected function setNativeGettextLocale($locale) {

$locale .= '.utf8';
putenv("LANG=$locale");

Expand All @@ -141,33 +140,29 @@ protected function setNativeGettextLocale($locale) {

$this->_phpgettext = new CRM_Core_I18n_NativeGettext();
$this->_extensioncache['civicrm'] = 'civicrm';

}

/**
* Set getText locale.
*
* Since CiviCRM 4.5, expected dir structure is civicrm/l10n/xx_XX/LC_MESSAGES/civicrm.mo
* because that is what native gettext expects. Fallback support for the pre-4.5 structure
* was removed in CiviCRM 5.51.
*
* CiviCRM 5.23 added support for the CIVICRM_L10N_BASEDIR constant (and [civicrm.l10n])
* so that mo files can be stored elsewhere (such as in a web-writable directory, to
* support extensions sur as l10nupdate.
*
* @param string $locale
*/
protected function setPhpGettextLocale($locale) {

// we support both the old file hierarchy format and the new:
// pre-4.5: civicrm/l10n/xx_XX/civicrm.mo
// post-4.5: civicrm/l10n/xx_XX/LC_MESSAGES/civicrm.mo
require_once 'PHPgettext/streams.php';
require_once 'PHPgettext/gettext.php';

$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 = CRM_Core_I18n::getResourceDir() . $locale . DIRECTORY_SEPARATOR . 'civicrm.mo';
}

$streamer = new FileReader($mo_file);
$this->_phpgettext = new gettext_reader($streamer);
$this->_extensioncache['civicrm'] = $this->_phpgettext;

}

/**
Expand Down

0 comments on commit fed6123

Please sign in to comment.